need help with a toggleable script to farm Topic is solved

Ask gaming related questions
Zekken
Posts: 2
Joined: 11 Apr 2024, 07:11

need help with a toggleable script to farm

11 Apr 2024, 07:27

Im trying setup a script using AHK v2 to automatically harvest resources in the game . I dont exactly understand the syntax with autohotkey so im struggling to make the script . It work something like this

Press [x] key to toggle the script on and off
Press [p] key to switch between state one and state two

state one : holds left click and d at the same time
state two : holds left click and s at the same time

also to clarify i dont meant to completely stop the script but something more akin to this

Code: Select all

toggle := true
return

f1::toggle := !toggle   ;inverts toggle 0>1>0>1 etc.

#If toggle ;if toggle = true/1 then hotkeys work, otherwise disabled
z::a  ;this does not need a return since its single line
x::d
User avatar
boiler
Posts: 17123
Joined: 21 Dec 2014, 02:44

Re: need help with a toggleable script to farm

11 Apr 2024, 08:06

Make sure you're looking at the v2 documentation. It's #HotIf in v2, not #If like in v1. And your F1 function needs to declare toggle as global since it is assigning a value to it. It can't assume it's global.

Code: Select all

#Requires AutoHotkey v2.0

toggle := true

f1::global toggle := !toggle   ;inverts toggle 0>1>0>1 etc.

#HotIf toggle ;if toggle = true/1 then hotkeys work, otherwise disabled
z::a  ;this does not need a return since its single line
x::d
Zekken
Posts: 2
Joined: 11 Apr 2024, 07:11

Re: need help with a toggleable script to farm

11 Apr 2024, 08:08

Im well aware that the code is v1 i just found it as an example
User avatar
boiler
Posts: 17123
Joined: 21 Dec 2014, 02:44

Re: need help with a toggleable script to farm  Topic is solved

11 Apr 2024, 08:12

No matter how well aware you are of what that code is, what I said about looking at the v2 documentation is still good direction. That should be your first stop.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests