Sign in to follow this  
Followers 0
tater

Display Timer (countdown)

13 posts in this topic

Good evening friends,

I wrote a countdown timer a while back. It wasn't anything special, it was just a tooltip that displayed a countdown and wrote certain time/data in a text file. I've been getting really irritated with it lately because the text is just too small on this giant resolution. So what I want to do is maybe instead of using a tooltip, just have it displayed on the screen in say a red text. But the problem is I don't know where I should exactly start. Would this be considered a GUI? Also I would rather have it transparent and have no background color at all since that was quite irritating at times as well. Could someone please just point me in the right direction as to where to start and what I should look into via the help file.

Thanks for any help >_<

tater

Share this post


Link to post
Share on other sites



I doubt this is the only way, but GUISetFont lets you define font size, and GUISetBkColor lets you define background color, while GUICtrlSetDefColor defines foreground color.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Thanks for the reply >_< I just have one quick question as to the background color - how can you basically have nothing. I just want it to be transparent if that is possible.

Thanks again for any help!

Share this post


Link to post
Share on other sites

in order for it to be transparent you will need to make a .GIF the same size anduse the Transparent UDF found somwhere on here , forgot the name, But ehh


My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u]

Share this post


Link to post
Share on other sites

Thanks a lot for the help guys. Greatly appreciated.

Share this post


Link to post
Share on other sites

Just another quick question, can you allow GUIs to stay on top? Since I previously used a ToolTip, it was always visible. Can you do the same with a GUI - so if you drag Internet Explorer next to the GUI window it will go behind it and keep the GUI on top!

Thanks for any responses and help!

tater

Share this post


Link to post
Share on other sites

#include<WindowsConstants.au3>

GUICreate("", 100, 100, -1, -1, "", $WS_EX_TOPMOST)


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Thank you Sir.

Share this post


Link to post
Share on other sites

Hi guys,

First off I'd like to say thanks to everyone that has taken the time to look and respond to my questions! You're a very big help to me.

My problem now is that upon hitting one of the hotkeys, only 1 timer can be on at any given time. I can't have all 3 running. I'm wondering if you guys can show me how to do so (or if it's possible). As you can tell, this is kind of a basic stopwatch >_<

Thanks again for any help!

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

Simple()

Func Simple()
   
    GUICreate("Simple", 200,200)  
    WinSetTrans("Simple", "", 150) 



    
    $birdpic = GUICtrlCreatePic("C:\Users\tater\Desktop\bird.jpg", 10, 10, 50, 50)
    HotKeySet("{UP}", "Bird")



    $catpic = GUICtrlCreatePic("C:\Users\tater\Desktop\cat.jpg", 8, 60, 55, 55)
    HotKeySet("{LEFT}", "Cat")

    
    $dogpic = GUICtrlCreatePic("C:\Users\tater\Desktop\dog.jpg", 8, 110, 55, 55)
    HotKeySet("{RIGHT}", "Dog")
    
    
    
    GUISetState(@SW_SHOW)
 
 
    While 1
        $msg = GUIGetMsg()
       
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   

Func Bird()
    For $i = 35 to 1 Step -1
        $font = "Calibri"
        GUICtrlSetDefColor(0x5588EE)  
        GUICtrlCreateLabel($i, 90, 15, 40,40)
        GUICtrlSetFont(-1, 24, 800, 0, $font)
        Sleep(1000)
    Next
        ;GUICtrlCreateLabel("Time's Up!", 60, 20)
        GUICtrlCreateLabel("  ", 60, 14,40,40)
EndFunc
    
Func Cat()
    For $i = 35 to 1 Step -1
        $font = "Calibri"
        GUICtrlSetDefColor(0xA30505)  
        GUICtrlCreateLabel($i, 90, 65, 40,40)
        GUICtrlSetFont(-1, 24, 800, 0, $font)    
        Sleep(1000)
    Next
        ;GUICtrlCreateLabel("Time's Up!", 60, 20)
        GUICtrlCreateLabel("  ", 60, 14,40,40)
EndFunc


Func Dog()
        For $i = 25 to 1 Step -1
        $font = "Calibri"
        GUICtrlSetDefColor(0xFEE533)  
        GUICtrlCreateLabel($i, 90, 115, 40,40)
        GUICtrlSetFont(-1, 24, 800, 0, $font)    
        Sleep(1000)
    Next
        ;GUICtrlCreateLabel("Time's Up!", 60, 20)
        GUICtrlCreateLabel("  ", 60, 14,40,40)
EndFunc

Share this post


Link to post
Share on other sites

Since autoit isn't multithreaded, you can't have it doing two things at once. You could use three different scripts, but that might be a problem if they are all using the same gui.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

As you can't run multiple loops at the same time you want incorporate everything that has to be checked continuously into one loop. I've made an example:

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

Global $font = "Calibri"
Global $BirdStart, $CatStart, $DogStart

Simple()

Func Simple()
   
    GUICreate("Simple", 200,200)  
    WinSetTrans("Simple", "", 150) 

    $birdpic = GUICtrlCreatePic("C:\Users\tater\Desktop\bird.jpg", 10, 10, 50, 50)
    GUICtrlSetDefColor(0x5588EE)
    $BirdLabel = GUICtrlCreateLabel("", 90, 15, 40,40)
    GUICtrlSetFont(-1, 24, 800, 0, $font)
    HotKeySet("{UP}", "Bird")

    $catpic = GUICtrlCreatePic("C:\Users\tater\Desktop\cat.jpg", 8, 60, 55, 55)
    GUICtrlSetDefColor(0xA30505)
    $CatLabel = GUICtrlCreateLabel("", 90, 65, 40,40)
    GUICtrlSetFont(-1, 24, 800, 0, $font)
    HotKeySet("{LEFT}", "Cat")

    $dogpic = GUICtrlCreatePic("C:\Users\tater\Desktop\dog.jpg", 8, 110, 55, 55)
    GUICtrlSetDefColor(0xFEE533)
    $DogLabel =  GUICtrlCreateLabel("", 90, 115, 40,40)         
    GUICtrlSetFont(-1, 24, 800, 0, $font)
    HotKeySet("{RIGHT}", "Dog")
        
    GUISetState(@SW_SHOW)
 
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
        If $BirdStart And _DateDiff("s",$BirdStart, _NowCalc()) < 36 Then
            GUICtrlSetData($BirdLabel, 35 - _DateDiff("s",$BirdStart, _NowCalc()))
        EndIf
        
        If $CatStart And _DateDiff("s",$CatStart, _NowCalc()) < 36 Then
            GUICtrlSetData($CatLabel, 35 - _DateDiff("s",$CatStart, _NowCalc()))
        EndIf
        
        If $DogStart And _DateDiff("s",$DogStart, _NowCalc()) < 36 Then
            GUICtrlSetData($DogLabel, 35 - _DateDiff("s",$DogStart, _NowCalc()))
        EndIf
    WEnd
EndFunc   

Func Bird()
    $BirdStart = _NowCalc()
EndFunc

Func Cat()
    $CatStart = _NowCalc()
EndFunc

Func Dog()
    $DogStart = _NowCalc()
EndFunc

As you can see the hotkeys call a function that returns almost instantly and they set a variable which is then used in the main loop.

Downside of this approach is that the labels get updated continuously, which causes flickering.

You can solve this by putting in a sleep(100), but you never want to have a sleep() in a loop that uses GUIGetMsg().

You could easily modify it to only update when the variable has changed and setting the window style $WS_CLIPCHILDREN may also reduce flickering.

Hope it helps.

Tom

Share this post


Link to post
Share on other sites

Thank you very much for your help! This is a nice new approach for me to learn.

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