Different register in A_ThisHotkey

Report problems with documented functionality
serzh82saratov
Posts: 137
Joined: 01 Jul 2017, 03:04

Different register in A_ThisHotkey

29 Jul 2018, 07:13

This is the same as in GetKeyName, in the header register. If you uncomment ~$uP ::, then another hotkey is specified.
Can you make a correction, A_ThisHotkey is always identical to GetKeyName?
Or, at least, stayed, in the form in which he was appointed for this label.

Code: Select all

Hotkey, % GetKeyName("uP"), Lbl
SendLevel, 100
Send {up}
Return

Lbl:
	MsgBox % A_ThisHotkey
	Return
	
; ~$uP::Return
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Different register in A_ThisHotkey

29 Jul 2018, 13:12

This is documented behaviour,
When a hotkey is first created -- either by the Hotkey command or a double-colon label in the script -- its key name and the ordering of its modifier symbols becomes the permanent name of that hotkey, shared by all variants of the hotkey.
Maybe you mean for this to be in the wish list forum?

Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Different register in A_ThisHotkey

29 Jul 2018, 16:15

For situations like this I often create multiple labels pointing to the same code, and check A_ThisLabel.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Different register in A_ThisHotkey

29 Jul 2018, 22:16

Can you make a correction, A_ThisHotkey is always identical to GetKeyName?
No. Then the names of individual hotkeys would unexpectedly differ from what the user wrote in the script, and scripts relying on the documented behaviour would no longer work.

The "canonical" name returned by GetKeyName might not be what the user expects (with respect to keys with multiple names). Hotkeys specified by VK or SC behave differently in some cases than those specified by name, but GetKeyName always returns a name. The presence and order of modifier symbols can vary. Using the first name and ordering found in the script is best overall.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 24 guests