Sign in to follow this  
Followers 0
Ace08

Clicking a GUI

4 posts in this topic

uhm hi guys just want to know what i did was to create a GUI that displays the time I've also added the seconds and i want to place it on the lower right so that it would cover up the system time display.

the problem is how would the script know that the GUI has been clicked twice? this is because when i double click the GUI the date and time properties would open.

here are the codes I did:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)
Global $MainF,$Label1,$Hour,$AmPm,$msg
Main()

Func Main()
    Run("control timedate.cpl")
     $MainF = GUICreate("Scheduler", 80 ,80,-1,-1,$WS_POPUP, $WS_EX_TOOLWINDOW+$WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle()));Creates The GUI
     $Label1 = GUICtrlCreateLabel("",2,10,200,200)
    GUISetState()
    While 1
        WinSetOnTop ( "Scheduler", "",1)
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE then 
             GUIDelete($MainF)
                 Exit
        Endif
        if @Hour > 12 then
            $Hour = @Hour - 12
            $AmPm = "PM"
        else 
            $Hour = @Hour
            $AmPm = "AM"
        endif
        GUICtrlSetData($Label1, $Hour & ":" & @Min & ":" & @Sec & " " & $AmPm)
        WinMove ( "Scheduler", "", 958, 720, 65, 18)
        Sleep(1000)
    Wend
EndFunc

Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites



after thinking for a while i recognized that i don't need to click on the GUI itself since the whole of the script will occupy only one control i've decided to use a button instead.

but i am facing another problem with this, here is what i did

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)
Global $MainF,$Label1,$Hour,$AmPm,$msg
Main()

Func Main()
    $MainF = GUICreate("Scheduler", 80 ,80,-1,-1,$WS_POPUP, Default, WinGetHandle(AutoItWinGetTitle()));Creates The GUI
    $Label1 = GUICtrlCreateButton("",0,0,70,20)
    GUISetOnEvent($Label1, "SpecialEvents")
    GUISetState()
    While 1
        WinSetOnTop ( "Scheduler", "",1)
        $msg = GUIGetMsg()
        Select
            Case $msg = $Label1
                If WinExists("Date and Time Properties") Then
                Else
                    Run("control timedate.cpl")
                    WinWait("Date and Time Properties")
                    WinActivate ("Date and Time Properties", "")
                EndIf
        EndSelect
        if @Hour > 12 then
            $Hour = @Hour - 12
            $AmPm = "PM"
        else 
            $Hour = @Hour
            $AmPm = "AM"
        endif
        GUICtrlSetData($Label1, $Hour & ":" & @Min & ":" & @Sec & " " & $AmPm)
        WinMove ( "Scheduler", "", 958, 744, 65, 18)
        Sleep(80)
    Wend
EndFunc

the problem is about the sleep function, i wanted to stop the script from fliokering so i've set sleep to 1000(1 Sec) but when i click on the button while the script is still sleeping nothing happens but if i lower the sleep function i get the flickering effect.

any help or ideas are greatly appreciated, Thanks


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Only write your time display if it changes

; .....
$display = $Hour & ":" & @Min & ":" & @Sec & " " & $AmPm
If $display <> $olddisplay Then GUICtrlSetData($Label1, $display)
$olddisplay = $display
; .....
Edited by whim

Share this post


Link to post
Share on other sites

Thanks whim its now working perfectly


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0