How can I do this, given that the number following w could be a variable length? does autohotkey hotstrings support regex or variable pattern matching?

I currenty have w expanding to width:px and the cursor positioned before the px.

:oR0:w::width:px;{left 3}

  • Which platform and which app are you using?
    – jsejcksn
    Sep 9, 2010 at 7:07
  • windows 7, autohotkey 1.0.48
    – Moin Zaman
    Jan 10, 2011 at 7:28

1 Answer 1


Use the hotstrings( regexStr, expandedStr) method defined here and add this to the top of the script above the definition of the function:

 hotstrings( "w(\d+)\s", "width:%$1%px;" )

I've got it working on AutoHotKey on Windows XP.

  • That looks promising. I can't get it to work however. I pasted the contents hotstrings.ahk at the bottom of my existing script. Then I put the one line call you've got above at the top of my script. Nothing happens when I type w94 and hit space.
    – Moin Zaman
    Jan 10, 2011 at 7:10
  • I think I am missing how to setup the hostrings, I'm finding some info about an .ini file but I don't have an autohotkey.ini file on my machine. Could you clarify how you've got it setup?
    – Moin Zaman
    Jan 10, 2011 at 7:27
  • 1
    Ok, I got it. I created a new script called hotstrings.ahk with the function declaration at the bottom and my 1 line hostring definitions at the top. It works. Thanks again!
    – Moin Zaman
    Jan 10, 2011 at 8:02
  • @Moin: Glad it worked for you!
    – yhw42
    Jan 10, 2011 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.