Remapped Keys not Triggering Hotstrings Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
buttshark
Posts: 62
Joined: 22 Apr 2017, 20:57

Remapped Keys not Triggering Hotstrings

24 Oct 2017, 17:29

Hello all!
What I want to do is simple. I would like to rebind my keyboard such that the number bar (above qwertyuiop) is inverted (pressing "2" would send "@", and pressing "Shift+2" would send "2"), since I normally use the numpad for numbers, anyways. What I came up with is as you would expect:

Code: Select all

1::!
2::@
3::#
4::$
5::send, `%  ; "5::%" doesn't compile
6::^
7::&
8::*
9::(
0::)

+1::numpad1
+2::numpad2
+3::numpad3
+4::numpad4
+5::numpad5
+6::numpad6
+7::numpad7
+8::numpad8
+9::numpad9
+0::numpad0
My problem is that this remapping doesn't work for hotstrings. So if I had

Code: Select all

:c:hi!::HI
and I pressed "hi2", it wouldn't trigger the hotstring.

*note: these characters aren't necessarily at the end of the hotstring, so although you may be able to get something along the lines of

Code: Select all

:cB0:hi::
	if(A_EndChar == "!")
		Send, {BS 3}HI
	return
to work, that's not what I'm looking for.

When I was looking into this I remember reading something about reg and k-hook hotstrings, and in my case, pressing 0-9 would reset the hotstring recognizer, which is no good. In the documentation of SendLeve, it mentions "...In some cases it can be useful to override this behaviour; for instance, to allow a remapped key to be used to trigger other hotkeys..." but messing around with it, I couldn't come up with a functioning solution.

I was messing around with making the numbers hotstrings, and using GetKeyState to see if it was the numpad or number bar that pressed it, but alas, I couldn't make that work, either (though I don't really fancy that soulution, since if 1! was pressed in a short enough time span where both keys were held down at the same time, that could send 11 or !!).

Also, my remapping script and hotstring scripts are in different files, so if there is a solution that works when scripts are separate (or at least #Include), that would be great.

Any help would be greatly appreciated. Thanks!
I have no idea what I'm doing.
buttshark
Posts: 62
Joined: 22 Apr 2017, 20:57

Re: Remapped Keys not Triggering Hotstrings

22 Sep 2018, 02:56

Well it's been over a year, and I decided to take another crack at it... And I still failed.
From what I noticed, the main reason why I couldn't get it to work is because the remapping is for the same key (1 -> !, 2 -> @, etc). I can get this working no problemo if it goes to a different key.

Goal: remap '0' to ')' such that typing '0' will trigger the hotstring ')'
Attempt 1:

Code: Select all

0::)
:*:)::success!
;doesn't work, '0' doesn't trigger hotstring (and neither does ')')
Attempt 2:

Code: Select all

0::
SendLevel, 1
Send, )
return
:*:)::success!
;doesn't work, '0' sends nothing
Attempt 3:

Code: Select all

#InputLevel, 1
0::)
#InputLevel, 0
:*:)::success!
;doesn't work, pressing '0' and ')' does nothing
Attempt 4:

Code: Select all

Hotkey, 0, lbl, I1
return
lbl:
Send, )
return
:*:)::success!
;it... it actually works!?
YAY! So for whatever reason, Dynamically creating the hotkey with an input level fixes the problem? Nope. For some mystical reason beyond me, it doesn't work with 6, 3, or 1. Specifically:

Code: Select all

Hotkey, 6, lbl6, I1
Hotkey, 3, lbl3, I1
Hotkey, 1, lbl1, I1
return
lbl6:
Send, ^
return
lbl3:
Send, #
return
lbl1:
Send, !
return
:*:^::why must
:*:#::this be
:*:!::so difficult
;doesn't work, pressing '1', '3', and '6' does nothing
Fun fact: it also doesn't work with mapping '[' to '{' and ']' to '}' (and maybe ';' to ':', can't check because I don't think it is possible to make ':' a hotstring). But thankfully I don't care about those two/three. So once again, I come crawling back for help. Perhaps someone got a few new insights in over the past year :P.
I have no idea what I'm doing.
User avatar
Nextron
Posts: 1318
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Remapped Keys not Triggering Hotstrings  Topic is solved

22 Sep 2018, 04:35

Three thing to consider are that:
• You need to set the #Inputlevel[/c] higher than the hotstring. (as you have done)
• You need to send the hotkeys using SendEvent. (Not sure if you set SendMode anywhere to input)
• As for ^#!+, those are used to indicate modifier keys in send commands. To use them literally enclose them in {}.

Then it should work:

Code: Select all

#InputLevel, 1
6::SendEvent, {^}
#InputLevel, 0
:*:^::success!
buttshark
Posts: 62
Joined: 22 Apr 2017, 20:57

Re: Remapped Keys not Triggering Hotstrings

22 Sep 2018, 04:50

AHA! Works like a charm. Thanks :⁠)
I have no idea what I'm doing.

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 96 guests