快捷复制粘贴.ahk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ; @Author : liuyuqi
  2. ; @Contact : liuyuqi.gov@msn.cn
  3. ; @Time : 2019/08/05 07:06:02
  4. ; @Version : 1.0
  5. ; @License : (C)Copyright 2019 liuyuqi.
  6. ; @Desc : 鼠标操作:左键拖选复制 + 中键粘贴 + 长按中键滚动
  7. $*MButton::
  8. Hotkey, $*MButton Up, MButtonup, off
  9. KeyWait, MButton, T0.15
  10. If ErrorLevel = 1
  11. {
  12. Hotkey, $*MButton Up, MButtonup, on
  13. MouseGetPos, ox, oy
  14. SetTimer, WatchTheMouse, 1
  15. SystemCursor("Toggle")
  16. }
  17. Else {
  18. Send {LButton}
  19. SendInput ^v
  20. }
  21. Return
  22. ; 左键拖选复制
  23. ~LButton::
  24. cos_mousedrag_treshold := 20 ; pixels
  25. MouseGetPos, cos_mousedrag_x, cos_mousedrag_y
  26. win1 := WinActive("A")
  27. KeyWait LButton
  28. MouseGetPos, cos_mousedrag_x2, cos_mousedrag_y2
  29. win2 := WinActive("A")
  30. WinGetClass cos_class, A
  31. if(((abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold
  32. or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold)) and win1 = win2
  33. and cos_class != "ConsoleWindowClass")
  34. {
  35. SendInput ^c ; Ctrl+C复制
  36. }
  37. Return
  38. ; Shift+中键点击
  39. +MButton::
  40. Send {MButton}
  41. Return
  42. MButtonup:
  43. Hotkey, $*MButton Up, MButtonup, off
  44. SetTimer, WatchTheMouse, off
  45. SystemCursor("Toggle")
  46. Return
  47. WatchTheMouse:
  48. MouseGetPos, nx, ny
  49. dy := ny-oy
  50. dx := nx-ox
  51. If (dx**2 > 0 and dx**2>dy**2) ;edit 4 for sensitivity (changes sensitivity to movement)
  52. {
  53. times := Abs(dy)/1 ;edit 1 for sensitivity (changes frequency of scroll signal)
  54. Loop, %times%
  55. {
  56. If (dx > 0)
  57. Click WheelRight
  58. Else
  59. Click WheelLeft
  60. }
  61. }
  62. If (dy**2 > 0 and dy**2>dx**2) ;edit 0 for sensitivity (changes sensitivity to movement)
  63. {
  64. times := Abs(dy)/1 ;edit 1 for sensitivity (changes frequency of scroll signal)
  65. Loop, %times%
  66. {
  67. If (dy > 0)
  68. Click WheelDown
  69. Else
  70. Click WheelUp
  71. }
  72. }
  73. MouseMove ox, oy
  74. Return
  75. SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
  76. {
  77. static AndMask, XorMask, $, h_cursor
  78. ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
  79. , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
  80. , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
  81. if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
  82. {
  83. $ = h ; active default cursors
  84. VarSetCapacity( h_cursor,4444, 1 )
  85. VarSetCapacity( AndMask, 32*4, 0xFF )
  86. VarSetCapacity( XorMask, 32*4, 0 )
  87. system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
  88. StringSplit c, system_cursors, `,
  89. Loop %c0%
  90. {
  91. h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
  92. h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
  93. b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
  94. , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
  95. }
  96. }
  97. if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
  98. $ = b ; use blank cursors
  99. else
  100. $ = h ; use the saved cursors
  101. Loop %c0%
  102. {
  103. h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
  104. DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
  105. }
  106. }
  107. Return