I made a simple timer using Autohotkey with the help of some snippets from the Autohotkey forum, Like the page loading bar on many of the web pages in browser, but for Windows.
Now it work as expected, with those features:
But, I notice while transparency been set to 100, there alway be a gray transparent background,
Some one know any parameter I can tweak to make the progress bar without background ?
Full Autohotkey code here for this simple timer:
#Persistent
WinTitle = toptimer
Gui,New,hwndMyGui
global MyProgress
; 30 minutes
time := 30 * 60 * 1000
tick:=A_TickCount+time
Gui, +E0x20 -Caption +AlwaysOnTop +Owner +LastFound
; Gui, -Caption +AlwaysOnTop +Owner +LastFound
WinSet, Transparent, 100
; Gui,Margin,0,0
Gui,Margin,-1,-1
Gui,Add,Progress,w1920 h4 cbFF0000 Range%A_TickCount%-%tick% vMyProgress
; Gui,Show,NA
Gui, Show, x0 y0 w%A_ScreenWidth%
While A_TickCount<=tick {
GuiControl,,MyProgress,% A_TickCount
Sleep 16
}
Gui,Destroy
ExitApp
Thanks @0x464e for nice suggestion,
Now I just draw a single color gui and change it's width
#Persistent
Gui,New,hwndMyGui
time := 1 * 60 * 1000
tick:=A_TickCount+time
Gui, +E0x20 -Caption +AlwaysOnTop +Owner +LastFound
WinSet, Transparent, 100
Gui, Color, FF0000
While A_TickCount<=tick {
width0 := A_ScreenWidth * (1 - (tick - A_TickCount)/time)
Gui, Show, x0 y0 w%width0% h5
Sleep 16
}
Gui,Destroy
ExitApp
That made the code even simpler, and the background is gone. But while this timer is running, the left mouse button is not function right, clicking on explorer's top right Minimize/Restore/Close is not work.
But the Minimize/Restore/Close button of vscode is working fine.
After quit the timer, everything just work fine.
Some one help to figure out why that happens.
The problem occurs because your Gui, Show
command activates the the window each time.
Add the NA
(docs) option to get rid of this.
Alternatively, you could use e.g WinMove
(docs) to resize the window.
In that case you'll also need to use SetWinDelay
(docs) to remove the delay that happens after a WinMove
command.
I'm not sure which approach is better, I can't be asked to open up the AHK source to see what exactly is the difference between these two. If you care enough (and understand C/C++ well enough) be sure to take a look.
Here are the revised scripts for both approaches:
time := 1 * 60 * 1000
tick := A_TickCount + time
Gui, +E0x20 -Caption +AlwaysOnTop +Owner +LastFound
WinSet, Transparent, 100
Gui, Color, FF0000
While (A_TickCount <= tick)
{
width0 := A_ScreenWidth * (1 - (tick - A_TickCount) / time)
Gui, Show, x0 y0 w%width0% h5 NA
Sleep, 16
}
ExitApp
SetWinDelay, 0
time := 1 * 60 * 1000
tick := A_TickCount + time
Gui, +E0x20 -Caption +AlwaysOnTop +Owner +LastFound
WinSet, Transparent, 100
Gui, Color, FF0000
Gui, Show, y0 x0 h5
While (A_TickCount <= tick)
{
width0 := A_ScreenWidth * (1 - (tick - A_TickCount) / time)
WinMove, , , , , % width0
Sleep, 16
}
ExitApp