Paradoxsays
Programmer
In a closed thread, I found a script that displays the word CAPS in the current window titlebar in a box that is either red or green depending on whether capslock is off or on. Can anyone modify this to display only the word CAPS in a green box when capslock is on, i.e. when capslock is off nothing is displayed?
#noenv
#singleinstance, ignore
setbatchlines, -1
setworkingdir, %a_scriptdir%
gosub, osd_create
return
osd_create:
{
gui, -caption +toolwindow +alwaysontop +lastfound
gui, color, 8b0fc6
gui, font, s10 w600, Arial Bold
gui, margin, 0, 0
winset, transcolor, 8b0fc6
gui, add, listview, x63 y0 w40 h16 -hdr -e0x200 -multi background5481E6 v_capslock glv altsubmit
gui, add, text, x63 y0 w40 h16 0x201 cwhite backgroundtrans vtxt_capslock, CAPS ; overlay the word CAPS on top of the ListView control
}
return
capslock::
{
sleep, 10
if (!locked_%a_thishotkey%)
{
_toggle_key(a_thishotkey)
soundplay, beep.wav
color := getkeystate(a_thishotkey, "t") ? "00FF00" : "FF0000"
guicontrol, +background%color%, _%a_thishotkey%
guicontrol, hide, txt_%a_thishotkey%
guicontrol, show, txt_%a_thishotkey%
}
sysget, var_, monitorworkarea
gui, show, xCenter y0 NA, OSD
; xCenter centres the control horizontally, y0 sets the control at the top of the screen using normal x/y co-ordinates,
; NA displays the control without activating it (although you can click on the control to toggle CapsLock status.
;settimer, cancel, -3000 ; Control in milliseconds how long the control remains on screen
}
return
lv:
{
if (a_guievent = "normal") or (a_guievent = "doubleclick")
{
control := ltrim(a_guicontrol, "_")
if (!locked_%control%)
{
_toggle_key(control)
soundplay, beep.wav
color := getkeystate(control, "t") ? "00FF00" : "FF0000"
guicontrol, +background%color%, %a_guicontrol%
guicontrol, hide, txt%a_guicontrol%
guicontrol, show, txt%a_guicontrol%
}
;settimer, cancel, -3000 ; Control in milliseconds how long the control remains on screen
}
}
return
_toggle_key(key)
{
if (key = "capslock")
{
setcapslockstate, % getkeystate(key, "t") ? "off" : "on"
}
else if (key = "scrolllock")
{
setscrolllockstate, % getkeystate(key, "t") ? "off" : "on"
}
else if (key = "numlock")
{
setnumlockstate, % getkeystate(key, "t") ? "off" : "on"
}
return
}
cancel:
{
gui, cancel
}
return
#noenv
#singleinstance, ignore
setbatchlines, -1
setworkingdir, %a_scriptdir%
gosub, osd_create
return
osd_create:
{
gui, -caption +toolwindow +alwaysontop +lastfound
gui, color, 8b0fc6
gui, font, s10 w600, Arial Bold
gui, margin, 0, 0
winset, transcolor, 8b0fc6
gui, add, listview, x63 y0 w40 h16 -hdr -e0x200 -multi background5481E6 v_capslock glv altsubmit
gui, add, text, x63 y0 w40 h16 0x201 cwhite backgroundtrans vtxt_capslock, CAPS ; overlay the word CAPS on top of the ListView control
}
return
capslock::
{
sleep, 10
if (!locked_%a_thishotkey%)
{
_toggle_key(a_thishotkey)
soundplay, beep.wav
color := getkeystate(a_thishotkey, "t") ? "00FF00" : "FF0000"
guicontrol, +background%color%, _%a_thishotkey%
guicontrol, hide, txt_%a_thishotkey%
guicontrol, show, txt_%a_thishotkey%
}
sysget, var_, monitorworkarea
gui, show, xCenter y0 NA, OSD
; xCenter centres the control horizontally, y0 sets the control at the top of the screen using normal x/y co-ordinates,
; NA displays the control without activating it (although you can click on the control to toggle CapsLock status.
;settimer, cancel, -3000 ; Control in milliseconds how long the control remains on screen
}
return
lv:
{
if (a_guievent = "normal") or (a_guievent = "doubleclick")
{
control := ltrim(a_guicontrol, "_")
if (!locked_%control%)
{
_toggle_key(control)
soundplay, beep.wav
color := getkeystate(control, "t") ? "00FF00" : "FF0000"
guicontrol, +background%color%, %a_guicontrol%
guicontrol, hide, txt%a_guicontrol%
guicontrol, show, txt%a_guicontrol%
}
;settimer, cancel, -3000 ; Control in milliseconds how long the control remains on screen
}
}
return
_toggle_key(key)
{
if (key = "capslock")
{
setcapslockstate, % getkeystate(key, "t") ? "off" : "on"
}
else if (key = "scrolllock")
{
setscrolllockstate, % getkeystate(key, "t") ? "off" : "on"
}
else if (key = "numlock")
{
setnumlockstate, % getkeystate(key, "t") ? "off" : "on"
}
return
}
cancel:
{
gui, cancel
}
return