hotstring input consisting of special characters

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

hotstring input consisting of special characters

15 Jul 2021, 13:18

I have a standalone numpad with a few extra buttons. Everything maps to standard scan codes except for 3 buttons, 2 for parenthesis, and one for =

The problem is those keys actually are sending the alt code combo for those symbols. There are no drivers, it's just happening in the hardware. I want to remap those keys for something more useful, but I'm not sure how to intercept the input.

Here is an example keyhistory of pressing the ( button once:
A4 038 d 1.03 LAlt
60 052 d 0.01 Numpad0
60 052 u 0.02 Numpad0
64 04B d 0.00 Numpad4
64 04B u 0.00 Numpad4
60 052 d 0.00 Numpad0
A4 038 u 0.02 LAlt
60 052 u 0.00 Numpad0

Does anyone know how to detect that series of keypresses in AHK?
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: hotstring input consisting of special characters

15 Jul 2021, 14:37

So you have tried this and found that it does not work?

Code: Select all

(::MsgBox, 64, Result, Test
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

Re: hotstring input consisting of special characters

15 Jul 2021, 14:43

No luck, it just sends the ( symbol

That test does work if I press shift+9 though
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: hotstring input consisting of special characters

15 Jul 2021, 14:56

This probably does not help, but perhaps it is an idea in the right direction.

Code: Select all

Alt Up::Input
Alt:: ; https://autohotkey.com/board/topic/121922-hotkeys-like-altnumpad/
Input text
Send % text = "040" ? "x" : ""
Return
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

Re: hotstring input consisting of special characters

15 Jul 2021, 15:08

Ooh, that does work!

can you point me to some syntax info on this construction: text = "040" ? "x" : ""

I think I know what's going on there, but some more direction would be appreciated
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: hotstring input consisting of special characters

15 Jul 2021, 15:20

It's just If... then... else.

Code: Select all

Alt Up::Input
Alt:: ; https://autohotkey.com/board/topic/121922-hotkeys-like-altnumpad/
Input text
If (text = "040")
 Send x
Return
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

Re: hotstring input consisting of special characters

15 Jul 2021, 15:23

Ok, I found it, the ternary operator. I rewrote it as a series of if else statements to wrap those 3 keys into one function, and it works great!

But, I can no longer manually enter alt-codes. Not really a dealbreaker, I only ever need it for the degree symbol (alt+0248), so I just built another if into my function to detect that and send the symbol.

Thank you so much for your help! If you ever need any help with 3D rendering or animation, find me on the blenderartists forum, I'd love to return the favor.

Thanks again!
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: hotstring input consisting of special characters

15 Jul 2021, 15:27

Thanks! I'm glad it worked (more or less).
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

Re: hotstring input consisting of special characters

15 Jul 2021, 16:24

on further review, this breaks any other hotkey that uses alt, haha

Any tips on setting up a timeout override? My numpad pounds out those keycodes in under .06 seconds, so any fast input could be detected and anything happening at a more human pace could still passthrough.
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: hotstring input consisting of special characters

15 Jul 2021, 19:07

You can try things like the following. Reviewing documentation for Input might provide additional ideas.

Code: Select all

Alt Up::Input
Alt:: ; https://autohotkey.com/board/topic/121922-hotkeys-like-altnumpad/
Input text
If (text = "040")
 Send x
Else Send !%text%
Return
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

Re: hotstring input consisting of special characters

02 Aug 2021, 15:49

mikeyww wrote:
15 Jul 2021, 19:07
You can try things like the following. Reviewing documentation for Input might provide additional ideas.

Code: Select all

Alt Up::Input
Alt:: ; https://autohotkey.com/board/topic/121922-hotkeys-like-altnumpad/
Input text
If (text = "040")
 Send x
Else Send !%text%
Return
I added the send !%text% to my last if, and it is still breaking my other shortcuts. I use a lot of alt+clicking in my programs and non of those work at all.

I added a 100 millisecond timeout to the input command, as the virtual keystrokes are sent real fast. Is there anyway to just exit the hotkey script and dump it back to standard operation?
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: hotstring input consisting of special characters

02 Aug 2021, 16:07

ExitApp works, but it sounded like you needed your other hotkeys. Perhaps others on the forum have additional ideas.
sterlingroth
Posts: 7
Joined: 15 Jul 2021, 13:05

Re: hotstring input consisting of special characters

04 Aug 2021, 16:04

I do need the other hotkeys, but the alt hotkey script is gumming up other hotkeys.

If I could get the AHK hotkey that listens for the alt code to do its job in 100 milliseconds, then revert back to standard alt key held down behavior, that would solve my issues.
lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: hotstring input consisting of special characters

06 Aug 2021, 22:40

I would suggest trying <!Numpad0:: rather than Alt::, to start the sequence. The rest of the sequence can be detected either with additional hotkeys (either unconditional or using the Hotkey command or #If) or Input as before.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], inseption86, peter_ahk, Rohwedder, william_ahk and 208 guests