Advertisement
Guest User

GrinnKeys.ahk

a guest
Oct 20th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  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. #q::
  5. If (HotkeysEnabled == true)
  6. {
  7. HotkeysEnabled := false
  8. HasCroissant := false
  9. MsgBox, , GrinnKeys, Hotkeys turned off, 2
  10. } else {
  11. IfWinExist, Play The Grinns Tale
  12. WinActivate
  13. else
  14. return
  15.  
  16. ; This is the core of the Anchor system. It requires a picture to be found in the
  17. ; same directory as this script is run from. This is a cropped picture of the Pramin
  18. ; on the top bar that is almost always found in the exact same spot. It allows us to
  19. ; determine where in the window the top/left corner of the game is so we can use the
  20. ; right coordinates for the rest of the code.
  21. ImageSearch, _FoundX, _FoundY, 0, 0, 1300, 700, *25 GTPramin.png
  22.  
  23. if (ErrorLevel == 1)
  24. {
  25. MsgBox, , GrinnKeys, Pramin image not found on screen.
  26. return
  27. } else if (ErrorLevel == 2)
  28. {
  29. MsgBox, , GrinnKeys, GTPramin.png was not found in the script directory
  30. return
  31. }
  32.  
  33. OriginX := _FoundX - 155
  34. OriginY := _FoundY - 0
  35.  
  36. MsgBox, , GrinnKeys, Please be patient while I look for your croissants, 1
  37.  
  38. ImageSearch, _FoundX, _FoundY, 0, 0, 1300, 900, *25 *TransBlack GTCroissant.png
  39.  
  40. if (ErrorLevel == 1)
  41. {
  42. MsgBox, , GrinnKeys, Croissant image not found on screen.
  43. HasCroissant := false
  44. } else if (ErrorLevel == 2)
  45. {
  46. MsgBox, , GrinnKeys, GTCroissant.png was not found in the script directory
  47. HasCroissant := false
  48. } else if (ErrorLevel == 0)
  49. {
  50. HasCroissant := true
  51. CroissantX := _FoundX + 15 - OriginX
  52. CroissantY := _FoundY + 15 - OriginY
  53. }
  54.  
  55. HotkeysEnabled := true
  56. if (HasCroissant)
  57. {
  58. MsgBox, , GrinnKeys, Hotkeys turned on `n` Croissant was found. Hotkey 4 is active, 2
  59. } else {
  60. MsgBox, , GrinnKeys, Hotkeys turned on `n` Croissant was not found. Hotkey 4 is inactive, 2
  61. }
  62. }
  63. return
  64.  
  65. ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
  66. #IfWinActive, Play The Grinns Tale
  67. 1::
  68. ; We are only going to go further if the hotkeys are turned on.
  69. ; This allows us to check for our Origin position once instead of on each keypress.
  70. If (HotkeysEnabled == true)
  71. if (DragToMouse(174, 389) == true)
  72. return
  73.  
  74. Send 1
  75. return
  76.  
  77. 2::
  78. ; We are only going to go further if the hotkeys are turned on.
  79. ; This allows us to check for our Origin position once instead of on each keypress.
  80. If (HotkeysEnabled == true)
  81. if (DragToMouse(265, 389) == true)
  82. return
  83.  
  84. Send 2
  85. return
  86.  
  87. 3::
  88. ; We are only going to go further if the hotkeys are turned on.
  89. ; This allows us to check for our Origin position once instead of on each keypress.
  90. If (HotkeysEnabled == true)
  91. if (DragToMouse(357, 389) == true)
  92. return
  93.  
  94. Send 3
  95. return
  96.  
  97. 4::
  98. ; We are only going to go further if the hotkeys are turned on.
  99. ; This allows us to check for our Origin position once instead of on each keypress.
  100. If (HotkeysEnabled == true)
  101. ; This is only a viable option if the croissant was found
  102. If (HasCroissant)
  103. {
  104. if (DragToMouse(CroissantX, CroissantY) == true)
  105. return
  106. }
  107.  
  108. Send 4
  109. return
  110.  
  111. #IfWinActive
  112.  
  113. ; This is our work horse. Instead of writing this code three times, once for each hotkey we
  114. ; call this function with the X/Y coordinates of the player and it handles the rest.
  115. DragToMouse(_PlayerX, _PlayerY)
  116. {
  117. ; This makes it so that all variable names in this function, unless otherwise declared Local are global.
  118. ; I could also use: global OriginX, OriginY
  119. global
  120. local _MouseX, _MouseY
  121.  
  122. ; Here we ask for the mouse position. We only need the x/y values so we leave the other parts out.
  123. MouseGetPos, _MouseX, _MouseY
  124.  
  125. ; Here we check to see if our mouse position is in the window.
  126. ; This lets us click over to chat and talk without it triggering on 1/2/3
  127. ; so long as the mouse is off the game.
  128. if (_MouseX - OriginX < 0 || _MouseX - OriginX > 1000
  129. || _MouseY - OriginY < 0 || _MouseY - OriginY > 600)
  130. return false
  131.  
  132. ; Now we ask for the drag movement.
  133. MouseClickDrag, Left, _PlayerX + OriginX, _PlayerY + OriginY, _MouseX, _MouseY, DragSpeed
  134.  
  135. return true
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement