Hi everyone,
I made a script to generate a random number from 1 to 4 and if the number were to be 1 the cursor would click in location A, if the number were to be 2 the cursor would click in location B etc.
I made this script in V1 and it worked perfectly fine
(1.ahk)
but then I tried to translate it to V2 and I kept on getting an error "call to nonexistend function" (2.ahk)
I annot figure out what I did wrong, could someone please assist me?
Thanks in advance,
FraudeerBeer
Why does my script not work?
Re: Why does my script not work?
Your main problem is that you are not running the script using v2. That error is an v1 error, and you would have gotten an error on an earlier line because your hotkey function is not enclosed in braces { } as is required in v2.
It would be better if you posted your code in the body of the post in between [code][/code] tags so members can immediately view your code without having to download it.
It would be better if you posted your code in the body of the post in between [code][/code] tags so members can immediately view your code without having to download it.
-
- Posts: 4
- Joined: 22 Jan 2023, 15:45
Re: Why does my script not work?
Hi @boiler,
I am not very experienced with V2 yet. Could you explain more carefully where I have to put the brackets {}?
Thanks,
-FraudeerBeer.
I am not very experienced with V2 yet. Could you explain more carefully where I have to put the brackets {}?
Thanks,
-FraudeerBeer.
Re: Why does my script not work?
It’s about the first thing shown on the documentation page for hotkeys. Looking at the documentation should always be your first step.
Re: Why does my script not work?
Also: there are situations where using #Requires helps.
Explained: Launcher
Or:
Code: Select all
#Requires AutoHotkey v2.0
^k:: {
Loop 10
Switch Random(1, 4) {
Case 1: Send 1
Case 2: Send 2
Case 3: Send 3
Case 4: Send 4
}
}
Or:
Code: Select all
#Requires AutoHotkey v2.0
coord := [[500, 250], [1200, 300], [1700, 950], [180, 900]]
^k:: {
Loop 2 {
c := coord[Random(1, 4)]
Click c[1], c[2]
}
}