Advertisement
Solsund

GrinnKeys

Oct 1st, 2012
1,527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. ; This top section is out of a hotkey or function block so it is considered the autoexecute section
  2. ; I use this spot to set up my variables that I want set from the start.
  3.  
  4. ; This line forces the script to look for windows a little more liberally.
  5. SetTitleMatchMode, 2
  6.  
  7. HotkeysEnabled := false
  8. OriginX := -1
  9. OriginY := -1
  10.  
  11. ; These three are the coordinates of the heroes when in combat.
  12. ; They are set here to simplify changing them if the layout ends up slightly off.
  13. Hero1_X := 171
  14. Hero1_Y := 389
  15.  
  16. Hero2_X := 263
  17. Hero2_Y := 388
  18.  
  19. Hero3_X := 353
  20. Hero3_Y := 388
  21.  
  22.  
  23. ; Drag speed is the speed we'll use to drag. It can run from 0 to 100.
  24. ; Change this to change the speed in the rest of the code.
  25. DragSpeed := 0
  26.  
  27. ; This function returns the position of the mouse at the time it is used.
  28. ; This can be useful in case you need to play with the Hero X/Y values
  29. ; if they are off on your computer.
  30. ; I find it works best if you either choose just below the center of the character
  31. ; box, or do your selection on a boss screen where you are zoomed out.
  32. #w::
  33. if (HotkeysEnabled == true)
  34. {
  35. MouseGetPos, FoundX, FoundY
  36. X := FoundX - OriginX
  37. Y := FoundY - OriginY
  38. MsgBox, Mouse is at`nX: %X%, Y:%Y%
  39. } else {
  40. MsgBox, Hotkeys must be turned on to use this key.
  41. }
  42. return
  43.  
  44. ; This is the start of a hotkey block. I chose to use Win+Q for this hotkey but you might have to
  45. ; change it to suit your own keyboard.
  46. ; http://www.autohotkey.com/docs/Hotkeys.htm#Symbols
  47. #q::
  48. If (HotkeysEnabled == true)
  49. {
  50. HotkeysEnabled := false
  51. MsgBox, , GrinnKeys, Hotkeys turned off, 2
  52. } else {
  53. IfWinExist, The Grinns Tale
  54. WinActivate
  55. else
  56. return
  57.  
  58. ErrorMessage := ""
  59. Quality := "High"
  60.  
  61. ; This is the core of the Anchor system. It requires a picture to be found in the
  62. ; same directory as this script is run from. This is a cropped picture of the Pramin
  63. ; on the top bar that is almost always found in the exact same spot. It allows us to
  64. ; determine where in the window the top/left corner of the game is so we can use the
  65. ; right coordinates for the rest of the code.
  66. ImageSearch, FoundX, FoundY, 0, 0, 1300, 700, *25 GTPramin.png
  67.  
  68. if ( ErrorLevel != 0)
  69. {
  70. if (ErrorLevel == 2)
  71. ErrorMessage := "GTPramin.png not found"
  72.  
  73. Quality := "Low"
  74. ImageSearch, FoundX, FoundY, 0, 0, 1300, 700, *25 GTPramin_LQ.png
  75.  
  76. if (ErrorLevel != 0)
  77. {
  78. if (ErrorMessage != "")
  79. ErrorMessage := ErrorMessage . "`n"
  80.  
  81. if (ErrorLevel == 2)
  82. ErrorMessage := ErrorMessage . "GTPramin_LQ.png not found"
  83. else
  84. ErrorMessage := ErrorMessage . "Pramin image not found on screen"
  85.  
  86. MsgBox, , GrinnKeys, %ErrorMessage%
  87. return
  88. }
  89. }
  90. OriginX := FoundX - 163
  91. OriginY := FoundY - 0
  92. HotkeysEnabled := true
  93. MsgBox, , GrinnKeys, %Quality% quality detected.`nHotkeys turned on, 2
  94. }
  95. return
  96.  
  97. ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
  98. #IfWinActive, The Grinns Tale
  99. 1::
  100. ; We are only going to go further if the hotkeys are turned on.
  101. ; This allows us to check for our Origin position once instead of on each keypress.
  102. If (HotkeysEnabled == true)
  103. if (DoDrag(Hero1_X, Hero1_Y) == true)
  104. return
  105.  
  106. Send 1
  107. return
  108.  
  109. 2::
  110. ; We are only going to go further if the hotkeys are turned on.
  111. ; This allows us to check for our Origin position once instead of on each keypress.
  112. If (HotkeysEnabled == true)
  113. if (DoDrag(Hero2_X, Hero2_Y) == true)
  114. return
  115.  
  116. Send 2
  117. return
  118.  
  119. 3::
  120. ; We are only going to go further if the hotkeys are turned on.
  121. ; This allows us to check for our Origin position once instead of on each keypress.
  122. If (HotkeysEnabled == true)
  123. if (DoDrag(Hero3_X, Hero3_Y) == true)
  124. return
  125.  
  126. Send 3
  127. return
  128.  
  129. q::
  130. ; We are only going to go further if the hotkeys are turned on.
  131. ; This allows us to check for our Origin position once instead of on each keypress.
  132. If (HotkeysEnabled == true)
  133. if (DoDrag(Hero1_X, Hero1_Y, true) == true)
  134. return
  135.  
  136. Send q
  137. return
  138.  
  139. w::
  140. ; We are only going to go further if the hotkeys are turned on.
  141. ; This allows us to check for our Origin position once instead of on each keypress.
  142. If (HotkeysEnabled == true)
  143. if (DoDrag(Hero2_X, Hero2_Y, true) == true)
  144. return
  145.  
  146. Send w
  147. return
  148.  
  149. e::
  150. ; We are only going to go further if the hotkeys are turned on.
  151. ; This allows us to check for our Origin position once instead of on each keypress.
  152. If (HotkeysEnabled == true)
  153. if (DoDrag(Hero3_X, Hero3_Y, true) == true)
  154. return
  155.  
  156. Send e
  157. return
  158.  
  159. #IfWinActive
  160.  
  161. ; This is our work horse. Instead of writing this code three times, once for each hotkey we
  162. ; call this function with the X/Y coordinates of the player and it handles the rest.
  163. ; mouseToCharacter allows us to use this same function to drag both from a character to the mouse (attacks)
  164. ; and from the mouse to the character (item use)
  165. DoDrag(_PlayerX, _PlayerY, mouseToCharacter = false)
  166. {
  167. ; This makes it so that all variable names in this function, unless otherwise declared Local are global.
  168. ; I could also use: global OriginX, OriginY
  169. global
  170. local _MouseX, _MouseY
  171.  
  172. ; Here we ask for the mouse position. We only need the x/y values so we leave the other parts out.
  173. MouseGetPos, _MouseX, _MouseY
  174.  
  175. ; Here we check to see if our mouse position is in the window.
  176. ; This lets us click over to chat and talk without it triggering on 1/2/3
  177. ; so long as the mouse is off the game.
  178. if (_MouseX - OriginX < 0 || _MouseX - OriginX > 1000
  179. || _MouseY - OriginY < 0 || _MouseY - OriginY > 600)
  180. return false
  181.  
  182. ; Now we choose which type of drag to do use.
  183. if (mouseToCharacter == true)
  184. {
  185. ; We click from the mouse to the character.
  186. MouseClickDrag, Left, _MouseX, _MouseY, _PlayerX + OriginX, _PlayerY + OriginY, DragSpeed
  187. ; We then need to set the mouse back to it's original spot.
  188. MouseMove, _MouseX, _MouseY, 0
  189. } else
  190. ; We drag from the character to the mouse location.
  191. MouseClickDrag, Left, _PlayerX + OriginX, _PlayerY + OriginY, _MouseX, _MouseY, DragSpeed
  192.  
  193. return true
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement