boiler wrote: ↑19 Apr 2021, 21:56
Try this:
Code: Select all
#Persistent
SetCapsLockState, Off
displayedState := "off"
width := A_ScreenWidth/2
height := A_ScreenHeight - 300
SetTimer, Monitor, 100
return
Monitor:
if GetKeyState("CapsLock", "T") && (displayedState = "off")
{
displayedState := "on"
Progress, B1 W200 H120 ZH0 FS80 WS700 x%width% y%height% CTFFFFFF CW5A5A5A, A
gosub, FadeOut
}
else if !GetKeyState("CapsLock", "T") && (displayedState = "on")
{
displayedState := "off"
Progress, B1 W200 H120 ZH0 FS80 WS700 x%width% y%height% CTFFFFFF CW5A5A5A, a
gosub, FadeOut
}
OldState := State
return
FadeOut:
Sleep, 200
loop, 25 {
WinSet, Transparent, % 255 - 10 * A_Index, ahk_class AutoHotkey2
Sleep, 10
}
Progress, Off
return
Thanks again,it is great!
Compared to the previous version, the only problem is if changing the key very fast, it looks not very smooth.
so I copied your code and made this one
Code: Select all
#Persistent
SetCapsLockState, Off
displayedState := "off"
width := A_ScreenWidth/2
height := A_ScreenHeight - 300
SetTimer, Monitor, 100
return
Monitor:
if GetKeyState("CapsLock", "T") && (displayedState = "off")
{
displayedState := "on"
Progress, B1 W200 H120 ZH0 FS80 WS700 x%width% y%height% CTFFFFFF CW5A5A5A, A
SetTimer, ProgressOff, -1000
}
else if !GetKeyState("CapsLock", "T") && (displayedState = "on")
{
displayedState := "off"
Progress, B1 W200 H120 ZH0 FS80 WS700 x%width% y%height% CTFFFFFF CW5A5A5A, a
SetTimer, ProgressOff, -1000
}
OldState := State
return
ProgressOff:
Sleep, 1500
loop, 25 {
WinSet, Transparent, % 255 - 10 * A_Index, ahk_class AutoHotkey2
Sleep, 10
}
Progress, Off
return
Oh, NO
after testing, there is a bug...
in ProgressOff, the sleep time is 1500, so if changing the key at 1200, the new key's status only stay on the screen 300...it's too fast
could you please give me some advise ?