press "Up", this script hears " ~ Up "

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

press "Up", this script hears " ~ Up "

28 Feb 2016, 02:47

Code: Select all

#IfWinActive ahk_class never_ever
	~Up::ExitApp
#IfWinActive
	Up::
		ToolTip, %A_ThisHotkey%
		Sleep, 2000
		ToolTip
	Return
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: press "Up", this script hears " ~ Up "

29 Feb 2016, 01:33

@lexikos:
... its key name and the ordering of its modifier symbols ...
Not really clear, or do you think it is?
Recca
Posts: 35
Joined: 18 Jan 2016, 21:44

Re: press "Up", this script hears " ~ Up "

29 Feb 2016, 01:39

Rohwedder wrote:

Code: Select all

#IfWinActive ahk_class never_ever
	~Up::ExitApp
#IfWinActive
	Up::
		ToolTip, %A_ThisHotkey%
		Sleep, 2000
		ToolTip
	Return
Hi, What do you need help with?
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: press "Up", this script hears " ~ Up "

29 Feb 2016, 03:56

@just me:
I don't think there's much room to misinterpret "shared by all variants of the hotkey". Referring to "the permanent name of that hotkey" also has clear implications.

I suppose it was written in that roundabout way because it is awkward to explain without defining what a hotkey "name" is. On the other hand, the Hotkey command uses the term "key name" to mean the actual hotkey definition (name), including modifiers, so the A_ThisHotkey documentation could be basically saying "the name of the hotkey becomes the permanent name of the hotkey" -> "the name of the hotkey becomes permanent".

How about: "If there are multiple variants of a hotkey, A_ThisHotkey returns the exact string which was used to create the first variant of the hotkey."

If more is needed: "Depending on how it was created, this is either the part of the label up to (but not including) the double-colon, or the value of the Hotkey command's first parameter."

I think the mention of "key name", if it is referring only to the name of the key (as in 'Up', excluding '~'), is not important. If you use different names, as in Esc vs Escape vs vk1B, they are treated as different hotkeys (but only one of them is recognized) so the "shared name" doesn't apply. It only matters if using case-sensitive comparison with A_ThisHotkey (i.e. "Up" vs "up").

The ordering of modifier symbols and presence or absence of optional modifier symbols (~ and $) is important, but I don't know that it's necessary to spell out after writing "the exact string". Perhaps an example demonstrating the problem would be better.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: press "Up", this script hears " ~ Up "

29 Feb 2016, 05:02

@lexikos:
I think that most people would expect that "its key name and the ordering of its modifier symbols" is related to all "modifier symbols" listed on the HotKeys page. But, as far as I tested, only $ and ~ are treated as part of the name in A_ThisHotkey for the subsequent variants.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: press "Up", this script hears " ~ Up "

29 Feb 2016, 18:08

@just me: Were you creating different variants of one hotkey in your tests, or different hotkeys? Were you reordering the modifiers, or using different modifiers? :facepalm:

Code: Select all

#if 0
^+i::
#if
+$^i::
MsgBox %A_ThisHotkey%  ; ^+i
All the same hotkey: ^+i, +^i, $^+i, ~^+i, $~+^i, ~$+^$~+^~i

~ and $ are ignored for the purposes of identifying a hotkey, but they are still part of the name like every other modifier. They can be applied to some variants and not others (although $ affects all variants).
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: press "Up", this script hears " ~ Up "

01 Mar 2016, 02:17

@lexikos: Good question! And that's exactly why I think that the docs are unclear.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: press "Up", this script hears " ~ Up "

01 Mar 2016, 02:33

Now you are being unclear. I could interpret that to mean [that you are failing to see the obvious is] exactly why you think that the docs are unclear. That's not necessarily a fault of the docs.

The docs for A_ThisHotkey are not the place to explain which hotkeys are variants of other hotkeys and which hotkeys are unique. You can easily find out which is which by defining both without #If. If you get a duplicate hotkey error message, they are the same hotkey. If not, they are not the same hotkey.

Code: Select all

^+i::
+$^i::  ; Error: Duplicate hotkey.
Never mind how unclear the docs are; what about the explanation in my post above?
I wrote:How about: "If there are multiple variants of a hotkey, A_ThisHotkey returns the exact string which was used to create the first variant of the hotkey."

If more is needed: "Depending on how it was created, this is either the part of the label up to (but not including) the double-colon, or the value of the Hotkey command's first parameter."
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: press "Up", this script hears " ~ Up "

01 Mar 2016, 03:11

"If there are multiple variants of a hotkey, A_ThisHotkey returns the exact string which was used to create the first variant of the hotkey."
Well, this might help. It could be added at least to the descriptions of ~ and also $ in the modifier listing.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lpanatt, macromint, peter_ahk, Spawnova and 262 guests