Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Pressed keys by Michal Durak (micechal) based on Jon's On-Screen keyboard.
- ;
- ;Changelog:
- ;v1.1 - 30.12.12
- ; * Better buttons placement
- ; * Narrower spacebar button
- ; + Added the left and right mouse buttons
- ; * Closing the Arrows window doesn't kill script
- ; * Closing windows changes positions in the Tray menu
- ; - Abandoned the 'Clicking' version because of AutoHotkey limits
- ;v1.0 - 28.12.12
- ; + Initial release
- ; Forcing single instance so if the window gets lots you can restart it by running the script again. No warning about existing window.
- #SingleInstance force
- ;---- Configuration Section: Customize the size of the on-screen keyboard and
- ; other options here.
- ; Changing this font size will make the entire on-screen keyboard get
- ; larger or smaller:
- k_FontSize = 10
- k_FontName = Verdana ; This can be blank to use the system's default font.
- k_FontStyle = Bold ; Example of an alternative: Italic Underline
- ; Names for the tray menu items:
- k_MenuItemHideArrows = Hide arrow keys
- k_MenuItemShowArrows = Show arrow keys
- k_MenuItemHideAll = Hide all
- k_MenuItemShowAll = Show all
- ; Background color (default is green (00FF00) for Chroma Keying in OBS)
- Background_color = 00FF00
- ; How do you want to see pressed keys:
- ; Show/Hide will hide all buttons at start and then make them visible when keys are pressed on keyboard
- ; Enable/Disable will gray out all buttons at start and then make them normal when keys are pressed on keyboard
- ShowAndHide = y ;Only two options here, y - yes (will use Enable/Disable), anything else - will use Show/Hide
- ;---- End of configuration section. Don't change anything below this point
- ; unless you want to alter the basic nature of the script.
- if EnableAndDisable = y
- {
- ShowOrEnable = Enable
- HideOrDisable = Disable
- }
- else
- {
- ShowOrEnable = Show
- HideOrDisable = Hide
- }
- ;---- Alter the tray icon menu:
- Menu, Tray, Add, %k_MenuItemShowAll%, k_ShowAll
- Menu, Tray, Add, %k_MenuItemHideAll%, k_HideAll
- Menu, Tray, Add, %k_MenuItemHideArrows%, k_ShowHideArrows
- Menu, Tray, Add, &Exit, k_MenuExit
- Menu, Tray, NoStandard
- ;---- Calculate object dimensions based on chosen font size:
- k_KeyWidth = %k_FontSize%
- k_KeyWidth *= 3
- k_KeyHeight = %k_FontSize%
- k_KeyHeight *= 3
- k_KeyMargin = %k_FontSize%
- k_KeyMargin /= 6
- k_KeyWidthHalf = %k_KeyWidth%
- k_KeyWidthHalf /= 2
- k_KeySize = w%k_KeyWidth% h%k_KeyHeight%
- k_Position = x+%k_KeyMargin% %k_KeySize%
- ;---- Create a GUI window for the on-screen keyboard:
- Gui, +ToolWindow
- Gui, +AlwaysOnTop
- Gui, +SysMenu
- Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
- Gui, Color, %Background_color%
- ;---- Add a button for each key. Position the first button with absolute
- ; coordinates so that all other buttons can be positioned relative to it:
- ;ARROWS
- ; I used ULDR for arrow indicators, can change to WASD of course
- Gui, Add, Button, xm+%k_KeyWidth%, U ; Can change to W
- Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, L ; Auto-width. Can change to A
- Gui, Add, Button, %k_Position%, D ; Can change to S
- Gui, Add, Button, %k_Position%, R ; Can change to D
- ;---- Show the window:
- Gui, Show, , Arrows
- Control, %HideOrDisable%, , ?, Arrows
- Control, %HideOrDisable%, , ?, Arrows
- Control, %HideOrDisable%, , ?, Arrows
- Control, %HideOrDisable%, , ?, Arrows
- k_IsVisibleAll = n
- k_IsVisibleArrows = y
- ;---- When a key is pressed by the user, click the corresponding button on-screen:
- ;ARROWS
- ~*Up::
- Control, %ShowOrEnable%, , U, Arrows
- KeyWait, Up
- Control, %HideOrDisable%, , U, Arrows
- return
- ~*Left::
- Control, %ShowOrEnable%, , L, Arrows
- KeyWait, Left
- Control, %HideOrDisable%, , L, Arrows
- return
- ~*Down::
- Control, %ShowOrEnable%, , D, Arrows
- KeyWait, Down
- Control, %HideOrDisable%, , D, Arrows
- return
- ~*Right::
- Control, %ShowOrEnable%, , R, Arrows
- KeyWait, Right
- Control, %HideOrDisable%, , R, Arrows
- return
- ; ---- Tray Menu ----
- ;HIDE ALL
- k_HideAll:
- Gui, Cancel
- if k_IsVisibleArrows = y
- {
- Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
- k_IsVisibleArrows = n
- }
- k_IsVisibleAll = n
- return
- ;SHOW ALL
- k_ShowAll:
- if k_IsVisibleAll = n
- {
- if k_IsVisibleArrows = n
- {
- Gui, Show
- Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
- k_IsVisibleArrows = y
- }
- }
- return
- ;ARROWS
- k_ShowHideArrows:
- if k_IsVisibleArrows = y
- {
- Gui, Cancel
- Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
- k_IsVisibleArrows = n
- k_IsVisibleAll = n
- }
- else
- {
- Gui, Show
- Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
- k_IsVisibleArrows = y
- }
- return
- k_MenuExit:
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment