zxcvbnm Posted January 13, 2011 Share Posted January 13, 2011 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? expandcollapse popup#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 More sharing options...
Moderators Melba23 Posted January 13, 2011 Moderators Share Posted January 13, 2011 zxcvbnm,Next time, just post in the same thread where I gave you this code. 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. So take a look a this:expandcollapse popup#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 ;==>_FlashAll clear? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 13, 2011 Author Share Posted January 13, 2011 Thanks, but I don't need of a Hotkey, because it must be close by an external script! Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 13, 2011 Author Share Posted January 13, 2011 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2011 Moderators Share Posted January 14, 2011 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). 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? 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 14, 2011 Author Share Posted January 14, 2011 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2011 Moderators Share Posted January 14, 2011 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? 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 14, 2011 Author Share Posted January 14, 2011 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 More sharing options...
Moderators Melba23 Posted January 14, 2011 Moderators Share Posted January 14, 2011 zxcvbnm,I am just concerned that not killing the _Timer might affect the system somehow. Can your other script set an environment variable - that might be one way to tell the pop-up to close? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 14, 2011 Author Share Posted January 14, 2011 >I am just concerned that not killing the _Timer might affect the system somehow. 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 More sharing options...
Moderators Melba23 Posted January 14, 2011 Moderators Share Posted January 14, 2011 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. 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. Just be patient and I will get back to you. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 14, 2011 Author Share Posted January 14, 2011 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? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2011 Moderators Share Posted January 14, 2011 zxcvbnm,If you have killed both _Timers within the script then you can end it however your other app wishes! 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 14, 2011 Author Share Posted January 14, 2011 thanks a lot! Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 15, 2011 Author Share Posted January 15, 2011 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! Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 18, 2011 Author Share Posted January 18, 2011 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? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2011 Moderators Share Posted January 18, 2011 zxcvbnm, If both the labels are in the same script then the problem remains. 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. 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. 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zxcvbnm Posted January 19, 2011 Author Share Posted January 19, 2011 the timer should start opening a popup of a active background program, in closing I don't have related event! Link to comment Share on other sites More sharing options...
kylomas Posted January 19, 2011 Share Posted January 19, 2011 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 More sharing options...
zxcvbnm Posted January 19, 2011 Author Share Posted January 19, 2011 I confirm that the execution is 1 second. example is 5 seconds to accelerate the implementation and review its status changes more quickly Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now