Advertisement
Guest User

PressedKeys - Clicking

a guest
Dec 28th, 2012
492
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.0 - Initial release
  5.  
  6.  
  7.  
  8.  
  9. ;---- Configuration Section: Customize the size of the on-screen keyboard and
  10. ; other options here.
  11.  
  12. ; Changing this font size will make the entire on-screen keyboard get
  13. ; larger or smaller:
  14. k_FontSize = 10
  15. k_FontName = Verdana  ; This can be blank to use the system's default font.
  16. k_FontStyle = Bold    ; Example of an alternative: Italic Underline
  17.  
  18. ; Names for the tray menu items:
  19. k_MenuItemHideArrows = Hide arrow keys
  20. k_MenuItemShowArrows = Show arrow keys
  21. k_MenuItemHideShift = Hide shift
  22. k_MenuItemShowShift = Show shift
  23. k_MenuItemHideSpacebar = Hide spacebar
  24. k_MenuItemShowSpacebar = Show spacebar
  25. k_MenuItemHideAll = Hide all
  26. k_MenuItemShowAll = Show all
  27.  
  28. ; To have the keyboard appear on a monitor other than the primary, specify
  29. ; a number such as 2 for the following variable.  Leave it blank to use
  30. ; the primary:
  31. k_Monitor =
  32.  
  33. ; Background color (default is green (00FF00) for Chroma Keying in OBS)
  34. Background_color = 00FF00
  35.  
  36. ; How do you want to see pressed keys:
  37. ; Show/Hide will hide all buttons at start and then make them visible when keys are pressed on keyboard
  38. ; Enable/Disable will gray out all buttons at start and then make them normal when keys are pressed on keyboard
  39.  
  40.  
  41. ;---- End of configuration section.  Don't change anything below this point
  42. ; unless you want to alter the basic nature of the script.
  43.  
  44.  
  45. ;---- Alter the tray icon menu:
  46. Menu, Tray, Add, %k_MenuItemShowAll%, k_ShowAll
  47. Menu, Tray, Add, %k_MenuItemHideAll%, k_HideAll
  48. Menu, Tray, Add, %k_MenuItemHideArrows%, k_ShowHideArrows
  49. Menu, Tray, Add, %k_MenuItemHideShift%, k_ShowHideShift
  50. Menu, Tray, Add, %k_MenuItemHideSpacebar%, k_ShowHideSpacebar
  51. Menu, Tray, Add, &Exit, k_MenuExit
  52. Menu, Tray, NoStandard
  53.  
  54. ;---- Calculate object dimensions based on chosen font size:
  55. k_KeyWidth = %k_FontSize%
  56. k_KeyWidth *= 3
  57. k_KeyHeight = %k_FontSize%
  58. k_KeyHeight *= 3
  59. k_KeyMargin = %k_FontSize%
  60. k_KeyMargin /= 6
  61. k_SpacebarWidth = %k_FontSize%
  62. k_SpacebarWidth *= 25
  63. k_KeyWidthHalf = %k_KeyWidth%
  64. k_KeyWidthHalf /= 2
  65.  
  66. k_KeySize = w%k_KeyWidth% h%k_KeyHeight%
  67. k_Position = x+%k_KeyMargin% %k_KeySize%
  68.  
  69. ;---- Create a GUI window for the on-screen keyboard:
  70. Gui, +ToolWindow
  71. Gui, 2:+ToolWindow
  72. Gui, 3:+ToolWindow
  73. Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  74. Gui, 2:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  75. Gui, 3:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  76. Gui, Color, %Background_color%
  77. Gui, 2:Color, %Background_color%
  78. Gui, 3:Color, %Background_color%
  79.  
  80. ;---- Add a button for each key. Position the first button with absolute
  81. ; coordinates so that all other buttons can be positioned relative to it:
  82.  
  83. ;ARROWS
  84.  
  85. Gui, Add, Button, section %k_KeySize% xm+%k_KeyWidth%,
  86. Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%,; Auto-width.
  87. Gui, Add, Button, %k_Position%,
  88. Gui, Add, Button, %k_Position%,
  89.  
  90. ;SHIFT
  91.  
  92. Gui, 2:Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, Shift%A_Space%%A_Space%
  93.  
  94. ;SPACEBAR
  95.  
  96. Gui, 3:Add, Button, h%k_KeyHeight% x+%k_KeyMargin% w%k_SpacebarWidth%, Space
  97.  
  98. ;---- Show the window:
  99. Gui, Show
  100. WinWait, %A_ScriptName%
  101. WinSetTitle, Arrows
  102. Gui, 2:Show
  103. WinWait, %A_ScriptName%
  104. WinSetTitle, Shift
  105. Gui, 3:Show
  106. WinWait, %A_ScriptName%
  107. WinSetTitle, Spacebar
  108. k_IsVisibleAll = y
  109. k_IsVisibleArrows = y
  110. k_IsVisibleShift = y
  111. k_IsVisibleSpacebar = y
  112.  
  113. ;WinGet, k_ID, ID, A   ; Get its window ID.
  114. ;WinGetPos,,, k_WindowWidth, k_WindowHeight, A
  115.  
  116. ;---- When a key is pressed by the user, click the corresponding button on-screen:
  117.  
  118.  
  119. ;ARROWS
  120.  
  121. ~*Up::
  122. ControlClick,, Arrows, , , 1, D
  123. KeyWait, Up
  124. ControlClick,, Arrows, , , 1, U
  125. return
  126.  
  127. ~*Down::
  128. ControlClick,, Arrows, , , 1, D
  129. KeyWait, Down
  130. ControlClick,, Arrows, , , 1, U
  131. return
  132.  
  133. ~*Left::
  134. ControlClick,, Arrows, , , 1, D
  135. KeyWait, Left
  136. ControlClick,, Arrows, , , 1, U
  137. return
  138.  
  139. ~*Right::
  140. ControlClick,, Arrows, , , 1, D
  141. KeyWait, Right
  142. ControlClick,, Arrows, , , 1, U
  143. return
  144.  
  145.  
  146. ;SHIFT
  147.  
  148. ~*Shift::
  149. ControlClick, Shift, Shift, , , 1, D
  150. KeyWait, Shift
  151. ControlClick, Shift, Shift, , , 1, U
  152. return
  153.  
  154.  
  155. ;SPACEBAR
  156.  
  157. ~*Space::
  158. ControlClick, Space, Spacebar, , , 1, D
  159. KeyWait, Space
  160. ControlClick, Space, Spacebar, , , 1, U
  161. return
  162.  
  163.  
  164. ; ---- Tray Menu ----
  165.  
  166. ;HIDE ALL
  167.  
  168. k_HideAll:
  169. Gui, Cancel
  170. Gui, 2:Cancel
  171. Gui, 3:Cancel
  172. if k_IsVisibleArrows = y
  173. {
  174. Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  175. k_IsVisibleArrows = n
  176. }
  177. if k_IsVisibleShift = y
  178. {
  179. Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
  180. k_IsVisibleShift = n
  181. }
  182. if k_IsVisibleSpacebar = y
  183. {
  184. Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
  185. k_IsVisibleSpacebar = n
  186. }
  187. k_IsVisibleAll = n
  188. return
  189.  
  190. ;SHOW ALL
  191.  
  192. k_ShowAll:
  193. if k_IsVisibleAll = n
  194.   {
  195.     if k_IsVisibleArrows = n
  196.     {
  197.     Gui, Show
  198.     Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
  199.     k_IsVisibleArrows = y
  200.     }
  201.     if k_IsVisibleShift = n
  202.     {
  203.     Menu, Tray, Rename, %k_MenuItemShowShift%, %k_MenuItemHideShift%
  204.     k_IsVisibleShift = y
  205.     Gui, 2:Show
  206.     }
  207.     if k_IsVisibleSpacebar = n
  208.     {
  209.     Menu, Tray, Rename, %k_MenuItemShowSpacebar%, %k_MenuItemHideSpacebar%
  210.     k_IsVisibleSpacebar = y
  211.     Gui, 3:Show
  212.     }
  213.     k_IsVisibleAll = y
  214.     }
  215. return
  216.  
  217. ;ARROWS
  218.  
  219. k_ShowHideArrows:
  220. if k_IsVisibleArrows = y
  221. {
  222.     Gui, Cancel
  223.     Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  224.     k_IsVisibleArrows = n
  225.     k_IsVisibleAll = n
  226. }
  227. else
  228. {
  229.     Gui, Show
  230.     Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
  231.     k_IsVisibleArrows = y
  232. }
  233. return
  234.  
  235. ;SHIFT
  236.  
  237. k_ShowHideShift:
  238. if k_IsVisibleShift = y
  239. {
  240.     Gui, 2:Cancel
  241.     Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
  242.     k_IsVisibleShift = n
  243.     k_IsVisibleAll = n
  244. }
  245. else
  246. {
  247.     Gui, 2:Show
  248.     Menu, Tray, Rename, %k_MenuItemShowShift%, %k_MenuItemHideShift%
  249.     k_IsVisibleShift = y
  250. }
  251. return
  252.  
  253. ;SPACEBAR
  254.  
  255. k_ShowHideSpacebar:
  256. if k_IsVisibleSpacebar = y
  257. {
  258.     Gui, 3:Cancel
  259.     Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
  260.     k_IsVisibleSpacebar = n
  261.     k_IsVisibleAll = n
  262. }
  263. else
  264. {
  265.     Gui, 3:Show
  266.     Menu, Tray, Rename, %k_MenuItemShowSpacebar%, %k_MenuItemHideSpacebar%
  267.     k_IsVisibleSpacebar = y
  268. }
  269. return
  270.  
  271. GuiClose:
  272. k_MenuExit:
  273. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement