Jump to content

Blinking Text hindering Close Button


mtmartis
 Share

Recommended Posts

I am creating a dialog box for a an installation. The top test is set to "Blink" using the following code. My issue is I need to slow down the "blinking" by increasing the Sleep() duration, but when I do, I think the loop overlaps and when I click the Close Window Button, nothing happens. Any ideas would be greatly appreciated! NOTE: I am still learning AutoIt scripting, so try not to tear me a new one, thanks!

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

GUICreate("Install", 500, 335, -1, -1, BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU))
GUISetBkColor(0xDCDCDC) 

$button = GUICtrlCreateButton ("Close Window", 175, 285,150,20,$ES_CENTER)
GUICtrlSetState(-1,$GUI_FOCUS)  

GUISetFont (25, 999,-1, "Verdana"); will display underlined characters
$label = GUICtrlCreateLabel (@CRLF & "IMPORTANT REMINDER!!!",1,1,500,85,$ES_CENTER)

GUISetState ()

$right = 0
While 1
    $msg = GUIGetMsg()
    If $msg = $button Or $msg = $GUI_EVENT_CLOSE then Exit
    If $right = 0 then
        $right = 1
        GUICtrlSetColor($label,0xFF0000)    ; Red
    else
        $right = 0
        GUICtrlSetColor($label,0xDCDCDC)    ; BKGround

        endif
    sleep(250)
Wend
Exit
Link to comment
Share on other sites

  • Developers

2 options:

1. use eventmode for the button.

2. Use Adlib function for the blinking and get rid of the sleep() in the GUImessageloop

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If you don't want to learn adlib or event mode yet, this script should do the trick...

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

GUICreate("Install", 500, 335, -1, -1, BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU))
GUISetBkColor(0xDCDCDC) 

$button = GUICtrlCreateButton ("Close Window", 175, 285,150,20,$ES_CENTER)
GUICtrlSetState(-1,$GUI_FOCUS)  

GUISetFont (25, 999,-1, "Verdana"); will display underlined characters
$label = GUICtrlCreateLabel (@CRLF & "IMPORTANT REMINDER!!!",1,1,500,85,$ES_CENTER)

GUISetState ()
$global_sleep = 10 ; change main loop sleep duration here
$blink_sleep = 250 ; change blink sleep duration here
$total_blink_sleep = 0
$right = 0
While 1
    $msg = GUIGetMsg()
    If $msg = $button Or $msg = $GUI_EVENT_CLOSE then Exit
    If $total_blink_sleep >= $blink_sleep Then
        $total_blink_sleep = 0 ; reset total blink sleep
        If $right = 0 then
            $right = 1
            GUICtrlSetColor($label,0xFF0000)    ; Red
        else
            $right = 0
            GUICtrlSetColor($label,0xDCDCDC)    ; BKGround

        EndIf
    Else
        $total_blink_sleep = $total_blink_sleep + $global_sleep
    EndIf
    sleep($global_sleep)
Wend
Exit

Hi ;)

Link to comment
Share on other sites

If you don't want to learn adlib or event mode yet, this script should do the trick...

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

GUICreate("Install", 500, 335, -1, -1, BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU))
GUISetBkColor(0xDCDCDC) 

$button = GUICtrlCreateButton ("Close Window", 175, 285,150,20,$ES_CENTER)
GUICtrlSetState(-1,$GUI_FOCUS)  

GUISetFont (25, 999,-1, "Verdana"); will display underlined characters
$label = GUICtrlCreateLabel (@CRLF & "IMPORTANT REMINDER!!!",1,1,500,85,$ES_CENTER)

GUISetState ()
$global_sleep = 10 ; change main loop sleep duration here
$blink_sleep = 250 ; change blink sleep duration here
$total_blink_sleep = 0
$right = 0
While 1
    $msg = GUIGetMsg()
    If $msg = $button Or $msg = $GUI_EVENT_CLOSE then Exit
    If $total_blink_sleep >= $blink_sleep Then
        $total_blink_sleep = 0 ; reset total blink sleep
        If $right = 0 then
            $right = 1
            GUICtrlSetColor($label,0xFF0000)    ; Red
        else
            $right = 0
            GUICtrlSetColor($label,0xDCDCDC)    ; BKGround

        EndIf
    Else
        $total_blink_sleep = $total_blink_sleep + $global_sleep
    EndIf
    sleep($global_sleep)
Wend
Exit

Mison,

I did look at adlib and event mode for a few hours, and you are correct, I am not ready for that just yet.

I appreciate your help! It's going to take a bit for me to completely understand what the loop is doing. Loops just don't make sense to me for some reason.

Thanks again!!!

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...