Skip to content

Instantly share code, notes, and snippets.

@danielpza
Last active May 23, 2023 20:55
Show Gist options
  • Save danielpza/f05919e62bb4cf431dd92d524fca37a2 to your computer and use it in GitHub Desktop.
Save danielpza/f05919e62bb4cf431dd92d524fca37a2 to your computer and use it in GitHub Desktop.
V Rising Game ahk v2
#HotIf WinActive("ahk_exe VRising.exe")
sleeptime := 50
SetMouseDelay sleeptime
SetKeyDelay -1, sleeptime
SetDefaultMouseSpeed 0
F9::Reload()
#SuspendExempt
F12::Suspend()
#SuspendExempt false
chest1 := {
take: { x: 1244, y: 289, color: "0xD4D4D4" },
sort: { x: 1562, y: 290, color: "0xD8D8D8" },
}
chest2 := {
take: { x: 1245, y: 220, color: "0xCDCDCD" },
sort: { x: 1435, y: 362, color: "0xD4D4D4" },
}
chest3 := {
take: { x: 1244, y: 356, color: "0xD4D4D4" },
sort: { x: 1562, y: 360, color: "0xD8D8D8" },
}
inventory := {
sort: { x: 377, y: 965, color: "0xC7C6C6" },
ccount: { x: 733, y: 964, color: "0xD9D9D9" },
}
claimbutton := { x: 695, y: 76, color: "0xD4D4D4" }
;; tidy up: sorts inventory, compulsory count, clicks claim button, etc
v::{
SaveMouse()
PClick(claimbutton)
PClick(inventory.ccount)
PClick(inventory.sort)
PClick(chest1.sort)
PClick(chest2.sort)
PClick(chest3.sort)
RestoreMouse()
}
;; take all: clicks take all button, transfers from workstations to inventory
g::{
SaveMouse()
PClick(chest1.take)
PClick(chest2.take)
PClick(chest3.take)
TakeAllStation()
RestoreMouse()
}
TakeAllStation() {
if (not CheckPixel(1462, 789, "0x000000")) {
return
}
RClickUnlessColor(1679, 858, "0x000000")
RClickUnlessColor(1613, 858, "0x000000")
RClickUnlessColor(1536, 858, "0x000000")
RClickUnlessColor(1466, 858, "0x000000")
}
RClickUnlessColor(x, y, color) {
if (not CheckPixel(x, y, color)) {
SendEvent(format("{click {1} {2} {3}}", x, y, "Right"))
}
}
SaveMouse() {
global lastx, lasty
MouseGetPos &lastx, &lasty
}
RestoreMouse() {
global lastx, lasty
MouseMove(lastx, lasty)
}
PClick(p, button := "Left") {
if (not p.HasOwnProp("color") or CheckPixel(p.x, p.y, p.color)) {
SendEvent(format("{click {1} {2} {3}}", p.x, p.y, button))
}
}
ColorDiff(color1, color2){
; https://www.autohotkey.com/boards/viewtopic.php?t=65491
tr := format("{:d}","0x" . substr(color1,3,2))
tg := format("{:d}","0x" . substr(color1,5,2))
tb := format("{:d}","0x" . substr(color1,7,2))
; split pixel into rgb
pr := format("{:d}","0x" . substr(color2,3,2))
pg := format("{:d}","0x" . substr(color2,5,2))
pb := format("{:d}","0x" . substr(color2,7,2))
return Abs(tr - pr) + Abs(tg - pg) + Abs(tb - pb)
}
CheckPixel(x, y, ccolor) {
return ColorDiff(PixelGetColor(x, y), ccolor) < 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment