Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; Mirror.ahk mirrors mouse clicks on one half of the screen to the other half
  3. ; http://superuser.com/questions/393738/
  4. ;
  5. ; (cl) 2012- Synetech inc., Alec Soroudi
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8.  
  9.  
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. ; Hotkeys:
  12. ; Alt+Shift+Q to toggle mirroring
  13. ; Ctrl+Shift+Q to toggle autofire
  14. ; Ctrl+Alt+Shift+Q to completely pause the script (mouse behaves normally)
  15. ; Ctrl+Alt+Shift+Win+Q to quit
  16. ;
  17. ; Defaults to single-click, mirrored
  18. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19.  
  20.  
  21.  
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23. #SingleInstance force
  24. CoordMode, Mouse, Screen
  25. SetDefaultMouseSpeed, 0
  26. SetMouseDelay, -1
  27. SendMode Play ;Try modes Event, Input, or Play
  28.  
  29.  
  30. ;Variables
  31. SysGet, MonitorWorkArea, MonitorWorkArea, %A_Index%
  32. Half := (MonitorWorkAreaRight - MonitorWorkAreaLeft) >> 1
  33. Mirror := 1
  34. Autofire := 0
  35.  
  36.  
  37.  
  38. ;Main function
  39. Dupe(action, var) {
  40. ;Calculate other half
  41. MouseGetPos, x,y
  42. Global Half
  43. if (x<Half) {
  44. Left := (Half + x)
  45. }
  46. else {
  47. Left := (x - Half)
  48. }
  49.  
  50. Global Mirror
  51. if (action=0) { ;Mouse
  52. if (var=0) { ;Left-click
  53. if Mirror
  54. Click %Left% %y% Left
  55. Click %x% %y% Left
  56. }
  57.  
  58. else if (var=1) { ;Right-click
  59. Click %Left% %y% Right
  60. Click %x% %y% Right
  61. }
  62.  
  63. else if (var=2) { ;Middle-click
  64. Click %Left% %y% Middle
  65. Click %x% %y% Middle
  66. }
  67.  
  68. else if (var=3) { ;Button4-click
  69. Click %Left% %y% X1
  70. Click %x% %y% X1
  71. }
  72.  
  73. else if (var=4) { ;Button5-click
  74. Click %Left% %y% X2
  75. Click %x% %y% X2
  76. }
  77. }
  78.  
  79.  
  80. ; else if (action=1) { ;Keyboard - do what???
  81. ; }
  82. }
  83.  
  84.  
  85.  
  86. ;Hotkeys
  87. !+q:: ;Pause mirroring with Alt+Shift+Q
  88. Mirror := !Mirror
  89. ; MsgBox Mirror: %Mirror%
  90. return
  91.  
  92. ^+q:: ;Toggle autofire with Ctrl+Shift+Q
  93. Autofire := !Autofire
  94. ; MsgBox Autofire: %Autofire%
  95. return
  96.  
  97. ^!+q:: ;Pause script with Ctrl+Alt+Shift+Q
  98. Suspend
  99. ; if (A_IsSuspended = 1)
  100. ; MsgBox Hotkeys suspended
  101. ; else
  102. ; MsgBox Hotkeys resumed
  103. return
  104.  
  105. ^!+#q:: ;Quit with Ctrl+Alt+Shift+Win+Q
  106. ; MsgBox Quitting
  107. ExitApp
  108. return
  109.  
  110. +#q:: ;Reload/restart script with Shift+Win+Q
  111. ; MsgBox Reloading
  112. Reload
  113. return
  114.  
  115.  
  116.  
  117. ;Handlers
  118. *$LButton::
  119. Loop {
  120. ; if (Mirror)
  121. Dupe(0, 0)
  122. GetKeyState, State, LButton, P
  123. if (!Autofire || State = "U")
  124. Break
  125. }
  126. return
  127.  
  128. *$RButton::
  129. Loop {
  130. if (Mirror)
  131. Dupe(0, 1)
  132. GetKeyState, State, RButton, P
  133. if (!Autofire || State = "U")
  134. Break
  135. }
  136. return
  137.  
  138. *$MButton::
  139. Loop {
  140. if (Mirror)
  141. Dupe(0, 2)
  142. GetKeyState, State, MButton, P
  143. if (!Autofire || State = "U")
  144. Break
  145. }
  146. return
  147.  
  148. *$XButton1::
  149. Loop {
  150. if (Mirror)
  151. Dupe(0, 3)
  152. GetKeyState, State, XButton1, P
  153. if (!Autofire || State = "U")
  154. Break
  155. }
  156. return
  157.  
  158. *$XButton2::
  159. Loop {
  160. if (Mirror)
  161. Dupe(0, 4)
  162. GetKeyState, State, XButton2, P
  163. if (!Autofire || State = "U")
  164. Break
  165. }
  166. return
  167. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement