Hotkey problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

Hotkey problem

Post by WilNot » 03 Dec 2022, 10:21

This is a little bit annoying, whenever I write the script like this it says duplicate hotkey even though the keys that you have to press are different:

0 & Space::7
Up & Space::7

#If GetKeyState("0", "P")
Up & Space::R

User avatar
mikeyww
Posts: 26856
Joined: 09 Sep 2014, 18:38

Re: Hotkey problem

Post by mikeyww » 03 Dec 2022, 10:22

I ran your posted script without error. The error is in the part of your script that is not posted. Within any context, each hotkey must be unique.

To find the error:
1. See where the error message indicates, "Error at line ..."
2. Go to that line in your script.

:)

WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

Re: Hotkey problem

Post by WilNot » 03 Dec 2022, 11:10

Sorry Mikey, I forgot to mention that I put the GetKeyState part first which is what produces the error. The thing is that if I try to put it last it simply wouldn't work.

User avatar
mikeyww
Posts: 26856
Joined: 09 Sep 2014, 18:38

Re: Hotkey problem

Post by mikeyww » 03 Dec 2022, 11:21

Looks like we found the solution!

Explained: https://www.autohotkey.com/docs/commands/_If.htm#Basic_Operation
To turn off context sensitivity, specify #If or any #IfWin directive but omit all the parameters.
Next time: instead of posting a working script, post the script that doesn't work (well, OK, at least if you need help)!
Alternative: if you found the script that works, use it!

:)

WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

Re: Hotkey problem

Post by WilNot » 03 Dec 2022, 14:59

Ooh I see what you mean, I appreciate the kindness from you Mikey. I am very confused about this #If thing :eh: , I tried these below but they didn't work:

#If
GetKeyState("0", "P")
Up & Space::7

#If GetKeyState("0", "P")
Up & Space::7
#If

I don't fully understand the explanation from the link, it is a little bit too wordy to be honest.

User avatar
mikeyww
Posts: 26856
Joined: 09 Sep 2014, 18:38

Re: Hotkey problem

Post by mikeyww » 03 Dec 2022, 15:32

Perhaps:

Code: Select all

#If GetKeyState("0", "P")
Up & Space::R
#If
0::0
Up::Up
0 & Space::7
Up & Space::7

Post Reply

Return to “Ask for Help (v1)”