AutoHotkey - Display all Hotstrings

12/13/09

AutoHotkey - Display all Hotstrings

I wrote my first real AutoHotkey script yesterday. I’ve been using the program for a week or so to provide keyboard macros, but I wanted a way to list all of my hotstrings (abbreviation-expanders).

I set up my hotstrings to start with two dots (..) and to not require an ending character (like space or tab). So if I type “..e” it will be replaced with my email address. That’s set up as:

:c*:..e::myemail@my.domain

Here’s my first cut at a macro to list the hotstrings in the current script. I haven’t found a way to get at the metadata for this yet, so I’m loading the current script file as text and parsing it with regular expressions. Note that this does not depend upon my two-dot convention. It does have to be in the same file as the hotstrings, though. I don’t list the expansion text, as that can get pretty long (snippets of SQL, etc.).

; == HOTKEYS ==

#H::
; Windows + H: Display all Hotstrings

FileRead, ScriptContents, %A_ScriptFullPath%

if not ErrorLevel
{
  AllHotstrings := ""

  Loop, parse, ScriptContents, `n, `r
  {
    if (RegExMatch(A_LoopField, "^:.*?:(.+?)::", SubPat))
    {
      AllHotstrings := AllHotstrings . SubPat1 . "`n"
    }
  }

  MsgBox 0, Hotstrings, %AllHotstrings%
}

return


Your Host: webmaster@truewill.net
Copyright © 2000-2013 by William Sorensen. All rights reserved.