This is a script to automatically farm in a game. I am currently upgrading it to AHK v2 and added that the keys would be sent to that specific window.
Problems:
ahk_id %id%
for id
but that gave me an error that global ahk_id
was not set so i changed it.#Requires AutoHotkey v2.0
SetTitleMatchMode 2
#SingleInstance Force
id := 0
{
MouseGetPos , , &id, &control
return
}
Hotkey "!^w", "sWin"
Hotkey "f24", "rel"
Hotkey "f20", "wgar"
Hotkey "f21", "fsug"
Hotkey "f22", "fpum"
Hotkey "f13", "wda"
Hotkey "f14", "wcas"
Hotkey "f15", "whub"
Hotkey "f23", "fcho"
SelectWindow:
{
MouseGetPos , , &id, &control
return
}
rel:
{
ControlClick , id, , "Left", , "NAU"
ControlClick , id, , "Middle", , "NAU"
ControlSend "{a up}{s up}{d up}{w up}", , id
reload
return
}
fsug:
{
ControlSend "t", , id
sleep 100
ControlSend "{NumpadDiv}warp garden{Enter}1", , id
sleep 100
ControlClick , id, , "Left", , "NAD"
loop 15
{
ControlSend "{a down}", , id
sleep 47750
ControlSend "{a up}{s down}", , id
sleep 47750
ControlSend "{s up}", , id
}
ControlSend "{d down}", , id
sleep 9500
ControlClick , id, , "Left", , "NAU"
ControlSend "{d up}", , id
return
}
wgar:
{
ControlSend "t", , id
sleep 100
ControlSend "{NumpadDiv}warp garden{Enter}1", , id
return
}
fpum:
{
ControlSend "t", , id
sleep 100
ControlSend "{NumpadDiv}warp garden{Enter}1", , id
sleep 100
loop 2
{
ControlClick , id, , "Left", , "NAD"
ControlSend "{w down}", , id
loop 6
{
ControlSend "{a down}", , id
sleep 72500
ControlSend "{a up}{d down}", , id
sleep 72500
ControlSend "{d up}", , id
}
ControlClick , id, , "Left", , "NAU"
ControlSend "{w up}t", , id
sleep 100
ControlSend "{NumpadDiv}warp garden{Enter}1", , id
sleep 100
}
return
}
wda:
{
ControlSend "t", , id
sleep 100
ControlSend "{NumpadDiv}warp da{Enter}", , id
return
}
wcas:
{
ControlSend "t", , id
sleep 100
ControlSend "{NumpadDiv}warp castle{Enter}", , id
return
}
whub:
{
ControlSend "t", , id
sleep 100
ControlSend "{NumpadDiv}warp hub{Enter}", , id
return
}
fcho:
{
loop
{
ControlClick , id, , "Middle", , "NAD"
sleep 3
ControlClick , id, , "Middle", , "NAU"
sleep 3
}
}
I am expecting it to stay active.
things used for id : ahk_id %id% ; %id% ; id
Syntax is incorrect.
Your functions should look like this:
#Requires AutoHotkey v2.0
Hotkey "!1", test
test(k){
MsgBox("Hello")
}
Please read:
Hotkey
function: https://www.autohotkey.com/docs/v2/lib/Hotkey.htm