computerguy4513 Posted August 23, 2021 Posted August 23, 2021 (edited) Basically have an application automation install script for unattended deployment, and sometimes a windows firewall exception dialog pops up, and sometimes it doesn't. The script currently is set to wait for the two times it pops up, and click ok. Trouble is, when the boxes never pop up, or only one pops up, the script just sits there forever waiting for the popup, and causes havoc to my process. I need the script to essentially check for the pop up box for...30 secs? And if it doesn't pop up, end the script. Is this possible? Thanks guys! Edited August 23, 2021 by computerguy4513
Dan_555 Posted August 23, 2021 Posted August 23, 2021 (edited) I would do something like this; $timer=TimerInit() $quit=0 Do if WinActive("YourWindowTitleHere") then $quit=1 if TimerDiff($timer)>30000 then $quit=2 ;either $quit=2 or exit here EndIf Until $quit>0 If $quit=2 then Exit Edited August 23, 2021 by Dan_555 Loc 1 Some of my script sourcecode
BigDaddyO Posted August 23, 2021 Posted August 23, 2021 (edited) if you are using WinWait for the popup, there is a timeout option you can set to 30. if WinWait("Firewall", "", 30) = 0 then exit Edited August 23, 2021 by BigDaddyO seadoggie01 1
Musashi Posted August 23, 2021 Posted August 23, 2021 (edited) Wouldn't WinWaitActive do the same, if one set the optional timeout parameter ? EDIT : @BigDaddyO was a bit faster . Yes, WinWait also has an optional timeout parameter. Edited August 23, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
computerguy4513 Posted August 23, 2021 Author Posted August 23, 2021 Will give it a shot! Thanks guys!
computerguy4513 Posted August 23, 2021 Author Posted August 23, 2021 1 hour ago, BigDaddyO said: if you are using WinWait for the popup, there is a timeout option you can set to 30. if WinWait("Firewall", "", 30) = 0 then exit Just so I understand: ;Windows Security Alert WinWait('Windows Security Alert') WinWaitActive('Windows Security Alert') WinActivate('Windows Security Alert') ;Allow Access(Default) ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') ;Sleep(5000) ;Windows Security Alert WinWait('Windows Security Alert') WinWaitActive('Windows Security Alert') WinActivate('Windows Security Alert') ;Allow Access(Default) ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') In this case, I want the = 0 then exit on the second one to end the script, correct? Or is the exit portion just for that one line, and I'd want to put that on the end of each?
Nine Posted August 23, 2021 Posted August 23, 2021 Isn't that something like this rather ? ; do something before CheckSecurityAlert() ; do some other things here CheckSecurityAlert() ; finalize script after Func CheckSecurityAlert() If WinWait('Windows Security Alert', "", 30) Then WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') EndIf EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
computerguy4513 Posted August 23, 2021 Author Posted August 23, 2021 25 minutes ago, Nine said: Isn't that something like this rather ? ; do something before CheckSecurityAlert() ; do some other things here CheckSecurityAlert() ; finalize script after Func CheckSecurityAlert() If WinWait('Windows Security Alert', "", 30) Then WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') EndIf EndFunc Ahhh I see. So it will check it once, if it's there, it'll close it, then wait again, if it doesn't see one again in 30 secs, it will end the script?
Nine Posted August 23, 2021 Posted August 23, 2021 Yes I believe this is what it should be, right ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JockoDundee Posted August 23, 2021 Posted August 23, 2021 2 hours ago, Nine said: Yes I believe this is what it should be, right ? Maybe this to be safe? ; do something before CheckSecurityAlert() ; do some other things here CheckSecurityAlert() ; finalize script after Func CheckSecurityAlert() If WinWait('Windows Security Alert', "", 30) Then WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') Else Exit EndIf EndFunc Since you may not want to “do some other things here” if you timeout Code hard, but don’t hard code...
Nine Posted August 23, 2021 Posted August 23, 2021 (edited) Really ? If there is no security alert then exit ? Really ? So you absolutely want a security alert ? Edited April 14 by Nine JockoDundee 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JockoDundee Posted August 23, 2021 Posted August 23, 2021 1 hour ago, Nine said: Really ? If there is no security alert then exit ? Really ? Asking for a friend 7 hours ago, computerguy4513 said: I need the script to essentially check for the pop up box for...30 secs? And if it doesn't pop up, end the script. Code hard, but don’t hard code...
computerguy4513 Posted August 24, 2021 Author Posted August 24, 2021 (edited) If WinWait('Windows Security Alert', "", 30) = 0 then exit WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') If WinWait('Windows Security Alert', "", 30) = 0 then exit WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') So it looks like when I run this, the script ends after 30 secs, or if the windows firewall box pops up, and clicks ok. Instead of the "then exit" in the first winwait, is there a bit of code that will tell it to go on if there WAS a popup box within 30 secs which was answered, so it will check for a second before ending? I'm REAL close, and appreciative of those helping out. Edited August 24, 2021 by computerguy4513
ViciousXUSMC Posted August 24, 2021 Posted August 24, 2021 I had some kind of crazy Oracle installer that gave me a random box that would break automation. I handled it in a different way. Because I had no idea when it would pop up rather than being in sequence I simply had a AdlibRegister() function checking for that pop up window and if it came up, it would close it. Worked well for me.
computerguy4513 Posted August 24, 2021 Author Posted August 24, 2021 5 minutes ago, ViciousXUSMC said: I had some kind of crazy Oracle installer that gave me a random box that would break automation. I handled it in a different way. Because I had no idea when it would pop up rather than being in sequence I simply had a AdlibRegister() function checking for that pop up window and if it came up, it would close it. Worked well for me. I'll look into it, I'm admittedly not a coder, so I have no idea what that function is, or how to use it properly.
computerguy4513 Posted August 24, 2021 Author Posted August 24, 2021 (edited) ;Sleep(5000) ;Windows Security Alert If WinWait('Windows Security Alert', "", 30) = 1 then WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') Else If WinWait('Windows Security Alert', "", 30) = 1 then WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') Else If WinWait('Windows Security Alert', "", 30) = 0 then exit EndIf EndIf So I REALLY thought this was going to work. However when I ran the install, the script runs, sits in the system tray, and when the Firewall Security box pops up, the script ends, and disappears from the task tray. I want this script to wait for 30 secs, does the firewall dialog open? -No? Exit. -Yes? Click Allow, and wait for another 30 secs to see if the second Firewall dialog opens. Second dialog opens? - No? Exit. -Yes? Click Allow, then exit script. Like I said, I'm absolutely NOT a programmer by any means, but giving it my best. I feel like the above code SHOULD do that? What am I missing? Edited August 24, 2021 by computerguy4513
Nine Posted August 24, 2021 Posted August 24, 2021 (edited) WinWait returns 0 OR handle (see help file). So your 1 is incorrect. Try this : ;Windows Security Alert (first attempt) If Not WinWait('Windows Security Alert', "", 30) then Exit WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') ;Windows Security Alert (second attempt) If Not WinWait('Windows Security Alert', "", 30) then Exit WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') Exit Edited August 24, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
computerguy4513 Posted August 24, 2021 Author Posted August 24, 2021 17 minutes ago, Nine said: WinWait returns 0 OR handle (see help file). So your 1 is incorrect. Try this : ;Windows Security Alert (first attempt) If Not WinWait('Windows Security Alert', "", 30) then Exit WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') ;Windows Security Alert (second attempt) If Not WinWait('Windows Security Alert', "", 30) then Exit WinActivate('Windows Security Alert') WinWaitActive('Windows Security Alert') ControlClick('Windows Security Alert','','[CLASS:Button;INSTANCE:6]') Exit That worked for the first dialog, clicked ok, then the script closed. BUT! That's a step in the right direction! Thank you very much! I'm learning a lot. I tried putting a "then" statement in the middle, to chain it together...but that didn't work. Maybe a loop of some kind? Which I have no idea how to do. LOL
Solution Nine Posted August 24, 2021 Solution Posted August 24, 2021 Ho. I got it. Put a Sleep (3000) in between the 2 blocks of code ! It will wait for closure before executing the second attempt... JockoDundee and computerguy4513 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
computerguy4513 Posted August 24, 2021 Author Posted August 24, 2021 5 minutes ago, Nine said: Ho. I got it. Put a Sleep (3000) in between the 2 blocks of code ! It will wait for closure before executing the second attempt... THAT FREAKING WORKED!!!! THANK YOU SO MUCH!
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