Advertisement
Guest User

gkeys

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