Can an exclamation mark be used as hotkey?
Can an exclamation mark be used as hotkey?
For an autocorrect string where the exclamation mark is replaced with non-breaking space + exclamation mark, how can the exclamation mark, being the modifier for Alt be used as a hotkey?
Re: Can an exclamation mark be used as hotkey?
Either there is something to modify, then ! is a modifier - or there is nothing to modify, then ! is a !:
If you want to remap Alt alone, then you can use:
Finally, Alt + !
Code: Select all
!::msgbox
Code: Select all
alt::msgbox alt
Code: Select all
!!::msgbox
Re: Can an exclamation mark be used as hotkey?
Thank you! I had just realized that before reading your reply. My intended hotstring wasn't working for other reasons, not because of a bad abbreviation. And thank you for the additional explanations regarding Alt, very helpful!
Another head-scratcher was trying to use a colon as the abbreviation for a hotstring. I couldn't figure how to make it work so I ended up using this:
But I'm still wondering if it could be done with a hotstring.
Another head-scratcher was trying to use a colon as the abbreviation for a hotstring. I couldn't figure how to make it work so I ended up using this:
Code: Select all
: up::Send ^+{Space}:
Re: Can an exclamation mark be used as hotkey?
This works for me with a hotstring:
It seems you are missing a :
Or, do want to replace a string with : ?
But if you want to use a command like Send in a one-line-hotstring, you need to use the X option (AHK version 1.1.28+):
Code: Select all
::!up::Hello world
Or, do want to replace a string with : ?
Code: Select all
::colon::: ; replaces "colon" with ":"
Code: Select all
:X:colon::Send :
Re: Can an exclamation mark be used as hotkey?
Thank you gregster,
The intended action is to add a non-breaking space (achieved by pressing Ctrl+Alt+Space) before a colon, immediately when typing ":".
But I didn't know how to use ":" as the abbreviation for a hotstring, so my workaround was to use the up state of ":" as a hotkey instead, which is working.
The intended action is to add a non-breaking space (achieved by pressing Ctrl+Alt+Space) before a colon, immediately when typing ":".
But I didn't know how to use ":" as the abbreviation for a hotstring, so my workaround was to use the up state of ":" as a hotkey instead, which is working.
Re: Can an exclamation mark be used as hotkey?
The hotkey and hotstring parsers have some trouble with ":". You can create a hotstring with ":" as the trigger by using the Hotstring function in v1.1.28+.
You can create a ":" hotkey without doing anything special:
However, you probably want to do this:
...but that will probably create a loop where the sent colon triggers the hotkey. To avoid that, you might want to add the $ prefix:
...but that won't work because the hotkey parser doesn't support it. So you can do this instead:
...but that will only work with keyboard layouts where Shift+; produces ":", such as the US layout. Instead, you can use the Hotkey command or #UseHook:
The hotkey is mapped according to the script's keyboard layout (usually the system default layout), so if the system has multiple layouts with different ways of producing ":", a hotkey will only work with the "default" way while a hotstring will adapt to the active window.
Code: Select all
Hotstring(":*::", Func("nbsp_colon"))
nbsp_colon() {
Send ^+{Space}:
}
Code: Select all
:::MsgBox colon
Code: Select all
:::Send ^+{Space}:
Code: Select all
$:::Send ^+{Space}:
Code: Select all
$+;::Send ^+{Space}:
Code: Select all
Hotkey $:, nbsp_colon ; Passing a function requires v1.1.20+
nbsp_colon() {
Send ^+{Space}:
}
Code: Select all
#UseHook
:::Send ^+{Space}:
Re: Can an exclamation mark be used as hotkey?
Excellent information, thank you!
Who is online
Users browsing this forum: Bing [Bot], Darkmaster006, mikeyww, Raghava Doregowda and 346 guests