Simple hotkey combo prevents key usage

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Quisquose
Posts: 74
Joined: 24 Jun 2016, 04:16

Simple hotkey combo prevents key usage

26 Jun 2017, 17:03

I'm trying to make a simple hotkey where 2 keys are pressed simultaneously (neither of which is a modifer key) to launch an action. Lets say, for example, the letters "o" and "p".

If I use the code o & p:: then it only works if the "o" key is pressed first. But if you're pressing the 2 keys simultaneously, then you won't know whether the "o" will register first or not (which means that the action doesn't always work).

The solution that I have seen offered, is to simply add another hotkey with the keys reversed.

Code: Select all

o & p::
p & o::

{
run somestuff.exe
return
}
That works great as far as dealing with the simultaneous key press issue goes, but now you can now no longer type the key "o" or "p" individually anywhere any more.

How can I use a hotkey of two simultaneous regular letters, while still allowing those same letters to be used individually as normal?

Thanks
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Simple hotkey combo prevents key usage

26 Jun 2017, 23:26

Hallo,
try:

Code: Select all

~o & p::
~p & o::
run somestuff.exe
return
But the first pressed key will be always written!
Quisquose
Posts: 74
Joined: 24 Jun 2016, 04:16

Re: Simple hotkey combo prevents key usage

27 Jun 2017, 17:56

I appreciate your reply.

This solution is not perfect because it still triggers the action if one key is pressed soon after the other, but it is much better than having keys that do not work at all!

At least this allows me to type normally using those keys one at a time. Thank you.
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Simple hotkey combo prevents key usage

27 Jun 2017, 23:44

Hallo,
also not perfect, but try this:

Code: Select all

#MaxThreadsPerHotkey, 255
~o & p::
~p & o::
opKey := False
run somestuff.exe
return
o::
opKey := True
Sleep, 300 ;Wait for other hotkeys
If opKey
	Send, o
Return
p::
opKey := True
Sleep, 300 ;Wait for other hotkeys
If opKey
	Send, p
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, vysmaty and 232 guests