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
- ;These values are coordinate offsets from the Origin for the item bar hotkeys; the values do not change.
- Item0X := 250
- ItemsY := 523
- ItemWidth := 53
- ; 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
- ImageSearch, _FoundX, _FoundY, 0, 500, 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
- q::
- ; Item slot 1
- If (HotkeysEnabled == true)
- if (useItem(1) == true)
- return
- Send q
- return
- w::
- ; Item slot 2
- If (HotkeysEnabled == true)
- if (useItem(2) == true)
- return
- Send w
- return
- e::
- ; Item slot 3
- If (HotkeysEnabled == true)
- if (useItem(3) == true)
- return
- Send e
- return
- r::
- ; Item slot 4
- If (HotkeysEnabled == true)
- if (useItem(4) == true)
- return
- Send r
- return
- t::
- ; Item slot 5
- If (HotkeysEnabled == true)
- if (useItem(5) == true)
- return
- Send t
- return
- y::
- ; Item slot 6
- If (HotkeysEnabled == true)
- if (useItem(6) == true)
- return
- Send y
- return
- u::
- ; Item slot 7
- If (HotkeysEnabled == true)
- if (useItem(7) == true)
- return
- Send u
- return
- a::
- ; shift item list left
- If (HotkeysEnabled == true)
- if (ClickTheMouse(Item0X + OriginX, ItemsY + OriginY) == true)
- return
- Send a
- return
- s::
- ; shift item list right
- ; Please ignore the magic numbers here ;.;
- ; The X coord is composed of the itembar start, the origin, and JUST LESS than 8 item widths.
- ; Why? Because it worked :P And I can't be bothered to get image sizes precise enough to not need
- ; the magic number.
- If (HotkeysEnabled == true)
- if (ClickTheMouse(Item0X - 3 + OriginX + (ItemWidth * 8), ItemsY + OriginY) == true)
- return
- Send s
- return
- #IfWinActive
- ;handles generic item slot use
- useItem(slotnum)
- {
- global
- return DragToMouse(Item0X + (ItemWidth * slotnum), ItemsY)
- }
- ; 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
- }
- ClickTheMouse(clickPosX, clickPosY)
- {
- global
- local _MouseX, _MouseY
- 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
- MouseMove, clickPosX, clickPosY, 0
- Click
- MouseMove, _MouseX, _MouseY, 0
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement