The importance of " $ " Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

The importance of " $ "

26 May 2018, 19:02

Hi guys,

I would like to know the real value of using the "$" sign in each script.

I'm talking about using it for example like this:

Code: Select all

$!k::
The explanation that is in the AHK tutorial is not clear to me (English is not my mother tongue)

Should I always put it? In which case would it be a problem to use it?

Thank you very much in advance
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: The importance of " $ "  Topic is solved

26 May 2018, 20:44

The $ modifier in regards to hotkeys forces the hotkey to be implemented using a keyboard hook and not via RegisterHotkey() or SetWindowsHookEx() or whatever other methods are available instead. If not yet loaded, it would also load the hook. What it does besides implementing the hotkey is prevent Send from retriggering the hotkey, eg, a::Send a would result in a loop (though there are safeguards put in place).

I can think of only 2 scenarios where you wouldn't want a hotkey to be implemented with the hook. If you're concerned with the script's footprint and if you want to retrigger the same or trigger other hotkeys using the Send command, which you shouldn't be doing in the first place.

Most of the times the hook will be used regardless. Personally I fancy putting the dollar as a mental marker for "hey, this hotkey is possibly sending itself at some point, which is verboten" if I do decide later down the road to strip it of it's modifiers or get rid of other constructs, inadvertently making it not being implemented with the hook any longer.
Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

Re: The importance of " $ "

26 May 2018, 22:01

Thank you, very much.

The best for you

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 266 guests