Advertisement
Solsund

GrinnKeysFS

Nov 5th, 2012
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 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. Tooltip_X := A_Screenwidth / 2
  9. Tooltip_Y := A_Screenheight / 2
  10. TooltipTime := 5000
  11.  
  12. ; These three are the coordinates of the heroes when in combat.
  13. ; They are set here to simplify changing them if the layout ends up slightly off.
  14. Hero1_X := 244
  15. Hero1_Y := 655
  16.  
  17. Hero2_X := 373
  18. Hero2_Y := 655
  19.  
  20. Hero3_X := 496
  21. Hero3_Y := 655
  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. ; This will pop you out of Full Screen on purpose.
  33. #w::
  34. MouseGetPos, FoundX, FoundY
  35. MsgBox, Mouse is at`nX: %FoundX%, Y:%FoundY%
  36. return
  37.  
  38. ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
  39. #IfWinActive, Adobe Flash Player
  40.  
  41. ; This is the start of a hotkey block. I chose to use Win+Q for this hotkey but you might have to
  42. ; change it to suit your own keyboard.
  43. ; http://www.autohotkey.com/docs/Hotkeys.htm#Symbols
  44. #q::
  45. If (HotkeysEnabled == true)
  46. {
  47. HotkeysEnabled := false
  48. Tooltip, Hotkeys turned off, Tooltip_X, Tooltip_Y
  49. } else {
  50. ErrorMessage := ""
  51. Quality := "High"
  52.  
  53. ; In Full screen we do not need an Anchor as the Origin point will always be 0,0
  54. ; We still look for it in order to be sure we are in Grinn's Tale and not another
  55. ; fullscreen Flash App
  56. ; As we are in full screen we can also cheat and only search the top section of the
  57. ; screen as we will never find the Pramin image lower than that.
  58. ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, 100, *25 GTPramin.png
  59.  
  60. if ( ErrorLevel != 0)
  61. {
  62. if (ErrorLevel == 2)
  63. ErrorMessage := "GTPramin.png not found"
  64.  
  65. Quality := "Low"
  66. ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, 100, *25 GTPramin_LQ.png
  67.  
  68. if (ErrorLevel != 0)
  69. {
  70. if (ErrorMessage != "")
  71. ErrorMessage := ErrorMessage . "`n"
  72.  
  73. if (ErrorLevel == 2)
  74. ErrorMessage := ErrorMessage . "GTPramin_LQ.png not found"
  75. else
  76. ErrorMessage := ErrorMessage . "Pramin image not found on screen"
  77.  
  78. ToolTip, %ErrorMessage%, Tooltip_X, Tooltip_Y
  79. Sleep TooltipTime
  80. ToolTip
  81. return
  82. }
  83.  
  84. }
  85. HotkeysEnabled := true
  86. Tooltip, %Quality% quality detected.`nHotkeys turned on, Tooltip_X, Tooltip_Y
  87. }
  88. Sleep TooltipTime
  89. Tooltip
  90. return
  91.  
  92. 1::
  93. If (HotkeysEnabled == true)
  94. DoDrag(Hero1_X, Hero1_Y)
  95. return
  96.  
  97. 2::
  98. If (HotkeysEnabled == true)
  99. DoDrag(Hero2_X, Hero2_Y)
  100. return
  101.  
  102. 3::
  103. If (HotkeysEnabled == true)
  104. DoDrag(Hero3_X, Hero3_Y)
  105. return
  106.  
  107. q::
  108. If (HotkeysEnabled == true)
  109. DoDrag(Hero1_X, Hero1_Y, true)
  110. return
  111.  
  112. w::
  113. If (HotkeysEnabled == true)
  114. DoDrag(Hero2_X, Hero2_Y, true)
  115. return
  116.  
  117. e::
  118. If (HotkeysEnabled == true)
  119. DoDrag(Hero3_X, Hero3_Y, true)
  120. return
  121.  
  122.  
  123. #IfWinActive
  124.  
  125. ; This is our work horse. Instead of writing this code three times, once for each hotkey we
  126. ; call this function with the X/Y coordinates of the player and it handles the rest.
  127. ; mouseToCharacter allows us to use this same function to drag both from a character to the mouse (attacks)
  128. ; and from the mouse to the character (item use)
  129. DoDrag(_PlayerX, _PlayerY, mouseToCharacter = false)
  130. {
  131. ; This makes it so that all variable names in this function, unless otherwise declared Local are global.
  132. ; I could also use: global OriginX, OriginY
  133. global
  134. local _MouseX, _MouseY
  135.  
  136. ; Here we ask for the mouse position. We only need the x/y values so we leave the other parts out.
  137. MouseGetPos, _MouseX, _MouseY
  138.  
  139. ; Now we choose which type of drag to do use.
  140. if (mouseToCharacter == true)
  141. {
  142. ; We click from the mouse to the character.
  143. MouseClickDrag, Left, _MouseX, _MouseY, _PlayerX, _PlayerY, DragSpeed
  144. ; We then need to set the mouse back to it's original spot.
  145. MouseMove, _MouseX, _MouseY, 0
  146. } else
  147. ; We drag from the character to the mouse location.
  148. MouseClickDrag, Left, _PlayerX, _PlayerY, _MouseX, _MouseY, DragSpeed
  149.  
  150. return true
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement