Combination of keys and mouse click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
megaboy1
Posts: 2
Joined: 15 Dec 2017, 16:28

Combination of keys and mouse click

15 Dec 2017, 19:08

Hello everyone,

I'm trying to have space bar to be entered only when mouse is clicked while Ctrl + r is pressed.
Here is my code, but whenever I have ^ in the GetKeyState, it doesn't seem to work.
Anybody knows a solution?


Lbutton::

if (GetKeyState("^r")) {
Send {Space}
return
}

else {
Send {Lbutton}
return
}
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Combination of keys and mouse click

15 Dec 2017, 19:34

Try calling GetKeyState for both Ctrl and R.

Code: Select all

If (GetKeyState("Ctrl") and GetKeyState("r")) {
megaboy1
Posts: 2
Joined: 15 Dec 2017, 16:28

Re: Combination of keys and mouse click

16 Dec 2017, 00:40

Thanks Osprey, but it didn't work. I'm thinking maybe I shouldn't use GetKeyState and use something else for this?
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Combination of keys and mouse click

16 Dec 2017, 01:11

This works:

Code: Select all

#If GetKeyState("r")
^LButton::Send {Space}
It simply requires thinking of it slightly differently: as pressing Ctrl+LButton while 'r' is held down. If you add more hotkeys after that, though, make sure that you add #If on a line by itself to disable the 'r' key condition.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mannaia666, ntepa and 227 guests