Sign in to follow this  
Followers 0
zxcvbnm

continue to flash

37 posts in this topic

I need that when min = -59 and sec = 59 it continues to flash and the windows doesn't close it self

Is it right to distinguish beetwen two timer, the first that not flash to kill?

Why the windows does not remain opened?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Timers.au3>
Global $iMin = 1, $iSec = 32, $iFlash = 0, $neg = 0, $iTimerProgress
$Form1 = GUICreate("Count Down", 250, 70, 125, 125, BitOR($WS_DLGFRAME, $WS_POPUP), $WS_EX_TOPMOST)
GUISetBkColor(0x66FF00)
$Label = GUICtrlCreateLabel(StringFormat("%02d:%02d", $iMin, $iSec), 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG)
;$Label = GUICtrlCreateLabel("", 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 40, 800, 0, "verdana")
GUISetState(@SW_SHOW)
;AutoItSetOption ( "TrayIconHide" ,1 )
; Start a timer for the countdown
$iTimerProgress = _Timer_SetTimer($Form1, 5, "_CountDown") ; Call once a sec
Do
    Sleep(10)
Until $iMin = (-59) and $iSec = 59
;_Timer_KillAllTimers($Form1)
;If $iMin = (-59) and $iSec = 59 Then
_Timer_KillTimer($Form1,$iTimerProgress)
;EndIf

Func _CountDown($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing!
    ; We call it once a sec, so just reduce by 1 sec each time
    If $iMin > 0 Then
    $iSec -= 1
    If $iSec < 0 Then
        $iSec = 59
        $iMin -= 1
    EndIf
   GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec))
 ElseIF  $iMin = 0 and $neg = 0 Then
    $iSec -= 1
    If $iSec = 0 Then
        $neg = 1
    EndIf
    GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec))
 ElseIf $iMin = 0 and $neg = 1 Then
        $iSec += 1
    GUICtrlSetData($Label, StringFormat("-"&"%02d:%02d",$iMin, $iSec))
    If $iSec > 59 Then
        $iSec = 0
        $iMin -=1
        GUICtrlSetData($Label, StringFormat("%03d:%02d",$iMin, $iSec))
   EndIf
    ElseIf $iMin < 0 and $neg = 1 Then
        $iSec += 1
        If $iSec > 59 Then
        $iSec = 0
        $iMin -=1
        EndIf
        GUICtrlSetData($Label, StringFormat("%03d:%02d", $iMin, $iSec))
 EndIf
    If $iMin = 2 And $iSec = 30 Then
  GUISetBkColor(0xFFFF00)
 EndIf
 If $iMin = 0 And $iSec = 30 Then
  GUISetBkColor(0xFF0000)
    EndIf
    If $iMin = 0 And $iSec = 0 Then
    _Timer_SetTimer($Form1, 50, "_Flash") ; Start a second timer to flash
    EndIf

EndFunc
Func _Flash($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing!
    $iFlash = Not $iFlash
    If $iFlash Then
        GUICtrlSetColor($Label, 0xFF0000)
        Return
    EndIf
    GUICtrlSetColor($Label, 0x000000)
EndFunc

Share this post


Link to post
Share on other sites



zxcvbnm,

Next time, just post in the same thread where I gave you this code. :shifty:

You need to keep the script alive if you want the GUI the remain visible, so you need another loop. And you will then need something like a HotKey to kill it in the end. :x

So take a look a this:

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

; Set a HotKey to exit
HotKeySet("{ESC}", "On_Exit")

Global $iMin = 1, $iSec = 32, $iFlash = 0, $neg = 0, $iTimerProgress

$Form1 = GUICreate("Count Down", 250, 70, 125, 125, BitOR($WS_DLGFRAME, $WS_POPUP), $WS_EX_TOPMOST)
GUISetBkColor(0x66FF00)

$Label = GUICtrlCreateLabel(StringFormat("%02d:%02d", $iMin, $iSec), 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG)
;$Label = GUICtrlCreateLabel("", 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 40, 800, 0, "verdana")

GUISetState(@SW_SHOW)

;AutoItSetOption ( "TrayIconHide" ,1 )

; Start a timer for the countdown
$iTimerProgress = _Timer_SetTimer($Form1, 5, "_CountDown") ; Call once a sec
; Set a placeholder for the Flash timer
$iFlash_Timer = 9999

; Loop until you get to the correct value
Do
    Sleep(10)
Until $iMin = (-1) And $iSec = 59

; Kill the Progress Timer
_Timer_KillTimer($Form1, $iTimerProgress)

; Keep the scipt alive
While 1
    Sleep(10)
WEnd

; When you exit, kill the Flash timer
Func On_Exit()
    _Timer_KillTimer($Form1, $iFlash_Timer)
    Exit
EndFunc

Func _CountDown($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing!
    ; We call it once a sec, so just reduce by 1 sec each time
    If $iMin > 0 Then
        $iSec -= 1
        If $iSec < 0 Then
            $iSec = 59
            $iMin -= 1
        EndIf
        GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec))
    ElseIf $iMin = 0 And $neg = 0 Then
        $iSec -= 1
        If $iSec = 0 Then
            $neg = 1
        EndIf
        GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec))
    ElseIf $iMin = 0 And $neg = 1 Then
        $iSec += 1
        GUICtrlSetData($Label, StringFormat("-" & "%02d:%02d", $iMin, $iSec))
        If $iSec > 59 Then
            $iSec = 0
            $iMin -= 1
            GUICtrlSetData($Label, StringFormat("%03d:%02d", $iMin, $iSec))
        EndIf
    ElseIf $iMin < 0 And $neg = 1 Then
        $iSec += 1
        If $iSec > 59 Then
            $iSec = 0
            $iMin -= 1
        EndIf
        GUICtrlSetData($Label, StringFormat("%03d:%02d", $iMin, $iSec))
    EndIf
    If $iMin = 2 And $iSec = 30 Then
        GUISetBkColor(0xFFFF00)
    EndIf
    If $iMin = 0 And $iSec = 30 Then
        GUISetBkColor(0xFF0000)
    EndIf
    If $iMin = 0 And $iSec = 0 Then
        $iFlash_Timer = _Timer_SetTimer($Form1, 50, "_Flash") ; Start a second timer to flash
    EndIf

EndFunc   ;==>_CountDown
Func _Flash($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing!
    $iFlash = Not $iFlash
    If $iFlash Then
        GUICtrlSetColor($Label, 0xFF0000)
        Return
    EndIf
    GUICtrlSetColor($Label, 0x000000)
EndFunc   ;==>_Flash

All clear? :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks, but I don't need of a Hotkey, because it must be close by an external script!

Share this post


Link to post
Share on other sites

what do you think about this:

;HotKeySet("{ESC}", "On_Exit")

GUISetOnEvent($GUI_EVENT_CLOSE, "On_Exit")
.
.
Func On_Exit()
    _Timer_KillTimer($Form1, $iFlash_Timer)
    Exit
EndFunc

when the external script kill the pop up the Flash_Timer is killed

Share this post


Link to post
Share on other sites

zxcvbnm,

If an external script kills the pop-up, the $GUI_EVENT_CLOSE message will not be sent by the pop-up so that code will never run. And you cannot use OnAutoItExitRegister if you are going to kill the process externally from another script (I have just tested to see). :shifty:

So you are into some form of inter-script communication which will add a lot of complexity to both scripts. Why can you not run the pop-up as a function within the other script? :x

I am happy to help you try and get it to work as separate scripts. but it would be a lot simpler if you could combine them. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

now I have only a vbscript that exec a query from win32process using the name of the .exe application to find it.

The two should remain separate because scripts are executed at different times.

Share this post


Link to post
Share on other sites

zxcvbnm,

While I am trying to find out if we need to kill the _Timer before the pop-up script itself is ended by your other app, is there anything else that happens that we might recognise and so use to end the pop-up gracefully? Does a process begin or end? Is a GUI created or closed? :x

If we can find something that the pop-up script will recognise, we can use OnAutoItExitRegister to kill the _Timer and the problem becomes moot. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I could possibly use another autoit application to close the first, I have no obligations on the choice of the executable, but the two should remain separate because scripts are executed at different times and I don't know when, it's depends on the user.

In this way is it possible to kill _Timer?

Share this post


Link to post
Share on other sites

zxcvbnm,

I am just concerned that not killing the _Timer might affect the system somehow. :x

Can your other script set an environment variable - that might be one way to tell the pop-up to close? :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

>I am just concerned that not killing the _Timer might affect the system somehow. :x

I hope no....so what about my pc?

Ok I try to realize a script in auoit that finds and kills my_app.exe, what I can use to kill _timer of my_app.exe?

Share this post


Link to post
Share on other sites

zxcvbnm,

I try to realize a script in auoit that finds and kills my_app.exe, what I can use to kill _timer of my_app.exe?

That is exactly the problem - if you kill the script I am not sure that you also kill the _Timer and I do not know what effect that has. :x

That is why I am asking if there is some way we can get the script to end itself by recognising that it is time to go - a change to a GUI or a process, or the setting of an environmental variable. :shifty:

Just be patient and I will get back to you. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I begin to stop flashing when the timer arrive to 59 and 59, so ...is the problem solved?

In this way I stop both timer, so where is the right way to kill 'my_app' now?

Share this post


Link to post
Share on other sites

zxcvbnm,

If you have killed both _Timers within the script then you can end it however your other app wishes! :P The normal AutoIt command to do this would be ProcessClose.

I will still look into whether the _Timer needs to be closed and will update this topic when I can. :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

thanks a lot!

Share this post


Link to post
Share on other sites

unfortunately I can not stop the two timers, as the app. exe will be executed and killed by an external script at least 100 times a day. I do not know when it will be the moment that depends on the user will be killed!

Share this post


Link to post
Share on other sites

if you did not use the two timer and I should add two labels only one draggable, while the other is with the count, is it possible?

Share this post


Link to post
Share on other sites

zxcvbnm,

If both the labels are in the same script then the problem remains. :shifty:

And despite lots of searching I am afraid I am no closer to finding out if there might be a problem if we do not kill the timers. :nuke:

However, you have never given me a reply to the questions I asked you earlier:

is there anything else that happens that we might recognise and so use to end the pop-up gracefully? Does a process begin or end? Is a GUI created or closed? [...] Can your other script set an environment variable?

What event makes leads your other script to end this AutoIt timer GUI? Perhaps we can use that. :x

If we can find something to use as a trigger for a graceful exit we can kill the timers as we leave, which would solve the problem. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

the timer should start opening a popup of a active background program, in closing I don't have related event!

Share this post


Link to post
Share on other sites

Melba, zxcvbnm,

Let me throw two cents in:

scripts with timers set "guiregistermsg(WM_CLOSE)"

use "handle" from script issueing WM_CLOSE to exit each script

Also,

The comments in your script say that you are setting _countdown to run a 1 sec intervals, it looks to me like it is running at 5 MS intervals..

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

I confirm that the execution is 1 second. example is 5 seconds to accelerate the implementation and review its status changes more quickly

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