Advertisement
micechal_

PressedKeys v1.1

Dec 30th, 2012
2,883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Pressed keys by Michał 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_MenuItemHideShift = Hide shift
  30. k_MenuItemShowShift = Show shift
  31. k_MenuItemHideSpacebar = Hide spacebar
  32. k_MenuItemShowSpacebar = Show spacebar
  33. k_MenuItemHideAll = Hide all
  34. k_MenuItemShowAll = Show all
  35. k_MenuItemHideMouse = Hide mouse
  36. k_MenuItemShowMouse = Show mouse
  37.  
  38. ; Background color (default is green (00FF00) for Chroma Keying in OBS)
  39. Background_color = 00FF00
  40.  
  41. ; How do you want to see pressed keys:
  42. ; Show/Hide will hide all buttons at start and then make them visible when keys are pressed on keyboard
  43. ; Enable/Disable will gray out all buttons at start and then make them normal when keys are pressed on keyboard
  44.  
  45. EnableAndDisable = n      ;Only two options here, y - yes (will use Enable/Disable), anything else - will use Show/Hide
  46.  
  47.  
  48.  
  49. ;---- End of configuration section.  Don't change anything below this point
  50. ; unless you want to alter the basic nature of the script.
  51.  
  52. if EnableAndDisable = y
  53. {
  54. ShowOrEnable = Enable
  55. HideOrDisable = Disable
  56. }
  57. else
  58. {
  59. ShowOrEnable = Show
  60. HideOrDisable = Hide
  61. }
  62.  
  63.  
  64. ;---- Alter the tray icon menu:
  65. Menu, Tray, Add, %k_MenuItemShowAll%, k_ShowAll
  66. Menu, Tray, Add, %k_MenuItemHideAll%, k_HideAll
  67. Menu, Tray, Add, %k_MenuItemHideArrows%, k_ShowHideArrows
  68. Menu, Tray, Add, %k_MenuItemHideShift%, k_ShowHideShift
  69. Menu, Tray, Add, %k_MenuItemHideSpacebar%, k_ShowHideSpacebar
  70. Menu, Tray, Add, %k_MenuItemHideMouse%, k_ShowHideMouse
  71. Menu, Tray, Add, &Exit, k_MenuExit
  72. Menu, Tray, NoStandard
  73.  
  74. ;---- Calculate object dimensions based on chosen font size:
  75. k_KeyWidth = %k_FontSize%
  76. k_KeyWidth *= 3
  77. k_KeyHeight = %k_FontSize%
  78. k_KeyHeight *= 3
  79. k_KeyMargin = %k_FontSize%
  80. k_KeyMargin /= 6
  81. k_SpacebarWidth = %k_FontSize%
  82. k_SpacebarWidth *= 18
  83. k_KeyWidthHalf = %k_KeyWidth%
  84. k_KeyWidthHalf /= 2
  85.  
  86. k_KeySize = w%k_KeyWidth% h%k_KeyHeight%
  87. k_Position = x+%k_KeyMargin% %k_KeySize%
  88.  
  89. ;---- Create a GUI window for the on-screen keyboard:
  90. Gui, +ToolWindow
  91. Gui, 2:+ToolWindow
  92. Gui, 3:+ToolWindow
  93. Gui, 4:+ToolWindow
  94. Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  95. Gui, 2:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  96. Gui, 3:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  97. Gui, 4:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  98. Gui, Color, %Background_color%
  99. Gui, 2:Color, %Background_color%
  100. Gui, 3:Color, %Background_color%
  101. Gui, 4:Color, %Background_color%
  102.  
  103. ;---- Add a button for each key. Position the first button with absolute
  104. ; coordinates so that all other buttons can be positioned relative to it:
  105.  
  106. ;ARROWS
  107.  
  108. Gui, Add, Button, xm+%k_KeyWidth%,
  109. Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%,; Auto-width.
  110. Gui, Add, Button, %k_Position%,
  111. Gui, Add, Button, %k_Position%,
  112.  
  113. ;SHIFT
  114.  
  115. Gui, 2:Add, Button,, Shift%A_Space%%A_Space%
  116.  
  117. ;SPACEBAR
  118.  
  119. Gui, 3:Add, Button, w%k_SpacebarWidth%, Space
  120.  
  121. ;MOUSE
  122.  
  123. Gui, 4:Add, Button,, LMB
  124. Gui, 4:Add, Button,, RMB
  125.  
  126. ;---- Show the window:
  127. Gui, Show, , Arrows
  128. Control, %HideOrDisable%, ,, Arrows
  129. Control, %HideOrDisable%, ,, Arrows
  130. Control, %HideOrDisable%, ,, Arrows
  131. Control, %HideOrDisable%, ,, Arrows
  132. Gui, 2:Show, , Shift
  133. Control, %HideOrDisable%, , Shift, Shift
  134. Gui, 3:Show, , Spacebar
  135. Control, %HideOrDisable%, , Space, Spacebar
  136. Gui, 4:Show, , Mouse
  137. Control, %HideOrDisable%, , LMB, Mouse
  138. Control, %HideOrDisable%, , RMB, Mouse
  139. k_IsVisibleAll = y
  140. k_IsVisibleArrows = y
  141. k_IsVisibleShift = y
  142. k_IsVisibleSpacebar = y
  143. k_IsVisibleMouse = y
  144.  
  145. ;---- When a key is pressed by the user, click the corresponding button on-screen:
  146.  
  147.  
  148. ;ARROWS
  149.  
  150. ~*Up::
  151. Control, %ShowOrEnable%, ,, Arrows
  152. KeyWait, Up
  153. Control, %HideOrDisable%, ,, Arrows
  154. return
  155.  
  156. ~*Down::
  157. Control, %ShowOrEnable%, ,, Arrows
  158. KeyWait, Down
  159. Control, %HideOrDisable%, ,, Arrows
  160. return
  161.  
  162. ~*Left::
  163. Control, %ShowOrEnable%, ,, Arrows
  164. KeyWait, Left
  165. Control, %HideOrDisable%, ,, Arrows
  166. return
  167.  
  168. ~*Right::
  169. Control, %ShowOrEnable%, ,, Arrows
  170. KeyWait, Right
  171. Control, %HideOrDisable%, ,, Arrows
  172. return
  173.  
  174.  
  175. ;SHIFT
  176.  
  177. ~*Shift::
  178. Control, %ShowOrEnable%, , Shift, Shift
  179. KeyWait, Shift
  180. Control, %HideOrDisable%, , Shift, Shift
  181. return
  182.  
  183.  
  184. ;SPACEBAR
  185.  
  186. ~*Space::
  187. Control, %ShowOrEnable%, , Space, Spacebar
  188. KeyWait, Space
  189. Control, %HideOrDisable%, , Space, Spacebar
  190. return
  191.  
  192. ;MOUSE
  193.  
  194. ~*LButton::
  195. Control, %ShowOrEnable%, , LMB, Mouse
  196. KeyWait, LButton
  197. Control, %HideOrDisable%, , LMB, Mouse
  198. return
  199.  
  200. ~*RButton::
  201. Control, %ShowOrEnable%, , RMB, Mouse
  202. KeyWait, RButton
  203. Control, %HideOrDisable%, , RMB, Mouse
  204. return
  205.  
  206.  
  207. ; ---- Tray Menu ----
  208.  
  209. ;HIDE ALL
  210.  
  211. k_HideAll:
  212. Gui, Cancel
  213. Gui, 2:Cancel
  214. Gui, 3:Cancel
  215. Gui, 4:Cancel
  216. if k_IsVisibleArrows = y
  217. {
  218. Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  219. k_IsVisibleArrows = n
  220. }
  221. if k_IsVisibleShift = y
  222. {
  223. Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
  224. k_IsVisibleShift = n
  225. }
  226. if k_IsVisibleSpacebar = y
  227. {
  228. Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
  229. k_IsVisibleSpacebar = n
  230. }
  231. if k_IsVisibleMouse = y
  232. {
  233. Menu, Tray, Rename, %k_MenuItemHideMouse%, %k_MenuItemShowMouse%
  234. k_IsVisibleMouse = n
  235. }
  236. k_IsVisibleAll = n
  237. return
  238.  
  239. ;SHOW ALL
  240.  
  241. k_ShowAll:
  242. if k_IsVisibleAll = n
  243.   {
  244.     if k_IsVisibleArrows = n
  245.     {
  246.     Gui, Show
  247.     Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
  248.     k_IsVisibleArrows = y
  249.     }
  250.     if k_IsVisibleShift = n
  251.     {
  252.     Menu, Tray, Rename, %k_MenuItemShowShift%, %k_MenuItemHideShift%
  253.     k_IsVisibleShift = y
  254.     Gui, 2:Show
  255.     }
  256.     if k_IsVisibleSpacebar = n
  257.     {
  258.     Menu, Tray, Rename, %k_MenuItemShowSpacebar%, %k_MenuItemHideSpacebar%
  259.     k_IsVisibleSpacebar = y
  260.     Gui, 3:Show
  261.     }
  262.     if k_IsVisibleMouse = n
  263.     {
  264.     Menu, Tray, Rename, %k_MenuItemShowMouse%, %k_MenuItemHideMouse%
  265.     k_IsVisibleMouse = y
  266.     Gui, 4:Show
  267.     }
  268.     k_IsVisibleAll = y
  269.     }
  270. return
  271.  
  272. ;ARROWS
  273.  
  274. k_ShowHideArrows:
  275. if k_IsVisibleArrows = y
  276. {
  277.     Gui, Cancel
  278.     Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  279.     k_IsVisibleArrows = n
  280.     k_IsVisibleAll = n
  281. }
  282. else
  283. {
  284.     Gui, Show
  285.     Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
  286.     k_IsVisibleArrows = y
  287. }
  288. return
  289.  
  290. ;SHIFT
  291.  
  292. k_ShowHideShift:
  293. if k_IsVisibleShift = y
  294. {
  295.     Gui, 2:Cancel
  296.     Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
  297.     k_IsVisibleShift = n
  298.     k_IsVisibleAll = n
  299. }
  300. else
  301. {
  302.     Gui, 2:Show
  303.     Menu, Tray, Rename, %k_MenuItemShowShift%, %k_MenuItemHideShift%
  304.     k_IsVisibleShift = y
  305. }
  306. return
  307.  
  308. ;SPACEBAR
  309.  
  310. k_ShowHideSpacebar:
  311. if k_IsVisibleSpacebar = y
  312. {
  313.     Gui, 3:Cancel
  314.     Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
  315.     k_IsVisibleSpacebar = n
  316.     k_IsVisibleAll = n
  317. }
  318. else
  319. {
  320.     Gui, 3:Show
  321.     Menu, Tray, Rename, %k_MenuItemShowSpacebar%, %k_MenuItemHideSpacebar%
  322.     k_IsVisibleSpacebar = y
  323. }
  324. return
  325.  
  326. ;MOUSE
  327.  
  328. k_ShowHideMouse:
  329. if k_IsVisibleMouse = y
  330. {
  331.     Gui, 4:Cancel
  332.     Menu, Tray, Rename, %k_MenuItemHideMouse%, %k_MenuItemShowMouse%
  333.     k_IsVisibleMouse = n
  334.     k_IsVisibleAll = n
  335. }
  336. else
  337. {
  338.     Gui, 4:Show
  339.     Menu, Tray, Rename, %k_MenuItemShowMouse%, %k_MenuItemHideMouse%
  340.     k_IsVisibleMouse = y
  341. }
  342. return
  343.  
  344.  
  345. GuiClose:
  346. Gui, Cancel
  347. Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  348. k_IsVisibleArrows = n
  349. k_IsVisibleAll = n
  350. return
  351.  
  352. 2GuiClose:
  353. Gui, 2:Cancel
  354. Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
  355. k_IsVisibleShift = n
  356. k_IsVisibleAll = n
  357. return
  358.  
  359. 3GuiClose:
  360. Gui, 3:Cancel
  361. Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
  362. k_IsVisibleSpacebar = n
  363. k_IsVisibleAll = n
  364. return
  365.  
  366. 4GuiClose:
  367. Gui, 4:Cancel
  368. Menu, Tray, Rename, %k_MenuItemHideMouse%, %k_MenuItemShowMouse%
  369. k_IsVisibleMouse = n
  370. k_IsVisibleAll = n
  371. return
  372.  
  373. k_MenuExit:
  374. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement