Sign in to follow this  
Followers 0
anderson78

Creating countdown window

7 posts in this topic

I am trying to create a countdown window to alert the user that a action is about to take place. I am doing this by creating a GUI box and then trying to change the background through three different jpeg images so that the user sees a box that this displays 3,2,1... in order. When I run my code the window is created but the background does not change to the jpeg images, it just remains blank. I am not trying to create any other controls in this window so I am not worried about the tabbing to other controls issue that I have seen in other posts.

Thanks.

GUICreate("Countdown",750,750)

GUICtrlCreatePic("C:\Users\Anderson\Desktop\AutoIT testing\three.jpeg",0,0,600,600)

GUISetState(@SW_SHOW)

SLEEP(1000)

GUICtrlCreatePic("C:\Users\Anderson\Desktop\AutoIT testing\two.jpeg",0,0,600,600)

GUISetState(@SW_SHOW)

SLEEP(1000)

GUICtrlCreatePic("C:\Users\Anderson\Desktop\AutoIT testing\one.jpeg",0,0,600,600)

GUISetState(@SW_SHOW)

GUIDelete()

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

A short example:

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

$Form1 = GUICreate("Form1", 233, 156)
$Pic1 = GUICtrlCreatePic(@WorkingDir & "Test1.jpg", 8, 8, 209, 137)
GUISetState(@SW_SHOW)

Sleep(500)
GUICtrlSetImage($Pic1, @WorkingDir & "Test2.jpg")
Sleep(500)
GUICtrlSetImage($Pic1, @WorkingDir & "Test3.jpg")
Sleep(500)
Exit

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
Edited by johnmcloud

Share this post


Link to post
Share on other sites

Or, from the helpfile example for SplashTextOn:

$message = ""
SplashTextOn("TitleFoo", $message, -1, -1, -1, -1, 4, "")

For $x = 10 To 1 Step -1
$message = $message & $x & @LF
ControlSetText("TitleFoo", "", "Static1", $message)
Sleep(100)
Next

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the input but I tried copying in your code and changing the file paths as a test and got the same result, the blank GUI which then closed after the timers were out. I would also like to note that I did have the constants included in my code as well, so I don't think it is related to that. Any other ideas?.

I also just refreshed the window and saw the splash example. I will give that a try and see where it gets me.

Thanks.

Edited by anderson78

Share this post


Link to post
Share on other sites

Your splash text on worked, but I am trying to use jpeg images for my countdown and I've tried adapting your splash text code to images with no success. For whatever reason it seems like I can get pictures to be displayed...

Share this post


Link to post
Share on other sites

anderson78,

If you do not need to have a picture display the countdown number try this script (the number is a control on a transparent background)

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <WINAPI.au3>

local $countdown = 3, $freq = 500

local $gui010 = GUICreate("",700,700 ,-1, -1, $WS_POPUP, $WS_EX_LAYERED)
                GUISetBkColor(0xABCDEF)
local $lbl010 = guictrlcreatelabel('',140,10,680,680)
                guictrlsetfont($lbl010,500,800)
                _WinAPI_SetLayeredWindowAttributes($gui010, 0xABCDEF, 250)
                guisetstate(@sw_show)

for $i = $countdown to 1 step -1

    guictrlsetdata($lbl010,$i)

    beep($freq,500)

    Sleep(1000)

next

;shutdown(2)

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Your splash text on worked, but I am trying to use jpeg images for my countdown and I've tried adapting your splash text code to images with no success. For whatever reason it seems like I can get pictures to be displayed...

If you need to use images, try something like this. Just plug in the path to your image:

Local $destination = @DesktopDir & "test.jpg"

For $x = 10 to 1 Step -1

If $x = "1" Then
  SplashImageOn("The program will begin in " & $x & " second.", $destination, 250, 50)
Else
  SplashImageOn("The program will begin in " & $x & " seconds.", $destination, 250, 50)
EndIf

Sleep(1000)
SplashOff()
Sleep(500)

Next

√-1 2^3 ∑ π, and it was delicious!

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