Advertisement
Guest User

gkeys

a guest
Nov 5th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This is the start of a hotkey block. I chose to use Win+Q for this hotkey but you might have to
  2. ; change it to suit your own keyboard.
  3. ; http://www.autohotkey.com/docs/Hotkeys.htm#Symbols
  4.  
  5. ;;Global variable initialization
  6. DEBUG := true
  7. MaxX := 1000
  8. MaxY := 600
  9. ;These values are coordinate offsets from the Origin for the item bar hotkeys; the values do not change.
  10. Item0X := 250
  11. ItemsY := 523
  12. ItemWidth := 53
  13. if(DEBUG)
  14. DragSpeed := 5
  15. else
  16. DragSpeed := 1
  17.  
  18. #q::
  19. If (HotkeysEnabled == true)
  20. {
  21. HotkeysEnabled := false
  22. HasCroissant := false
  23. MsgBox, , GrinnKeys, Hotkeys turned off, 2
  24. } else {
  25. IfWinExist, Play The Grinns Tale
  26. WinActivate
  27. else
  28. return
  29.  
  30. ; This is the core of the Anchor system. It requires a picture to be found in the
  31. ; same directory as this script is run from. This is a cropped picture of the Pramin
  32. ; on the top bar that is almost always found in the exact same spot. It allows us to
  33. ; determine where in the window the top/left corner of the game is so we can use the
  34. ; right coordinates for the rest of the code.
  35. ImageSearch, _FoundX, _FoundY, 0, 0, 1300, 700, *25 GTPramin.png
  36. if (ErrorLevel == 1){
  37. MsgBox, , GrinnKeys, Pramin image not found on screen.
  38. return
  39. } else if (ErrorLevel == 2){
  40. MsgBox, , GrinnKeys, GTPramin.png was not found in the script directory
  41. return
  42. }
  43. OriginX := _FoundX - 155
  44. OriginY := _FoundY - 0
  45. ImageSearch, _FoundX, _FoundY, 0, 500, 1300, 900, *25 *TransBlack GTCroissant.png
  46. if (ErrorLevel == 1){
  47. MsgBox, , GrinnKeys, Croissant image not found on screen.
  48. HasCroissant := false
  49. } else if (ErrorLevel == 2){
  50. MsgBox, , GrinnKeys, GTCroissant.png was not found in the script directory
  51. HasCroissant := false
  52. } else if (ErrorLevel == 0){
  53. HasCroissant := true
  54. CroissantX := _FoundX + 15 - OriginX
  55. CroissantY := _FoundY + 15 - OriginY
  56. }
  57. HotkeysEnabled := true
  58. if (HasCroissant){
  59. MsgBox, , GrinnKeys, Hotkeys turned on `n` Croissant was found. Hotkey 4 is active, 2
  60. } else {
  61. MsgBox, , GrinnKeys, Hotkeys turned on `n` Croissant was not found. Hotkey 4 is inactive, 2
  62. }
  63. }
  64. return
  65.  
  66. ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
  67. #IfWinActive, Play The Grinns Tale
  68. 1::
  69. ; We are only going to go further if the hotkeys are turned on.
  70. ; This allows us to check for our Origin position once instead of on each keypress.
  71. If (HotkeysEnabled == true)
  72. if (DragToMouse(174, 389) == true)
  73. return
  74.  
  75. Send 1
  76. return
  77.  
  78. 2::
  79. ; We are only going to go further if the hotkeys are turned on.
  80. ; This allows us to check for our Origin position once instead of on each keypress.
  81. If (HotkeysEnabled == true)
  82. if (DragToMouse(265, 389) == true)
  83. return
  84.  
  85. Send 2
  86. return
  87.  
  88. 3::
  89. ; We are only going to go further if the hotkeys are turned on.
  90. ; This allows us to check for our Origin position once instead of on each keypress.
  91. If (HotkeysEnabled == true)
  92. if (DragToMouse(357, 389) == true)
  93. return
  94.  
  95. Send 3
  96. return
  97.  
  98. w::
  99. ; Item slot 1
  100. If (HotkeysEnabled == true)
  101. if (useItem(1) == true)
  102. return
  103.  
  104. Send w
  105. return
  106.  
  107. e::
  108. ; Item slot 2
  109. If (HotkeysEnabled == true)
  110. if (useItem(2) == true)
  111. return
  112.  
  113. Send e
  114. return
  115.  
  116. r::
  117. ; Item slot 3
  118. If (HotkeysEnabled == true)
  119. if (useItem(3) == true)
  120. return
  121.  
  122. Send r
  123. return
  124.  
  125. t::
  126. ; Item slot 4
  127. If (HotkeysEnabled == true)
  128. if (useItem(4) == true)
  129. return
  130.  
  131. Send t
  132. return
  133.  
  134. y::
  135. ; Item slot 5
  136. If (HotkeysEnabled == true)
  137. if (useItem(5) == true)
  138. return
  139.  
  140. Send y
  141. return
  142.  
  143. u::
  144. ; Item slot 6
  145. If (HotkeysEnabled == true)
  146. if (useItem(6) == true)
  147. return
  148.  
  149. Send u
  150. return
  151.  
  152. i::
  153. ; Item slot 7
  154. If (HotkeysEnabled == true)
  155. if (useItem(7) == true)
  156. return
  157.  
  158. Send i
  159. return
  160.  
  161. #IfWinActive
  162.  
  163. ;handles generic item slot use
  164. useItem(slotnum)
  165. {
  166. global
  167. return DragToMouse(Item0X + (ItemWidth * slotnum), ItemsY)
  168. }
  169.  
  170. ; This is our work horse. Instead of writing this code three times, once for each hotkey we
  171. ; call this function with the X/Y coordinates of the player and it handles the rest.
  172. DragToMouse(_PlayerX, _PlayerY)
  173. {
  174. ; This makes it so that all variable names in this function, unless otherwise declared Local are global.
  175. ; I could also use: global OriginX, OriginY
  176. global
  177. local _MouseX, _MouseY
  178.  
  179. ; Here we ask for the mouse position. We only need the x/y values so we leave the other parts out.
  180. MouseGetPos, _MouseX, _MouseY
  181.  
  182. ; Here we check to see if our mouse position is in the window.
  183. ; This lets us click over to chat and talk without it triggering on 1/2/3
  184. ; so long as the mouse is off the game.
  185. if (_MouseX - OriginX < 0 || _MouseX - OriginX > MaxX
  186. || _MouseY - OriginY < 0 || _MouseY - OriginY > MaxY){
  187. TrayTip, Drag Operation Aborted, Mouse outside of game window, 10
  188. return false
  189. }
  190.  
  191. if(DEBUG){
  192. tooltip, Drag from here, _PlayerX + OriginX, _PlayerY + OriginY, 1
  193. tooltip, Drag to here, _MouseX, _MouseY, 2
  194. }
  195. ; Now we ask for the drag movement.
  196. MouseClickDrag, Left, _PlayerX + OriginX, _PlayerY + OriginY, _MouseX, _MouseY, DragSpeed
  197.  
  198. return true
  199. }
  200.  
  201. ClickTheMouse(clickPosX, clickPosY)
  202. {
  203. global
  204. local _MouseX, _MouseY
  205.  
  206. MouseGetPos, _MouseX, _MouseY
  207.  
  208. ; Here we check to see if our mouse position is in the window.
  209. ; This lets us click over to chat and talk without it triggering on 1/2/3
  210. ; so long as the mouse is off the game.
  211. if (_MouseX - OriginX < 0 || _MouseX - OriginX > MaxX
  212. || _MouseY - OriginY < 0 || _MouseY - OriginY > MaxY){
  213. TrayTip, Click Operation Aborted, Mouse outside of game window, 10
  214. return false
  215. }
  216.  
  217. if(DEBUG)
  218. tooltip, Click here, clickPosX, clickPosY, 1
  219. MouseMove, clickPosX, clickPosY, 0
  220. Click
  221. MouseMove, _MouseX, _MouseY, 0
  222. return true
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement