Search code examples
eventsautohotkeybatterylevel

Button event doesn't trigger - Autohotkey


Iam developing an ahk-Script that checks the battery of the current device in time intervals.

Besides two text-lines that show the ac-status and the batterylife in percent, I am showing a Button to close the gui. Otherwise the gui closes itself in 10 seconds.

But: When I click on the button, nothing happens... can someone show me the mistake?

Thx a lot

Gui, +AlwaysOnTop +Disabled -SysMenu +Owner

Gui +LastFound
WinSet, Transparent, 240 
Gui, -Caption

Gui, Font, s11 cD0D0D0 Bold
Gui, Add, Text,, %acStatus% 
Gui, Add, Text,, %batteryLifePercent% Prozent
Gui, Add, Button, x10 y+5 w90 gsub1, Ok

Gui, Show, x1750 y1000
Gui, Show, NoActivate, Akkustatus

Return


Sleep, 10000
Gui Destroy


Return

sub1:
{
    Gui Destroy
}
Return

Solution

  • Remove +Disabled from the gui:

    Gui, +AlwaysOnTop +Disabled -SysMenu +Owner
    

    This option will prevent the user from interacting with the window, thus preventing you from clicking on the button.