Dirk98 Posted December 11, 2007 Share Posted December 11, 2007 Guys, in my script I have a line that waits until a certain browser's window pops up (goes active). Then, when it is active, the code shoots a salvo of different instructions and self-terminates quitely. But sometimes, in practice, if the ISP line is down the script hangs up because the required window never goes active. Instead I get something like: "Internet Explorer cannot display bla bla bla...". I nee to add a module, that would wait 90 sec for the required window to go active and if it does not happen, it would take over the control and pass it to the next part that is executed ONLY if/when the main part has failed (not been activated). Any ideas or your techniques, please? Many thanks. Dirk. Link to comment Share on other sites More sharing options...
DW1 Posted December 11, 2007 Share Posted December 11, 2007 should be easy, lets see some code, and I'll help you. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Fossil Rock Posted December 11, 2007 Share Posted December 11, 2007 Look up AdlibEnable() Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Dirk98 Posted December 11, 2007 Author Share Posted December 11, 2007 should be easy, lets see some code, and I'll help you. Thanks, danwilli. Below are principal lines from the script and my notes: expandcollapse popup$netname = "LAN connection" $newIp = "192.168.7.79" $newSubnet = "255.255.255.0" $newDG = "192.168.7.1" $newDNSP = "192.168.9.17" $newDNSS = "213.251.192.29" ;------------------------------------------------------------------------------------ runwait ('netsh interface ip set address name=' & '"' & $netname & '" static ' & $newIP & ' '& $newSubnet & ' ' & $newDG & ' 1',"",@SW_Hide) runwait ('netsh interface ip set dns name=' & '"' & $netname & '" static ' & $newDNSP & ' primary',"",@SW_Hide) runwait ('netsh interface ip add dns name=' & '"' & $netname & '" addr=' & $newDNSS & ' index=2') ShellExecute ('https://192.168.9.17/login/') WinWaitActive ( "Security System Warning" ); <-- If ISP is down this window (uplet) never comes up ControlClick ( "Security System Warning", "", 1 ) WinWaitActive ( "Your Start Page - Microsoft Internet Explorer" );<-- If ISP is down then this window doesn't connect ; and instead the script hangs at "Internet Explorer cannot display the webpage" ;--------------------------------------------------------------------------------------------- ; here go the lines of my login information if ISP is up ;-------------------------------------------------------------------------------------------- ; If ISP is down I want the following module to take over and execute: $netname = "LAN connection" $newIp = "192.168.3.39" $newSubnet = "255.255.255.0" $newDG = "192.168.3.1" $newDNSP = "212.188.4.10" $newDNSS = "195.34.32.116" runwait ('netsh interface ip set address name=' & '"' & $netname & '" static ' & $newIP & ' '& $newSubnet & ' ' & $newDG & ' 1',"",@SW_Hide) runwait ('netsh interface ip set dns name=' & '"' & $netname & '" static ' & $newDNSP & ' primary',"",@SW_Hide) runwait ('netsh interface ip add dns name=' & '"' & $netname & '" addr=' & $newDNSS & ' index=2') Sleep(1000) ShellExecute ('http://www.whatismyip.com/') Sleep(1000) ; script terminates here Link to comment Share on other sites More sharing options...
BobTheEponge Posted December 11, 2007 Share Posted December 11, 2007 use Winactive("title") instead of winWaitActive Example : $t = 0 while $t < 90 if Winactive("my window") then do my stuff endif sleep(1000) $t = $t+1 Wend it Checks every second if your window is active. Link to comment Share on other sites More sharing options...
DW1 Posted December 11, 2007 Share Posted December 11, 2007 (edited) here is a func I wrote up for you, it should be self explanitory... if not, just ask If TimedWinWait("Untitled - Notepad", 5) Then MsgBox(0, "TEST", "win exists") Else MsgBox(0, "TEST", "win does NOT exist") EndIf Func TimedWinWait($windowname, $timeout) $timer = TimerInit() While TimerDiff($timer) < ($timeout * 1000) If WinExists($windowname) Then Return True EndIf Sleep(10) WEnd Return False EndFunc ;==>TimedWinWait Edited December 11, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted December 11, 2007 Share Posted December 11, 2007 Did that work for you Dirk? or do you need further assistance? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Dirk98 Posted December 11, 2007 Author Share Posted December 11, 2007 (edited) Did that work for you Dirk? or do you need further assistance?Guys, thank you very much, it's getting too late here to check anything. Danwilli, I'll surely post the result. Thanks again. Looks really good on the first glance.Dirk. Edited December 11, 2007 by Dirk98 Link to comment Share on other sites More sharing options...
Dirk98 Posted December 12, 2007 Author Share Posted December 12, 2007 Guys, thank you very much, it's getting too late here to check anything. Danwilli, I'll surely post the result. Thanks again. Looks really good on the first glance.Dirk.Danwilli, it works perfect! Nice trigger I've been looking for. Off to bed and happy. Thanks.Dirk. 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