Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; 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
- HasCroissant := false
- MsgBox, , GrinnKeys, Hotkeys turned off, 2
- } else {
- IfWinExist, Play The Grinns Tale
- WinActivate
- else
- return
- ; 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 == 1)
- {
- MsgBox, , GrinnKeys, Pramin image not found on screen.
- return
- } else if (ErrorLevel == 2)
- {
- MsgBox, , GrinnKeys, GTPramin.png was not found in the script directory
- return
- }
- OriginX := _FoundX - 155
- OriginY := _FoundY - 0
- MsgBox, , GrinnKeys, Please be patient while I look for your croissants, 1
- ImageSearch, _FoundX, _FoundY, 0, 0, 1300, 900, *25 *TransBlack GTCroissant.png
- if (ErrorLevel == 1)
- {
- MsgBox, , GrinnKeys, Croissant image not found on screen.
- HasCroissant := false
- } else if (ErrorLevel == 2)
- {
- MsgBox, , GrinnKeys, GTCroissant.png was not found in the script directory
- HasCroissant := false
- } else if (ErrorLevel == 0)
- {
- HasCroissant := true
- CroissantX := _FoundX + 15 - OriginX
- CroissantY := _FoundY + 15 - OriginY
- }
- HotkeysEnabled := true
- if (HasCroissant)
- {
- MsgBox, , GrinnKeys, Hotkeys turned on `n` Croissant was found. Hotkey 4 is active, 2
- } else {
- MsgBox, , GrinnKeys, Hotkeys turned on `n` Croissant was not found. Hotkey 4 is inactive, 2
- }
- }
- return
- ; This line will make these hotkeys only work if our Grinns Tale game is the active window.
- #IfWinActive, Play 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 (DragToMouse(174, 389) == 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 (DragToMouse(265, 389) == 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 (DragToMouse(357, 389) == true)
- return
- Send 3
- return
- 4::
- ; 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)
- ; This is only a viable option if the croissant was found
- If (HasCroissant)
- {
- if (DragToMouse(CroissantX, CroissantY) == true)
- return
- }
- Send 4
- 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.
- DragToMouse(_PlayerX, _PlayerY)
- {
- ; 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 ask for the drag movement.
- MouseClickDrag, Left, _PlayerX + OriginX, _PlayerY + OriginY, _MouseX, _MouseY, DragSpeed
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement