SHOW:
|
|
- or go back to the newest paste.
| 1 | ; Pressed keys by Michal Durak (micechal) based on Jon's On-Screen keyboard. | |
| 2 | ; | |
| 3 | ;Changelog: | |
| 4 | ;v1.1 - 30.12.12 | |
| 5 | ; * Better buttons placement | |
| 6 | ; * Narrower spacebar button | |
| 7 | ; + Added the left and right mouse buttons | |
| 8 | ; * Closing the Arrows window doesn't kill script | |
| 9 | ; * Closing windows changes positions in the Tray menu | |
| 10 | ; - Abandoned the 'Clicking' version because of AutoHotkey limits | |
| 11 | ;v1.0 - 28.12.12 | |
| 12 | ; + Initial release | |
| 13 | ||
| 14 | ||
| 15 | ||
| 16 | ||
| 17 | ;---- Configuration Section: Customize the size of the on-screen keyboard and | |
| 18 | ; other options here. | |
| 19 | ||
| 20 | ; Changing this font size will make the entire on-screen keyboard get | |
| 21 | ; larger or smaller: | |
| 22 | k_FontSize = 10 | |
| 23 | k_FontName = Verdana ; This can be blank to use the system's default font. | |
| 24 | k_FontStyle = Bold ; Example of an alternative: Italic Underline | |
| 25 | ||
| 26 | ; Names for the tray menu items: | |
| 27 | k_MenuItemHideArrows = Hide arrow keys | |
| 28 | k_MenuItemShowArrows = Show arrow keys | |
| 29 | k_MenuItemHideAll = Hide all | |
| 30 | k_MenuItemShowAll = Show all | |
| 31 | ||
| 32 | ; Background color (default is green (00FF00) for Chroma Keying in OBS) | |
| 33 | Background_color = 00FF00 | |
| 34 | ||
| 35 | ; How do you want to see pressed keys: | |
| 36 | ; Show/Hide will hide all buttons at start and then make them visible when keys are pressed on keyboard | |
| 37 | ; Enable/Disable will gray out all buttons at start and then make them normal when keys are pressed on keyboard | |
| 38 | ||
| 39 | ShowAndHide = y ;Only two options here, y - yes (will use Enable/Disable), anything else - will use Show/Hide | |
| 40 | ||
| 41 | ||
| 42 | ||
| 43 | ;---- End of configuration section. Don't change anything below this point | |
| 44 | ; unless you want to alter the basic nature of the script. | |
| 45 | ||
| 46 | if EnableAndDisable = y | |
| 47 | {
| |
| 48 | ShowOrEnable = Enable | |
| 49 | HideOrDisable = Disable | |
| 50 | } | |
| 51 | else | |
| 52 | {
| |
| 53 | ShowOrEnable = Show | |
| 54 | HideOrDisable = Hide | |
| 55 | } | |
| 56 | ||
| 57 | ||
| 58 | ;---- Alter the tray icon menu: | |
| 59 | Menu, Tray, Add, %k_MenuItemShowAll%, k_ShowAll | |
| 60 | Menu, Tray, Add, %k_MenuItemHideAll%, k_HideAll | |
| 61 | Menu, Tray, Add, %k_MenuItemHideArrows%, k_ShowHideArrows | |
| 62 | Menu, Tray, Add, &Exit, k_MenuExit | |
| 63 | Menu, Tray, NoStandard | |
| 64 | ||
| 65 | ;---- Calculate object dimensions based on chosen font size: | |
| 66 | k_KeyWidth = %k_FontSize% | |
| 67 | k_KeyWidth *= 3 | |
| 68 | k_KeyHeight = %k_FontSize% | |
| 69 | k_KeyHeight *= 3 | |
| 70 | k_KeyMargin = %k_FontSize% | |
| 71 | k_KeyMargin /= 6 | |
| 72 | k_KeyWidthHalf = %k_KeyWidth% | |
| 73 | k_KeyWidthHalf /= 2 | |
| 74 | ||
| 75 | k_KeySize = w%k_KeyWidth% h%k_KeyHeight% | |
| 76 | k_Position = x+%k_KeyMargin% %k_KeySize% | |
| 77 | ||
| 78 | ;---- Create a GUI window for the on-screen keyboard: | |
| 79 | Gui, +ToolWindow | |
| 80 | Gui, +AlwaysOnTop | |
| 81 | Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName% | |
| 82 | Gui, Color, %Background_color% | |
| 83 | ||
| 84 | ;---- Add a button for each key. Position the first button with absolute | |
| 85 | ; coordinates so that all other buttons can be positioned relative to it: | |
| 86 | ||
| 87 | ;ARROWS | |
| 88 | ; I used ULDR for arrow indicators, can change to WASD of course | |
| 89 | Gui, Add, Button, xm+%k_KeyWidth%, U ; Can change to W | |
| 90 | Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, L ; Auto-width. Can change to A | |
| 91 | Gui, Add, Button, %k_Position%, D ; Can change to S | |
| 92 | Gui, Add, Button, %k_Position%, R ; Can change to D | |
| 93 | ||
| 94 | ||
| 95 | ;---- Show the window: | |
| 96 | Gui, Show, , Arrows | |
| 97 | Control, %HideOrDisable%, , ?, Arrows | |
| 98 | Control, %HideOrDisable%, , ?, Arrows | |
| 99 | Control, %HideOrDisable%, , ?, Arrows | |
| 100 | Control, %HideOrDisable%, , ?, Arrows | |
| 101 | k_IsVisibleAll = n | |
| 102 | k_IsVisibleArrows = y | |
| 103 | ||
| 104 | ;---- When a key is pressed by the user, click the corresponding button on-screen: | |
| 105 | ||
| 106 | ||
| 107 | ;ARROWS | |
| 108 | ||
| 109 | ~*Up:: | |
| 110 | Control, %ShowOrEnable%, , U, Arrows | |
| 111 | KeyWait, Up | |
| 112 | Control, %HideOrDisable%, , U, Arrows | |
| 113 | return | |
| 114 | ||
| 115 | ~*Left:: | |
| 116 | Control, %ShowOrEnable%, , L, Arrows | |
| 117 | KeyWait, Left | |
| 118 | Control, %HideOrDisable%, , L, Arrows | |
| 119 | return | |
| 120 | ||
| 121 | ~*Down:: | |
| 122 | Control, %ShowOrEnable%, , D, Arrows | |
| 123 | KeyWait, Down | |
| 124 | Control, %HideOrDisable%, , D, Arrows | |
| 125 | return | |
| 126 | ||
| 127 | ~*Right:: | |
| 128 | Control, %ShowOrEnable%, , R, Arrows | |
| 129 | KeyWait, Right | |
| 130 | Control, %HideOrDisable%, , R, Arrows | |
| 131 | return | |
| 132 | ||
| 133 | ||
| 134 | ; ---- Tray Menu ---- | |
| 135 | ||
| 136 | ;HIDE ALL | |
| 137 | ||
| 138 | k_HideAll: | |
| 139 | Gui, Cancel | |
| 140 | if k_IsVisibleArrows = y | |
| 141 | {
| |
| 142 | Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows% | |
| 143 | k_IsVisibleArrows = n | |
| 144 | } | |
| 145 | k_IsVisibleAll = n | |
| 146 | return | |
| 147 | ||
| 148 | ;SHOW ALL | |
| 149 | ||
| 150 | k_ShowAll: | |
| 151 | if k_IsVisibleAll = n | |
| 152 | {
| |
| 153 | if k_IsVisibleArrows = n | |
| 154 | {
| |
| 155 | Gui, Show | |
| 156 | Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows% | |
| 157 | k_IsVisibleArrows = y | |
| 158 | } | |
| 159 | } | |
| 160 | return | |
| 161 | ||
| 162 | ;ARROWS | |
| 163 | ||
| 164 | k_ShowHideArrows: | |
| 165 | if k_IsVisibleArrows = y | |
| 166 | {
| |
| 167 | Gui, Cancel | |
| 168 | Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows% | |
| 169 | k_IsVisibleArrows = n | |
| 170 | k_IsVisibleAll = n | |
| 171 | } | |
| 172 | else | |
| 173 | {
| |
| 174 | Gui, Show | |
| 175 | Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows% | |
| 176 | k_IsVisibleArrows = y | |
| 177 | } | |
| 178 | return | |
| 179 | ||
| 180 | ||
| 181 | ||
| 182 | k_MenuExit: | |
| 183 | ExitApp |