Guest User

TP KeyPress

a guest
May 24th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
  81. Gui, Color, %Background_color%
  82.  
  83. ;---- Add a button for each key. Position the first button with absolute
  84. ; coordinates so that all other buttons can be positioned relative to it:
  85.  
  86. ;ARROWS
  87. ; I used ULDR for arrow indicators, can change to WASD of course
  88. Gui, Add, Button, xm+%k_KeyWidth%, U   ; Can change to W
  89. Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, L ; Auto-width.    Can change to A
  90. Gui, Add, Button, %k_Position%, D   ; Can change to S
  91. Gui, Add, Button, %k_Position%, R   ; Can change to D
  92.  
  93.  
  94. ;---- Show the window:
  95. Gui, Show, , Arrows
  96. Control, %HideOrDisable%, , ?, Arrows
  97. Control, %HideOrDisable%, , ?, Arrows
  98. Control, %HideOrDisable%, , ?, Arrows
  99. Control, %HideOrDisable%, , ?, Arrows
  100. k_IsVisibleAll = n
  101. k_IsVisibleArrows = y
  102.  
  103. ;---- When a key is pressed by the user, click the corresponding button on-screen:
  104.  
  105.  
  106. ;ARROWS
  107.  
  108. ~*Up::
  109. Control, %ShowOrEnable%, , U, Arrows
  110. KeyWait, Up
  111. Control, %HideOrDisable%, , U, Arrows
  112. return
  113.  
  114. ~*Left::
  115. Control, %ShowOrEnable%, , L, Arrows
  116. KeyWait, Left
  117. Control, %HideOrDisable%, , L, Arrows
  118. return
  119.  
  120. ~*Down::
  121. Control, %ShowOrEnable%, , D, Arrows
  122. KeyWait, Down
  123. Control, %HideOrDisable%, , D, Arrows
  124. return
  125.  
  126. ~*Right::
  127. Control, %ShowOrEnable%, , R, Arrows
  128. KeyWait, Right
  129. Control, %HideOrDisable%, , R, Arrows
  130. return
  131.  
  132.  
  133. ; ---- Tray Menu ----
  134.  
  135. ;HIDE ALL
  136.  
  137. k_HideAll:
  138. Gui, Cancel
  139. if k_IsVisibleArrows = y
  140. {
  141. Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  142. k_IsVisibleArrows = n
  143. }
  144. k_IsVisibleAll = n
  145. return
  146.  
  147. ;SHOW ALL
  148.  
  149. k_ShowAll:
  150. if k_IsVisibleAll = n
  151.   {
  152.     if k_IsVisibleArrows = n
  153.     {
  154.     Gui, Show
  155.     Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
  156.     k_IsVisibleArrows = y
  157.     }
  158. }
  159. return
  160.  
  161. ;ARROWS
  162.  
  163. k_ShowHideArrows:
  164. if k_IsVisibleArrows = y
  165. {
  166.     Gui, Cancel
  167.     Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
  168.     k_IsVisibleArrows = n
  169.     k_IsVisibleAll = n
  170. }
  171. else
  172. {
  173.     Gui, Show
  174.     Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
  175.     k_IsVisibleArrows = y
  176. }
  177. return
  178.  
  179.  
  180.  
  181. k_MenuExit:
  182. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment