View difference between Paste ID: JnJhQn3s and XsZdwwve
SHOW: | | - or go back to the newest paste.
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
; Forcing single instance so if the window gets lots you can restart it by running the script again.  No warning about existing window.
15
#SingleInstance force
16
17
18
;---- Configuration Section: Customize the size of the on-screen keyboard and
19
; other options here.
20
21
; Changing this font size will make the entire on-screen keyboard get
22
; larger or smaller:
23
k_FontSize = 10
24
k_FontName = Verdana  ; This can be blank to use the system's default font.
25
k_FontStyle = Bold    ; Example of an alternative: Italic Underline
26
27
; Names for the tray menu items:
28
k_MenuItemHideArrows = Hide arrow keys
29
k_MenuItemShowArrows = Show arrow keys
30
k_MenuItemHideAll = Hide all
31
k_MenuItemShowAll = Show all
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
ShowAndHide = y    ;Only two options here, y - yes (will use Enable/Disable), anything else - will use Show/Hide
41
42
43
44
;---- End of configuration section.  Don't change anything below this point
45
; unless you want to alter the basic nature of the script.
46
47
if EnableAndDisable = y
48
{
49
ShowOrEnable = Enable
50
HideOrDisable = Disable
51
}
52
else
53
{
54
ShowOrEnable = Show
55
HideOrDisable = Hide
56
}
57
58
59
;---- Alter the tray icon menu:
60
Menu, Tray, Add, %k_MenuItemShowAll%, k_ShowAll
61
Menu, Tray, Add, %k_MenuItemHideAll%, k_HideAll
62
Menu, Tray, Add, %k_MenuItemHideArrows%, k_ShowHideArrows
63
Menu, Tray, Add, &Exit, k_MenuExit
64
Menu, Tray, NoStandard
65
66
;---- Calculate object dimensions based on chosen font size:
67
k_KeyWidth = %k_FontSize% 
68
k_KeyWidth *= 3
69
k_KeyHeight = %k_FontSize%
70
k_KeyHeight *= 3
71
k_KeyMargin = %k_FontSize%
72
k_KeyMargin /= 6
73
k_KeyWidthHalf = %k_KeyWidth%
74
k_KeyWidthHalf /= 2
75
76
k_KeySize = w%k_KeyWidth% h%k_KeyHeight%
77
k_Position = x+%k_KeyMargin% %k_KeySize%
78
79
;---- Create a GUI window for the on-screen keyboard:
80
Gui, +ToolWindow
81
Gui, +AlwaysOnTop
82
Gui, +SysMenu
83
Gui, Font, s%k_FontSize% %k_FontStyle%, %k_FontName%
84
Gui, Color, %Background_color%
85
86
87
;---- Add a button for each key. Position the first button with absolute
88
; coordinates so that all other buttons can be positioned relative to it:
89
90
;ARROWS
91
; I used ULDR for arrow indicators, can change to WASD of course
92
Gui, Add, Button, xm+%k_KeyWidth%, U   ; Can change to W
93
Gui, Add, Button, xm y+%k_KeyMargin% h%k_KeyHeight%, L ; Auto-width.    Can change to A
94
Gui, Add, Button, %k_Position%, D   ; Can change to S
95
Gui, Add, Button, %k_Position%, R   ; Can change to D
96
97
98
;---- Show the window:
99
Gui, Show, , Arrows
100
Control, %HideOrDisable%, , ?, Arrows
101
Control, %HideOrDisable%, , ?, Arrows
102
Control, %HideOrDisable%, , ?, Arrows
103
Control, %HideOrDisable%, , ?, Arrows
104
k_IsVisibleAll = n
105
k_IsVisibleArrows = y
106
107
;---- When a key is pressed by the user, click the corresponding button on-screen:
108
109
110
;ARROWS
111
112
~*Up::
113
Control, %ShowOrEnable%, , U, Arrows
114
KeyWait, Up
115
Control, %HideOrDisable%, , U, Arrows
116
return
117
118
~*Left::
119
Control, %ShowOrEnable%, , L, Arrows
120
KeyWait, Left
121
Control, %HideOrDisable%, , L, Arrows
122
return
123
124
~*Down::
125
Control, %ShowOrEnable%, , D, Arrows
126
127
KeyWait, Down
128
Control, %HideOrDisable%, , D, Arrows
129
130
return
131
132
~*Right::
133
Control, %ShowOrEnable%, , R, Arrows
134
135
KeyWait, Right
136
Control, %HideOrDisable%, , R, Arrows
137
138
return
139
140
141
; ---- Tray Menu ----
142
143
;HIDE ALL
144
145
k_HideAll:
146
Gui, Cancel
147
if k_IsVisibleArrows = y
148
{
149
Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
150
k_IsVisibleArrows = n
151
}
152
k_IsVisibleAll = n
153
return
154
155
;SHOW ALL
156
157
k_ShowAll:
158
if k_IsVisibleAll = n
159
  {
160
	if k_IsVisibleArrows = n
161
	{
162
	Gui, Show
163
	Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
164
	k_IsVisibleArrows = y
165
	}
166
}
167
return
168
169
;ARROWS
170
171
k_ShowHideArrows:
172
if k_IsVisibleArrows = y
173
{
174
	Gui, Cancel
175
	Menu, Tray, Rename, %k_MenuItemHideArrows%, %k_MenuItemShowArrows%
176
	k_IsVisibleArrows = n
177
	k_IsVisibleAll = n
178
}
179
else
180
{
181
	Gui, Show
182
	Menu, Tray, Rename, %k_MenuItemShowArrows%, %k_MenuItemHideArrows%
183
	k_IsVisibleArrows = y
184
}
185
return
186
187
188
189
k_MenuExit:
190
ExitApp