title: Displaying List of AutoHotkey Hotkeys
body: <p>I’ve written script that contains numerous hotkeys (general structure is as below). I would like to create another one that when pressed displays a list of all of the hotkeys and their corresponding descriptions that the script contains in a nice, formatted table.</p>
  
  <p>The formatting and display are tenuous since AutoHotkey’s output is limited to message-boxes, but possible. More problematic is getting the hotkeys and corresponding descriptions.</p>
  
  <p>The hotkeys all call the same function with different arguments. I considered adding a variable to the function so that depending on the value, the function either performs the normal function when triggered by the normal hotkeys, or builds a string or something when triggered from the special display hotkey.</p>
  
  <p>I cannot figure out a way to programmatically access the script’s hotkeys at all. I checked the docs and there don’t seem to be any <code>A_</code> variables that can be used for this purpose, nor does the <code>Hotkey</code> command lend itself well (it can be used to test if a hotkey exists, but looping through the innumerable combinations is, <em>at best</em>, tedious).</p>
  
  <p>Failed attempts:</p>
  
  <ul>
  <li>I tried using Elliot’s suggestion of parsing the script itself (replacing the path with %A_ScriptFullPath%, and while it does work for a raw script, it does not when the script is compiled</li>
  <li>I tried assigning the entire hotkey section of the script to a variable as a continuation section and then parsing the variable and creating hotkeys using the <code>Hotkey</code> command. This worked well right up until the last part because the <a href="https://stackoverflow.com/questions/12851677/"><code>Hotkey</code></a> command cannot take arbitrary commands as the destination and requires <em>existing</em> labels.</li>
  <li>The <code>ListHotkeys</code> command is not applicable because it only displays the hotkeys as plain text in the control window.</li>
  </ul>
  
  <p>Does anyone know how I can display a list of the hotkeys and either their corresponding arguments or comments?</p>
  
  <p><hr />
  Example script:</p>
  
  <pre><code>SomeFunc(foobar)
  {
    MsgBox %foobar%
  }
  
           !^#A::SomeFunc("a") ; blah
   ^+NumpadMult::SomeFunc("c") ; blivet
          ^+!#`::SomeFunc("b") ; baz
        ^#Space::SomeFunc("d") ; ermahgerd
   …
  </code></pre>
  
  <p>Example desired “outputs”:</p>
  
  <pre><code>C+A+  W+ A   a    | C+ S+   NumpadMult  b
  ------------------+----------------------
  C+A+S+W+ `   c    | C+   W+ Space       d
  </code></pre>
  
  <p>    or</p>
  
  <pre><code>Ctrl Alt Shift Win  Key         Action
  -----------------------------------------
   ×    ×         ×   A           blah
   ×        ×         NumpadMult  baz
   ×    ×   ×     ×   `           blivet
   ×              ×   Space       ermahgerd
  
  etc.
  </code></pre>