Hotstring, interfering with hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Hotstring, interfering with hotkey

07 Oct 2021, 03:50

Hi.

I have a script with some keyboard remappings (hotkeys) and 1 hotstring in it. That hotstring is doing what is should, but it breaks some of the remappings - specifically the "dead keys". Other remappings still work fine. My script file looks like this:

Code: Select all

<^>!`::Send,{U+00F4} ;ô
<^>!+`::Send,{U+00D4} ;Ô

<^>!/::Send,{U+00FD} ;ý
<^>!+/::Send,{U+00DD} ;Ý

+'::SendInput {U+0022} ;"
'::SendInput {U+0027} ;'
^::SendInput {U+005E} ;^
~::SendInput {U+007E} ;~
`::SendInput {U+0060} ;`

:c:ScC::sugar with coffe and cream

#!Left::
SetWinDelay,0
WinGetPos,x,y,,,A
WinMove,A,,% x-100
return

#!Right::
SetWinDelay,0
WinGetPos,x,y,,,A
WinMove,A,,% x+100
return
When I press " I'll get another " inserted by the system, for instance (which is what the current keyboard layout "United Stated-international" does by default). What could be the reason? Maybe there are better ways of remapping the dead keys?
Last edited by SunAndSuch on 07 Oct 2021, 07:09, edited 1 time in total.
User avatar
mikeyww
Posts: 27215
Joined: 09 Sep 2014, 18:38

Re: Hotstring, interfering with hotkey

07 Oct 2021, 05:31

You press one quotation mark, and then see two of them? I was not able to reproduce that by running your script.
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Re: Hotstring, interfering with hotkey

07 Oct 2021, 07:14

I should probably have specified that I am using the "United States-international" keyboard layout (updated my question now), which has "dead keys". So yes, I press one quotation mark, then a space, or some other letter and another quotation mark appears. I am using these remappings to disable this annoying feature :).
Windows 10, Ahk v1 x64-bit.
User avatar
mikeyww
Posts: 27215
Joined: 09 Sep 2014, 18:38

Re: Hotstring, interfering with hotkey

07 Oct 2021, 08:16

In testing, it appears to me that the issue is +'. You get AHK's send along with the usual quotation mark and the character that follows it.

If you cannot use the regular US keyboard, the following worked in my test.

Code: Select all

$"::Send ""`b
This sends the quotation mark, followed by another quotation mark as shown. This seems to cancel what is happening with the international keyboard's handling. The final `b then just erases the second mark.
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Re: Hotstring, interfering with hotkey

11 Oct 2021, 07:50

Thanks for the suggestion mikeyww. I have tried it out and it behaves as you are describing it. That means I still have to type something after the ' for it to appear, while I'd like it to act exactly like the regular US keyboard without dead keys.
Speaking of which, I guess I could use the regular keyboard, but the international one already has so many useful characters in it (which can also be used when AHK is not running). Often I find myself typing in several different languages, even combining them in one sentence.
But maybe it's worth remapping a whole bunch of keys in the 'non-international' keyboard.
Windows 10, Ahk v1 x64-bit.
User avatar
mikeyww
Posts: 27215
Joined: 09 Sep 2014, 18:38

Re: Hotstring, interfering with hotkey

11 Oct 2021, 08:42

I might be misunderstanding what you need, but you can work with ' the same way.

Code: Select all

$"::Send ""`b
$'::Send ''`b
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Re: Hotstring, interfering with hotkey

12 Oct 2021, 03:01

Oh, of course. I mistook ' for a " under testing. It works as it should when I press the correct key :crazy:.
I've experimented a bit more and landed on just adding the dollar sign in front of my original hotkeys (and replacing the +':: with $"::):

Code: Select all

$"::SendInput {U+0022} ;"
$'::SendInput {U+0027} ;'
$^::SendInput {U+005E} ;^
$~::SendInput {U+007E} ;~
$`::SendInput {U+0060} ;`
So now it works fine, although I'm still not sure why adding a hotstring would disrupt the original hotkey-code. Anyway, thanks again for pointing me the right direction :thumbup:.
Windows 10, Ahk v1 x64-bit.
User avatar
mikeyww
Posts: 27215
Joined: 09 Sep 2014, 18:38

Re: Hotstring, interfering with hotkey

12 Oct 2021, 05:33

$ activates the keyboard hook. Without the hook, if the subroutine sends the hotkey itself, it triggers a loop instead of sending the key as expected.
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Re: Hotstring, interfering with hotkey

12 Oct 2021, 08:52

Right, well, still, the original code was working (for years) until I added the hotstring.
Windows 10, Ahk v1 x64-bit.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], mikeyww and 128 guests