Trigger hotstring ONLY when preceded by alphanumbe

2019-06-14 06:07发布

问题:

I know about using ? in a hotstring (e.g. :?:btw::by the way) to allow the hotstring to fire after an alphanumberic character. However, is there a way to make it fire only when preceded by an alphanumberic character? For example, so it doesn't trigger on #btw or @btw or :btw or similar.

回答1:

The only thing i can think of is to make a hotstring for every alphanumeric character.

:?:abtw::by the way
:?:bbtw::by the way
:?:cbtw::by the way
.
.
.
:?:Ybtw::by the way
:?:Zbtw::by the way
:?:1btw::by the way
.
.
.


回答2:

The library RegEx Powered Dynamic Hotstrings can do this for you. Save the above library in the same directory as your script and run the following:

#Include DynamicHotstrings.ahk

hotstrings("[\w]btw", "btw") ; [\w] is the regular expression for a single character word
Return

btw:
    SendInput, by the way
Return


标签: autohotkey