Jump to content

continue to flash


zxcvbnm
 Share

Recommended Posts

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

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