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
- OriginX := -1
- OriginY := -1
- ; 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 := 171
- Hero1_Y := 389
- Hero2_X := 263
- Hero2_Y := 388
- Hero3_X := 353
- Hero3_Y := 388
- ; 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.
- #w::
- if (HotkeysEnabled == true)
- {
- MouseGetPos, FoundX, FoundY
- X := FoundX - OriginX
- Y := FoundY - OriginY
- MsgBox, Mouse is at`nX: %X%, Y:%Y%
- } else {
- MsgBox, Hotkeys must be turned on to use this key.
- }
- return
- ; 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
- MsgBox, , GrinnKeys, Hotkeys turned off, 2
- } else {
- IfWinExist, The Grinns Tale
- WinActivate
- else
- return
- ErrorMessage := ""
- Quality := "High"
- ; This is the core of the Anchor system. It requires a picture to be found in the
- ; same directory as this script is run from. This is a cropped picture of the Pramin
- ; on the top bar that is almost always found in the exact same spot. It allows us to
- ; determine where in the window the top/left corner of the game is so we can use the
- ; right coordinates for the rest of the code.
- ImageSearch, FoundX, FoundY, 0, 0, 1300, 700, *25 GTPramin.png
- if ( ErrorLevel != 0)
- {
- if (ErrorLevel == 2)
- ErrorMessage := "GTPramin.png not found"
- Quality := "Low"
- ImageSearch, FoundX, FoundY, 0, 0, 1300, 700, *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"
- MsgBox, , GrinnKeys, %ErrorMessage%
- return
- }
- }
- OriginX := FoundX - 163
- OriginY := FoundY - 0
- HotkeysEnabled := true
- MsgBox, , GrinnKeys, %Quality% quality detected.`nHotkeys turned on, 2
- }
- return
- ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
- #IfWinActive, The Grinns Tale
- 1::
- ; We are only going to go further if the hotkeys are turned on.
- ; This allows us to check for our Origin position once instead of on each keypress.
- If (HotkeysEnabled == true)
- if (DoDrag(Hero1_X, Hero1_Y) == true)
- return
- Send 1
- return
- 2::
- ; We are only going to go further if the hotkeys are turned on.
- ; This allows us to check for our Origin position once instead of on each keypress.
- If (HotkeysEnabled == true)
- if (DoDrag(Hero2_X, Hero2_Y) == true)
- return
- Send 2
- return
- 3::
- ; We are only going to go further if the hotkeys are turned on.
- ; This allows us to check for our Origin position once instead of on each keypress.
- If (HotkeysEnabled == true)
- if (DoDrag(Hero3_X, Hero3_Y) == true)
- return
- Send 3
- return
- q::
- ; We are only going to go further if the hotkeys are turned on.
- ; This allows us to check for our Origin position once instead of on each keypress.
- If (HotkeysEnabled == true)
- if (DoDrag(Hero1_X, Hero1_Y, true) == true)
- return
- Send q
- return
- w::
- ; We are only going to go further if the hotkeys are turned on.
- ; This allows us to check for our Origin position once instead of on each keypress.
- If (HotkeysEnabled == true)
- if (DoDrag(Hero2_X, Hero2_Y, true) == true)
- return
- Send w
- return
- e::
- ; We are only going to go further if the hotkeys are turned on.
- ; This allows us to check for our Origin position once instead of on each keypress.
- If (HotkeysEnabled == true)
- if (DoDrag(Hero3_X, Hero3_Y, true) == true)
- return
- Send e
- 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
- ; Here we check to see if our mouse position is in the window.
- ; This lets us click over to chat and talk without it triggering on 1/2/3
- ; so long as the mouse is off the game.
- if (_MouseX - OriginX < 0 || _MouseX - OriginX > 1000
- || _MouseY - OriginY < 0 || _MouseY - OriginY > 600)
- return false
- ; 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 + OriginX, _PlayerY + OriginY, 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 + OriginX, _PlayerY + OriginY, _MouseX, _MouseY, DragSpeed
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement