Skip to content

Instantly share code, notes, and snippets.

@noih
Created November 10, 2022 15:19
Show Gist options
  • Save noih/84e9306873d87d111271abac08407cdf to your computer and use it in GitHub Desktop.
Save noih/84e9306873d87d111271abac08407cdf to your computer and use it in GitHub Desktop.
global foodHotKey := "1" ; 1 ~ 5, eat food or skill
#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
^r::Reload
Delete::ExitApp
!6::
Loop, {
if (IsHungry()) {
UseBelt(foodHotKey, 300)
}
Sleep, 5000
}
return
IsHungry() {
p := GetRelativeCenterBottom({ x: 76, y: 533 })
PixelGetColor, color, p.x, p.y
return color != 0x00C7EF
}
UseBelt(index, postMS) {
if (RegExMatch(index, "^[1-5]$")) {
Send, {Alt Down}
Send, {%index% Down}
Sleep, 80
Send, {%index% Up}
Send, {Alt Up}
Sleep, postMS
}
}
GetRelativeCenterBottom(position, width = 800, height = 600) {
return { x: Floor((A_ScreenWidth / 2) - (width / 2) + position.x), y: A_ScreenHeight - height + position.y }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment