Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; This top section is out of a hotkey or function block so it is considered the autoexecute section
- ; I use this spot to set up my variables that I want set from the start.
- ; This line forces the script to look for windows a little more liberally.
- SetTitleMatchMode, 2
- HotkeysEnabled := false
- Tooltip_X := A_Screenwidth / 2
- Tooltip_Y := A_Screenheight / 2
- TooltipTime := 5000
- ; These three are the coordinates of the heroes when in combat.
- ; They are set here to simplify changing them if the layout ends up slightly off.
- Hero1_X := 244
- Hero1_Y := 655
- Hero2_X := 373
- Hero2_Y := 655
- Hero3_X := 496
- Hero3_Y := 655
- ; Drag speed is the speed we'll use to drag. It can run from 0 to 100.
- ; Change this to change the speed in the rest of the code.
- DragSpeed := 0
- ; This function returns the position of the mouse at the time it is used.
- ; This can be useful in case you need to play with the Hero X/Y values
- ; if they are off on your computer.
- ; I find it works best if you either choose just below the center of the character
- ; box, or do your selection on a boss screen where you are zoomed out.
- ; This will pop you out of Full Screen on purpose.
- #w::
- MouseGetPos, FoundX, FoundY
- MsgBox, Mouse is at`nX: %FoundX%, Y:%FoundY%
- return
- ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
- #IfWinActive, Adobe Flash Player
- ; This is the start of a hotkey block. I chose to use Win+Q for this hotkey but you might have to
- ; change it to suit your own keyboard.
- ; http://www.autohotkey.com/docs/Hotkeys.htm#Symbols
- #q::
- If (HotkeysEnabled == true)
- {
- HotkeysEnabled := false
- Tooltip, Hotkeys turned off, Tooltip_X, Tooltip_Y
- } else {
- ErrorMessage := ""
- Quality := "High"
- ; In Full screen we do not need an Anchor as the Origin point will always be 0,0
- ; We still look for it in order to be sure we are in Grinn's Tale and not another
- ; fullscreen Flash App
- ; As we are in full screen we can also cheat and only search the top section of the
- ; screen as we will never find the Pramin image lower than that.
- ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, 100, *25 GTPramin.png
- if ( ErrorLevel != 0)
- {
- if (ErrorLevel == 2)
- ErrorMessage := "GTPramin.png not found"
- Quality := "Low"
- ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, 100, *25 GTPramin_LQ.png
- if (ErrorLevel != 0)
- {
- if (ErrorMessage != "")
- ErrorMessage := ErrorMessage . "`n"
- if (ErrorLevel == 2)
- ErrorMessage := ErrorMessage . "GTPramin_LQ.png not found"
- else
- ErrorMessage := ErrorMessage . "Pramin image not found on screen"
- ToolTip, %ErrorMessage%, Tooltip_X, Tooltip_Y
- Sleep TooltipTime
- ToolTip
- return
- }
- }
- HotkeysEnabled := true
- Tooltip, %Quality% quality detected.`nHotkeys turned on, Tooltip_X, Tooltip_Y
- }
- Sleep TooltipTime
- Tooltip
- return
- 1::
- If (HotkeysEnabled == true)
- DoDrag(Hero1_X, Hero1_Y)
- return
- 2::
- If (HotkeysEnabled == true)
- DoDrag(Hero2_X, Hero2_Y)
- return
- 3::
- If (HotkeysEnabled == true)
- DoDrag(Hero3_X, Hero3_Y)
- return
- q::
- If (HotkeysEnabled == true)
- DoDrag(Hero1_X, Hero1_Y, true)
- return
- w::
- If (HotkeysEnabled == true)
- DoDrag(Hero2_X, Hero2_Y, true)
- return
- e::
- If (HotkeysEnabled == true)
- DoDrag(Hero3_X, Hero3_Y, true)
- return
- #IfWinActive
- ; This is our work horse. Instead of writing this code three times, once for each hotkey we
- ; call this function with the X/Y coordinates of the player and it handles the rest.
- ; mouseToCharacter allows us to use this same function to drag both from a character to the mouse (attacks)
- ; and from the mouse to the character (item use)
- DoDrag(_PlayerX, _PlayerY, mouseToCharacter = false)
- {
- ; This makes it so that all variable names in this function, unless otherwise declared Local are global.
- ; I could also use: global OriginX, OriginY
- global
- local _MouseX, _MouseY
- ; Here we ask for the mouse position. We only need the x/y values so we leave the other parts out.
- MouseGetPos, _MouseX, _MouseY
- ; Now we choose which type of drag to do use.
- if (mouseToCharacter == true)
- {
- ; We click from the mouse to the character.
- MouseClickDrag, Left, _MouseX, _MouseY, _PlayerX, _PlayerY, DragSpeed
- ; We then need to set the mouse back to it's original spot.
- MouseMove, _MouseX, _MouseY, 0
- } else
- ; We drag from the character to the mouse location.
- MouseClickDrag, Left, _PlayerX, _PlayerY, _MouseX, _MouseY, DragSpeed
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement