New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Propose new features and changes
gvieira
Posts: 2
Joined: 09 Nov 2020, 05:30

New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by gvieira » 15 Jun 2021, 22:35

There is a MOD_NOREPEAT flag (0x4000) in the "RegisterHotKey" windows function that isn't used with ahk yet, it makes the key repetitions from the key being held be suppressed by the system.

My request is that it's implemented using a new hotkey modifier "@"

Example of a script that suppresses repetitions without the flag.

Code: Select all

F4::
  if F4Pressed
    return
  F4Pressed := true
  Tooltip F4 was pressed!
return

F4 up::
  F4Pressed := false
  Tooltip
return
Same script with the flag:

Code: Select all

@F4::Tooltip F4 was pressed!
@F4 up::Tooltip
Source: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey#parameters

I'm new on the forum (this is actually my first post), but I'm very active on discord, and this "suppress repetitons" problem appears often enough that I think it would be helpful.

My c++ knowledge is limited to be able to submit a github PR with a bugless version of the implementation so I thought it would be better to just suggest it here.

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by just me » 16 Jun 2021, 04:29

Changes the hotkey behavior so that the keyboard auto-repeat does not yield multiple hotkey notifications.

Windows Vista: This flag is not supported.
WinUser.h:

Code: Select all

#if(WINVER >= 0x0601)
#define MOD_NOREPEAT    0x4000
#endif /* WINVER >= 0x0601 */
Might be an option for v2.

gvieira
Posts: 2
Joined: 09 Nov 2020, 05:30

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by gvieira » 16 Jun 2021, 05:17

just me wrote:
16 Jun 2021, 04:29
Changes the hotkey behavior so that the keyboard auto-repeat does not yield multiple hotkey notifications.

Windows Vista: This flag is not supported.
WinUser.h:

Code: Select all

#if(WINVER >= 0x0601)
#define MOD_NOREPEAT    0x4000
#endif /* WINVER >= 0x0601 */
Might be an option for v2.
Why is it a problem that it's not supported on really old versions of windows?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by swagfag » 16 Jun 2021, 06:32

i think if this were to be implemented, it would have to be implemented as a hook hotkey in order to support hook hotkeys. so it wouldnt matter whether RegisterHotkey() had a flag for it or whether it was supported on whatever OS
the only question that remains is whether its worth(the time/effort) implementing it in source given the alternatives(KeyWait, #If, other inscript solutions)

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by just me » 16 Jun 2021, 06:40

gvieira wrote:Why is it a problem that it's not supported on really old versions of windows?
Because AHK scripts must run on all supported system versions.

mikeblas
Posts: 3
Joined: 22 Nov 2021, 14:58
Contact:

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by mikeblas » 23 Nov 2021, 12:04

just me wrote:
16 Jun 2021, 06:40
Because AHK scripts must run on all supported system versions.
Windows Vista support ended in April of 2017, more than four years ago.

iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by iseahound » 25 Nov 2021, 17:55

This would be useful for mousewheel hotkey combos, where there isn't a 1 second delay before repeating.

lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Re: New hotkey modifier "@" to suppress repetitions using already existent windows api flag

Post by lexikos » 26 Nov 2021, 20:54

What "this"?

"This" is "New hotkey modifier "@" to suppress repetitions using already existent windows api flag"

This only applies to RegisterHotkey, which does not support mouse hotkeys.

It would not work for the example in the top post either, because F4 up:: causes both hotkeys to require the keyboard hook. RegisterHotkey would not be used.

For normal keyboard keys, key-repeat can be detected with fair accuracy by tracking previous events - if you received two key-down events without a key-up event, usually you can assume that the second key-down was due to key-repeat.

Mouse wheels do not have key-down and key-up events; only reports that the wheel is rotated by some amount in one direction or the other. Without knowing the physical characteristics and timing of the hardware, it is impossible to know whether repeat is due to continued rotation of the wheel by the user, or digital repeat by hardware which doesn't actually have a (horizontal) wheel.

Post Reply

Return to “Wish List”