Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Pressed keys by Michał Durak (micechal) based on Jon's On-Screen keyboard.
- ;
- ;Changelog:
- ;v1.0 - Initial release
- ;---- 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_MenuItemHideShift = Hide shift
- k_MenuItemShowShift = Show shift
- k_MenuItemHideSpacebar = Hide spacebar
- k_MenuItemShowSpacebar = Show spacebar
- k_MenuItemHideAll = Hide all
- k_MenuItemShowAll = Show all
- ; To have the keyboard appear on a monitor other than the primary, specify
- ; a number such as 2 for the following variable. Leave it blank to use
- ; the primary:
- k_Monitor =
- ; 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
- EnableAndDisable = n ;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, %k_MenuItemHideShift%, k_ShowHideShift
- Menu, Tray, Add, %k_MenuItemHideSpacebar%, k_ShowHideSpacebar
- 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_SpacebarWidth = %k_FontSize%
- k_SpacebarWidth *= 25
- 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, 2:+ToolWindow
- Gui, 3:+ToolWindow
- Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
- Gui, 2:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
- Gui, 3:Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
- Gui, Color, %Background_color%
- Gui, 2:Color, %Background_color%
- Gui, 3: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
- Gui, Add, Button, section %k_KeySize% xm+%k_KeyWidth%, ↑
- Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, ← ; Auto-width.
- Gui, Add, Button, %k_Position%, ↓
- Gui, Add, Button, %k_Position%, →
- ;SHIFT
- Gui, 2:Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, Shift%A_Space%%A_Space%
- ;SPACEBAR
- Gui, 3:Add, Button, h%k_KeyHeight% x+%k_KeyMargin% w%k_SpacebarWidth%, Space
- ;---- Show the window:
- Gui, Show
- WinWait, %A_ScriptName%
- WinSetTitle, Arrows
- Control, %HideOrDisable%, , ↑, Arrows
- Control, %HideOrDisable%, , ←, Arrows
- Control, %HideOrDisable%, , ↓, Arrows
- Control, %HideOrDisable%, , →, Arrows
- Gui, 2:Show
- WinWait, %A_ScriptName%
- WinSetTitle, Shift
- Control, %HideOrDisable%, , Shift, Shift
- Gui, 3:Show
- WinWait, %A_ScriptName%
- WinSetTitle, Spacebar
- Control, %HideOrDisable%, , Space, Spacebar
- k_IsVisibleAll = y
- k_IsVisibleArrows = y
- k_IsVisibleShift = y
- k_IsVisibleSpacebar = y
- ;WinGet, k_ID, ID, A ; Get its window ID.
- ;WinGetPos,,, k_WindowWidth, k_WindowHeight, A
- ;---- When a key is pressed by the user, click the corresponding button on-screen:
- ;ARROWS
- ~*Up::
- Control, %ShowOrEnable%, , ↑, Arrows
- KeyWait, Up
- Control, %HideOrDisable%, , ↑, Arrows
- return
- ~*Down::
- Control, %ShowOrEnable%, , ↓, Arrows
- KeyWait, Down
- Control, %HideOrDisable%, , ↓, Arrows
- return
- ~*Left::
- Control, %ShowOrEnable%, , ←, Arrows
- KeyWait, Left
- Control, %HideOrDisable%, , ←, Arrows
- return
- ~*Right::
- Control, %ShowOrEnable%, , →, Arrows
- KeyWait, Right
- Control, %HideOrDisable%, , →, Arrows
- return
- ;SHIFT
- ~*Shift::
- Control, %ShowOrEnable%, , Shift, Shift
- KeyWait, Shift
- Control, %HideOrDisable%, , Shift, Shift
- return
- ;SPACEBAR
- ~*Space::
- Control, %ShowOrEnable%, , Space, Spacebar
- KeyWait, Space
- Control, %HideOrDisable%, , Space, Spacebar
- return
- ; ---- Tray Menu ----
- ;HIDE ALL
- k_HideAll:
- Gui, Cancel
- Gui, 2:Cancel
- Gui, 3:Cancel
- if k_IsVisibleArrows = y
- {
- Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
- k_IsVisibleArrows = n
- }
- if k_IsVisibleShift = y
- {
- Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
- k_IsVisibleShift = n
- }
- if k_IsVisibleSpacebar = y
- {
- Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
- k_IsVisibleSpacebar = 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
- }
- if k_IsVisibleShift = n
- {
- Menu, Tray, Rename, %k_MenuItemShowShift%, %k_MenuItemHideShift%
- k_IsVisibleShift = y
- Gui, 2:Show
- }
- if k_IsVisibleSpacebar = n
- {
- Menu, Tray, Rename, %k_MenuItemShowSpacebar%, %k_MenuItemHideSpacebar%
- k_IsVisibleSpacebar = y
- Gui, 3:Show
- }
- k_IsVisibleAll = 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
- ;SHIFT
- k_ShowHideShift:
- if k_IsVisibleShift = y
- {
- Gui, 2:Cancel
- Menu, Tray, Rename, %k_MenuItemHideShift%, %k_MenuItemShowShift%
- k_IsVisibleShift = n
- k_IsVisibleAll = n
- }
- else
- {
- Gui, 2:Show
- Menu, Tray, Rename, %k_MenuItemShowShift%, %k_MenuItemHideShift%
- k_IsVisibleShift = y
- }
- return
- ;SPACEBAR
- k_ShowHideSpacebar:
- if k_IsVisibleSpacebar = y
- {
- Gui, 3:Cancel
- Menu, Tray, Rename, %k_MenuItemHideSpacebar%, %k_MenuItemShowSpacebar%
- k_IsVisibleSpacebar = n
- k_IsVisibleAll = n
- }
- else
- {
- Gui, 3:Show
- Menu, Tray, Rename, %k_MenuItemShowSpacebar%, %k_MenuItemHideSpacebar%
- k_IsVisibleSpacebar = y
- }
- return
- GuiClose:
- k_MenuExit:
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement