Make key trigger hotstring or perform other function Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
poetofpiano
Posts: 61
Joined: 25 Jan 2016, 14:26

Make key trigger hotstring or perform other function

Post by poetofpiano » 01 Dec 2022, 21:21

I want the below hotkey to work while still allowing the / key to trigger the end of a hotstring like usual:

Code: Select all

$/::
KeyWait, /
If A_PriorKey != /
    return
send /
return
The advantage of the above is that I can use / as the base for other hotkeys, e.g., / & w. But like I said, it prevents / from triggering a hotstring like ::btw::by the way.

I tried the following modification that has worked in similar situations to allow one hotkey to trigger another, but it prevents / from sending at all:

Code: Select all

#InputLevel, 1
$/::
KeyWait, /
If A_PriorKey != /
    return
sendevent /
return
#InputLevel, 0
Any ideas from an AHK genius?

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Make key trigger hotstring or perform other function

Post by mikeyww » 01 Dec 2022, 21:37

If your goal is to send a key upon release, then why not

Code: Select all

/ Up::Send /
:?:

As far as I can tell,

Code: Select all

If A_PriorKey != /
is never met, because the prior key after a KeyWait for the hotkey is the hotkey when the hook is used.

Code: Select all

::btw::by the way
#InputLevel 1
/ Up::Send /
#InputLevel 0

poetofpiano
Posts: 61
Joined: 25 Jan 2016, 14:26

Re: Make key trigger hotstring or perform other function

Post by poetofpiano » 02 Dec 2022, 01:46

Code: Select all

[quote=mikeyww post_id=494049 time=1669948667 user_id=59977]
::btw::by the way
#InputLevel 1
/ Up::Send /
#InputLevel 0
[/quote]
This didn’t work for me to trigger the expansion by typing "btw/". This did:

Code: Select all

::btw::by the way
#InputLevel 1
/::Sendevent /
#InputLevel 0
I just wish that could coexist with my other / & w:: style hotkeys. This does not trigger upon typing "btw/":

Code: Select all

::btw::by the way
#InputLevel 1
/::Sendevent /
#InputLevel 0 

/ & w::send k

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Make key trigger hotstring or perform other function  Topic is solved

Post by mikeyww » 02 Dec 2022, 06:14

Code: Select all

map := {w: "k"}
For each, letter in map
 list .= letter

::btw::by the way

#InputLevel 1
/ Up::Send % list ~= A_PriorKey ? "" : "/"
w Up::
hk := SubStr(A_ThisHotkey, 1, 1)
Send % GetKeyState("/", "P") ? map[hk] : hk
Return
#InputLevel 0

Post Reply

Return to “Ask for Help (v1)”