PageRenderTime 61ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/HotkeyFeatures.htm

http://github.com/Lexikos/AutoHotkey_L-Docs
HTML | 102 lines | 83 code | 19 blank | 0 comment | 0 complexity | 14d123638d9c244ce0c7868d400492ee MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <title>Advanced Hotkey Features | AutoHotkey</title>
  5. <meta name="description" content="Learn advanced hotkey features such as using any keys as modifiers or automating game actions on the screen." />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <link href="static/theme.css" rel="stylesheet" type="text/css" />
  9. <script src="static/content.js" type="text/javascript"></script>
  10. </head>
  11. <body>
  12. <h1>Advanced Hotkey Features</h1>
  13. <h2 id="toc">Table of Contents</h2>
  14. <ul>
  15. <li><a href="#general">General</a>
  16. <ul>
  17. <li><a href="#easy-to-reach">Remap easy to reach but rarely used keys</a></li>
  18. <li><a href="#keys-as-modifiers">Use any keys as modifiers</a></li>
  19. <li><a href="#AltTab">Make the mouse wheel perform alt-tabbing</a></li>
  20. <li><a href="#keyboard-to-mouse">Make a keyboard key become a mouse button</a></li>
  21. <li><a href="#context-sensitive">Make your hotkeys context-sensitive</a></li>
  22. <li><a href="#hotstrings">Define abbreviations that expand as you type them</a></li>
  23. </ul>
  24. </li>
  25. <li><a href="#gaming">Gaming</a>
  26. <ul>
  27. <li><a href="#wear-and-tear">Reduce wear and tear on your fingers</a></li>
  28. <li><a href="#mouse-hotkeys">Create mouse hotkeys</a></li>
  29. <li><a href="#pass-through">Create "pass-through" hotkeys</a></li>
  30. <li><a href="#game-actions">Automate game actions on the screen</a></li>
  31. <li><a href="#keyboard-hook">Use the keyboard hook</a></li>
  32. </ul>
  33. </li>
  34. <li><a href="#related">Related Topics</a></li>
  35. </ul>
  36. <h2 id="general">General</h2>
  37. <h3 id="easy-to-reach">Remap easy to reach but rarely used keys</h3>
  38. <p>Some of the easiest keys to reach on the keyboard are also the least frequently used. Make these keys do something useful! For example, if you rarely use the right <kbd>Alt</kbd> key, make it perform the action you do most often:</p>
  39. <pre>RAlt::
  40. MsgBox You pressed the right ALT key.
  41. return</pre>
  42. <p>You can even do the above without losing the native function of the right <kbd>Alt</kbd> key by assigning the right <kbd>Alt</kbd> key to be a &quot;prefix&quot; for at least one other hotkey. In the below example, the right <kbd>Alt</kbd> has become a prefix, which automatically allows it to modify <strong>all</strong> other keys as it normally would. But if you press and release the right <kbd>Alt</kbd> key without having used it to modify another key, its hotkey action (above) will take effect immediately:</p>
  43. <pre>RAlt &amp; j::AltTab</pre>
  44. <h3 id="keys-as-modifiers">Use any keys as modifiers</h3>
  45. <p>Don't be limited to using only <kbd>Ctrl</kbd>, <kbd>Alt</kbd>, <kbd>Shift</kbd>, and <kbd>Win</kbd> as modifiers; you can combine <strong>any</strong> two keys or mouse buttons to form a custom hotkey. For example: Hold down Numpad0 and press Numpad1 to launch a hotkey (<code>Numpad0 &amp; Numpad1::</code>); hold down <kbd>CapsLock</kbd> and press another key, or click a mouse button (<code>CapsLock &amp; RButton::</code>). In this case, the <kbd>CapsLock</kbd> key's state (on or off) is not changed when it is used to launch the hotkey. For details, see <a href="Hotkeys.htm#combo">custom combinations of keys</a>.</p>
  46. <h3 id="AltTab">Make the mouse wheel perform alt-tabbing</h3>
  47. <p>Convert the mouse wheel (or any other keys of your choice) into a complete substitute for Alt-Tab. Click the wheel to show or hide the menu, and turn it to navigate through the menu. The wheel will still function normally whenever the Alt-Tab menu isn't visible. Syntax:</p>
  48. <pre>MButton::AltTabMenu
  49. WheelDown::AltTab
  50. WheelUp::ShiftAltTab</pre>
  51. <h3 id="keyboard-to-mouse">Make a keyboard key become a mouse button</h3>
  52. <p>Make a keyboard key <strong>become</strong> a mouse button, or have an action repeated continuously while you're holding down a key or mouse button. See the <a href="misc/Remap.htm#RemapMouse">remapping page</a> for examples.</p>
  53. <h3 id="context-sensitive">Make your hotkeys context-sensitive</h3>
  54. <p>Have your easiest-to-reach hotkeys perform an action appropriate to the type of window you're working with. In the following example, the right <kbd>Ctrl</kbd> key performs a different action depending on whether Notepad or Calculator is the active window:</p>
  55. <pre>#IfWinActive ahk_class Notepad
  56. RControl::WinMenuSelectItem, , , File, Save <em>; Save the current file in Notepad.</em>
  57. #IfWinActive Calculator
  58. RControl::Send, ^c!{tab}^v <em>; Copy the Calculator's result into the previously active window.</em></pre>
  59. <p>See <a href="commands/_IfWinActive.htm">#IfWinActive</a> for details.</p>
  60. <h3 id="hotstrings">Define abbreviations that expand as you type them</h3>
  61. <p>Also known as <a href="Hotstrings.htm">hotstrings</a>. No special training or scripting experience is needed. For example, a script containing the following lines would expand ceo, cfo, and btw wherever you type them:</p>
  62. <pre>::ceo::Chief Executive Officer
  63. ::cfo::Chief Financial Officer
  64. ::btw::by the way</pre>
  65. <h2 id="gaming">Gaming</h2>
  66. <h3 id="wear-and-tear">Reduce wear and tear on your fingers</h3>
  67. <p>Reduce wear and tear on your fingers by using virtually <a href="KeyList.htm">any key</a> as a hotkey, including single letters, arrow keys, Numpad keys, and even the modifier keys themselves (<kbd>Ctrl</kbd>/<kbd>Alt</kbd>/<kbd>Win</kbd>/<kbd>Shift</kbd>).</p>
  68. <h3 id="mouse-hotkeys">Create mouse hotkeys</h3>
  69. <p>Create mouse hotkeys, including the mouse wheel button (MButton) and the turning of the wheel up/down or left/right (WheelUp, WheelDown, WheelLeft, and WheelRight). You can also combine a keyboard key with a mouse button. For example, control-right-button would be expressed as <code>^RButton::</code>.</p>
  70. <h3 id="pass-through">Create "pass-through" hotkeys</h3>
  71. <p>For example, the left mouse button can trigger a hotkey action even while the click itself is being sent into the game normally (syntax: <code>~LButton::</code>).</p>
  72. <h3 id="game-actions">Automate game actions on the screen</h3>
  73. <p>Use commands such as <a href="commands/PixelSearch.htm">PixelSearch</a>, <a href="commands/PixelGetColor.htm">PixelGetColor</a>, and <a href="commands/ImageSearch.htm">ImageSearch</a> to automate game actions.</p>
  74. <h3 id="keyboard-hook">Use the keyboard hook</h3>
  75. <p>Have the option of using the <a href="commands/_UseHook.htm">keyboard hook</a> to implement hotkeys, which might be more responsive than other hotkey methods while the CPU is under load in a game. The hook might also be able to override any restrictions a game may have about which keys can be &quot;mapped&quot; to game actions.</p>
  76. <h2 id="related">Related Topics</h2>
  77. <ul>
  78. <li><a href="Hotkeys.htm">Hotkeys</a></li>
  79. <li><a href="Hotstrings.htm">Hotstrings</a></li>
  80. <li><a href="misc/Remap.htm">Remapping Keys</a></li>
  81. </ul>
  82. </body>
  83. </html>