Hot keys without sending original combination

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
akirofe
Posts: 150
Joined: 05 Apr 2021, 21:54

Hot keys without sending original combination

27 Mar 2024, 02:37

Hi guys,

Hope you are well.

Please kindly help me with this please: Using this key press detector website https://en.key-test.ru/, I saw that my codes below

Code: Select all

Ctrl & Shift::
{
Sleep(300)
Send "{LButton}"
return
}
did send the unwanted Ctrl
- and

Code: Select all

Shift & Ctrl::
{
Sleep(300)
Send("{Lbutton}")
Send("{Lbutton}")
return
}
did send the unwanted Shift

Could you please help as to where for me to read to understand this matter or help me fixing these codes thank you very much? <3

Warm Regards,
Aki.


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
Noitalommi_2
Posts: 224
Joined: 16 Aug 2023, 10:58

Re: Hot keys without sending original combination

27 Mar 2024, 03:46

Hi.

Please try.

Code: Select all

#Requires AutoHotkey 2.0
#SingleInstance

^Shift:: {

	Sleep 300
	Send "{LButton}"
}

+Ctrl:: {

	Sleep 300
	Send "{LButton}"
	Send "{LButton}"
}
gregster
Posts: 9035
Joined: 30 Sep 2013, 06:48

Re: Hot keys without sending original combination

27 Mar 2024, 21:19

What means "sends the unwanted ctrl"? This website detects the key events which it can see, but it doesn't even distinguish between down and up events. How do you know if it's a sent Ctrl or simply an event of your own physical keypress? Especially since Ctrl doesn't get suppressed like regular keys in a custom combo:
https://www.autohotkey.com/docs/v2/Hotkeys.htm#combo wrote:The prefix key loses its native function, unless it is a standard modifier key or toggleable key such as CapsLock.
(highlight by me)


Why not use AHK's own KeyHistory for the discussion which is much more detailed and can give you information even about suppressed or hooked keys and up/down events (don't forget to install the mouse hook, if necessary).

Also, you might know that Send (without blind mode), might require additional key events so that it can send unmodified keys.
This might be more obvious when not using a long sleep like above, eg: ^Shift::Send "{LButton}"

And yes, for actual modifier keys like Ctrl it is recommended to use their respective symbols (like Noitalommi_2 showed above):
https://www.autohotkey.com/docs/v2/Hotkeys.htm#combo wrote:Note: For combinations with standard modifier keys, it is usually better to use the standard syntax. For example, use <+s:: rather than LShift & s::.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: alawsareps and 143 guests