Jump to content

date and time refreshing in a gui with checkboxes


jennico
 Share

Recommended Posts

hello again,

so i am very glad and done with my configuration script of my program. the user can select options and these preferences are finally written into the ini files of the main program.

last thing to complete my work is refreshing date and time in the left upper corner of the gui. therefore i created a transparent label but i don't manage to get it refreshing, i mean the time counting up. right now it's just a fixed time displaying.

how can i achieve that preferably without creating a big loop ? do i use the global in a wrong way ?

thanx in advance. here my script but i only post the first important half of it.

j.

#include <file.au3>
#include <GuiConstants.au3>
#include <Date.au3>
Global $Sec, $Min, $Hour, $Time

SoundPlay("beep.wav")
GUICreate("(c)jennico2006",800,600,-1,-1,$WS_POPUP)
GUICtrlCreatePic ("konfig.jpg",0,0,800,600)
GuiCtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateLabel ( "die zeit ist : " & @Hour & ":" & @Min & ":" & @Sec,0,0,200,50 )
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

$Checkbox_1 = GUICtrlCreateCheckbox("",15,162,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_1 = ",LoadSkin(Destimap:zoombar)"
    $pic_1 = GUICtrlCreatePic("zo.jpg",84,151,42,206)
$Checkbox_2 = GUICtrlCreateCheckbox("",469,7,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_2 = ",LoadSkin(Destimap:shortcuts)"
    $pic_2 = GUICtrlCreatePic("sh.jpg",121,102,558,39)
$Checkbox_3 = GUICtrlCreateCheckbox("",728,143,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_3 = ",LoadSkin(Destimap:winamp)"
    $pic_3 = GUICtrlCreatePic("wa.jpg",680,116,38,247)
$Checkbox_4 = GUICtrlCreateCheckbox("",730,435,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_4 = ",LoadSkin(Destimap:apps)"
    $pic_4 = GUICtrlCreatePic("ap.jpg",640,437,80,48)
$Checkbox_5 = GUICtrlCreateCheckbox("",13,375,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_5 = ",LoadSkin(Destimap:buttons)"
    $pic_5 = GUICtrlCreatePic("bu.jpg",83,362,48,90)
$Exit = GUICtrlCreateButton("",472,550,112,42,$BS_bitmap,$WS_EX_TRANSPARENT)
    GUICtrlSetImage (-1,"fertig.bmp")
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        case $msg = $Checkbox_1
            if GuiCtrlRead($Checkbox_1) = $GUI_CHECKED then
                SoundPlay("comp1.wav")
                GUICtrlSetImage ($Checkbox_1,"konfig1.bmp")  
                GUICtrlSetImage($pic_1, "zo.jpg")
                $desti_1 = ",LoadSkin(Destimap:zoombar)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_1,"konfig0.bmp")  
                GUICtrlSetImage($pic_1, "")
                $desti_1 = ""
            endif
        case $msg = $Checkbox_2
            if GuiCtrlRead($Checkbox_2) = $GUI_CHECKED then
                SoundPlay("comp2.wav")
                GUICtrlSetImage ($Checkbox_2,"konfig1.bmp")  
                GUICtrlSetImage($pic_2, "sh.jpg")
                $desti_2 = ",LoadSkin(Destimap:shortcuts)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_2,"konfig0.bmp") 
                GUICtrlSetImage($pic_2, "")
                $desti_2 = ""
            endif   
        case $msg = $Checkbox_3
            if GuiCtrlRead($Checkbox_3) = $GUI_CHECKED then
                SoundPlay("comp3.wav")
                GUICtrlSetImage ($Checkbox_3,"konfig1.bmp")  
                GUICtrlSetImage($pic_3, "wa.jpg")
                $desti_3 = ",LoadSkin(Destimap:winamp)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_3,"konfig0.bmp") 
                GUICtrlSetImage($pic_3, "")
                $desti_3 = ""
            endif
        case $msg = $Checkbox_4
            if GuiCtrlRead($Checkbox_4) = $GUI_CHECKED then
                SoundPlay("comp4.wav")
                GUICtrlSetImage ($Checkbox_4,"konfig1.bmp") 
                GUICtrlSetImage($pic_4, "ap.jpg")
                $desti_4 = ",LoadSkin(Destimap:apps)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_4,"konfig0.bmp")  
                GUICtrlSetImage($pic_4, "") 
                $desti_4 = ""
            endif   
        case $msg = $Checkbox_5
            if GuiCtrlRead($Checkbox_5) = $GUI_CHECKED then
                SoundPlay("comp5.wav")
                GUICtrlSetImage ($Checkbox_5,"konfig1.bmp") 
                GUICtrlSetImage($pic_5, "bu.jpg")
                $desti_5 = ",LoadSkin(Destimap:buttons)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_5,"konfig0.bmp") 
                GUICtrlSetImage($pic_5, "")
                $desti_5 = ""
            endif
        case $msg = $Exit
            SoundPlay("fertig.wav")
            ExitLoop
    EndSelect
WEnd
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Take a look to AdlibEnable function.

#include <file.au3>
#include <GuiConstants.au3>
#include <Date.au3>
Global $Sec, $Min, $Hour, $Time

SoundPlay("beep.wav")
GUICreate("©jennico2006",800,600,-1,-1,$WS_POPUP)
GUICtrlCreatePic ("konfig.jpg",0,0,800,600)
GuiCtrlSetState(-1,$GUI_DISABLE)
$Time = GUICtrlCreateLabel ( "die zeit ist : " & @Hour & ":" & @Min & ":" & @Sec,0,0,200,50 )
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

$Checkbox_1 = GUICtrlCreateCheckbox("",15,162,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_1 = ",LoadSkin(Destimap:zoombar)"
    $pic_1 = GUICtrlCreatePic("zo.jpg",84,151,42,206)
$Checkbox_2 = GUICtrlCreateCheckbox("",469,7,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_2 = ",LoadSkin(Destimap:shortcuts)"
    $pic_2 = GUICtrlCreatePic("sh.jpg",121,102,558,39)
$Checkbox_3 = GUICtrlCreateCheckbox("",728,143,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_3 = ",LoadSkin(Destimap:winamp)"
    $pic_3 = GUICtrlCreatePic("wa.jpg",680,116,38,247)
$Checkbox_4 = GUICtrlCreateCheckbox("",730,435,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_4 = ",LoadSkin(Destimap:apps)"
    $pic_4 = GUICtrlCreatePic("ap.jpg",640,437,80,48)
$Checkbox_5 = GUICtrlCreateCheckbox("",13,375,58,57,$BS_PUSHLIKE+$BS_bitmap)
    GUICtrlSetState (-1, $GUI_CHECKED)
    GUICtrlSetImage (-1,"konfig1.bmp")
    $desti_5 = ",LoadSkin(Destimap:buttons)"
    $pic_5 = GUICtrlCreatePic("bu.jpg",83,362,48,90)
$Exit = GUICtrlCreateButton("",472,550,112,42,$BS_bitmap,$WS_EX_TRANSPARENT)
    GUICtrlSetImage (-1,"fertig.bmp")
GUISetState()
AdlibEnable("_UpdateTime")

While 1
    $msg = GUIGetMsg()
    Select
        case $msg = $Checkbox_1
            if GuiCtrlRead($Checkbox_1) = $GUI_CHECKED then
                SoundPlay("comp1.wav")
                GUICtrlSetImage ($Checkbox_1,"konfig1.bmp")  
                GUICtrlSetImage($pic_1, "zo.jpg")
                $desti_1 = ",LoadSkin(Destimap:zoombar)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_1,"konfig0.bmp")  
                GUICtrlSetImage($pic_1, "")
                $desti_1 = ""
            endif
        case $msg = $Checkbox_2
            if GuiCtrlRead($Checkbox_2) = $GUI_CHECKED then
                SoundPlay("comp2.wav")
                GUICtrlSetImage ($Checkbox_2,"konfig1.bmp")  
                GUICtrlSetImage($pic_2, "sh.jpg")
                $desti_2 = ",LoadSkin(Destimap:shortcuts)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_2,"konfig0.bmp") 
                GUICtrlSetImage($pic_2, "")
                $desti_2 = ""
            endif   
        case $msg = $Checkbox_3
            if GuiCtrlRead($Checkbox_3) = $GUI_CHECKED then
                SoundPlay("comp3.wav")
                GUICtrlSetImage ($Checkbox_3,"konfig1.bmp")  
                GUICtrlSetImage($pic_3, "wa.jpg")
                $desti_3 = ",LoadSkin(Destimap:winamp)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_3,"konfig0.bmp") 
                GUICtrlSetImage($pic_3, "")
                $desti_3 = ""
            endif
        case $msg = $Checkbox_4
            if GuiCtrlRead($Checkbox_4) = $GUI_CHECKED then
                SoundPlay("comp4.wav")
                GUICtrlSetImage ($Checkbox_4,"konfig1.bmp") 
                GUICtrlSetImage($pic_4, "ap.jpg")
                $desti_4 = ",LoadSkin(Destimap:apps)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_4,"konfig0.bmp")  
                GUICtrlSetImage($pic_4, "") 
                $desti_4 = ""
            endif   
        case $msg = $Checkbox_5
            if GuiCtrlRead($Checkbox_5) = $GUI_CHECKED then
                SoundPlay("comp5.wav")
                GUICtrlSetImage ($Checkbox_5,"konfig1.bmp") 
                GUICtrlSetImage($pic_5, "bu.jpg")
                $desti_5 = ",LoadSkin(Destimap:buttons)"
            else
                SoundPlay("cancel.wav")
                GUICtrlSetImage ($Checkbox_5,"konfig0.bmp") 
                GUICtrlSetImage($pic_5, "")
                $desti_5 = ""
            endif
        case $msg = $Exit
            SoundPlay("fertig.wav")
            ExitLoop
    EndSelect
WEnd
AdlibDisable()
Exit

Func _UpdateTime()
   GUICtrlSetData($Time, "die zeit ist : " & @Hour & ":" & @Min & ":" & @Sec)   
EndFunc
Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

a new but small problem occured:

later on in my script there are some message boxes. the clock stops until the message boxes are answered. seems that they interrupt the adlib function resp. the update of the main window. can i cure that (clock going on)?

j.

i solved the flickering prob by downing the refresh interval to 1000 ms. for a clock thats all i need....

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

a new but small problem occured:

later on in my script there are some message boxes. the clock stops until the message boxes are answered. seems that they interrupt the adlib function resp. the update of the main window. can i cure that (clock going on)?

Instead of using MsgBox you could have your own function which creates a gui then the adlib function will still be called and keep your clock running.

Func mymbox($s,$t)
$g2 = GUICreate($s,170,130)
$lab = GUICtrlCreateLabel($t,20,10,80,20)
$Byes = GUICtrlCreateButton("yes",30,80,50,20)
$Bno = GUICtrlCreateButton("no",100,80,50,20)
GUISetState()
while 1
    $w = 0
    $m = GUIGetMsg()
    if $m = $Byes then $w=1
      
    if $m = $Bno then $w = 2
        
    If $m = $GUI_EVENT_CLOSE Then $w = 3

    If $w > 0 Then
        GUIDelete($g2)
        return $w
    EndIf
WEnd
EndFunc
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

well, thank you guys,

i think i will avoid using message boxes and create guis instead. furthermore they are a lot more interesting and better in design.

thanx for the interesting adlib function and the ideas. i will be able to finish my work now.

thanx j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...