Testy Posted March 7, 2008 Share Posted March 7, 2008 Script gets stuck waiting for a window. If the program encounters an error and the needed window doesn't show, it will get stuck waiting. Func login() WinWaitActive("Sign On") Sleep(1000) Send("user{TAB}") Send("password{ENTER}") timeout() EndFunc Func timeout() (, 0, 3000) EndFunc Won't timeout. Link to comment Share on other sites More sharing options...
martin Posted March 7, 2008 Share Posted March 7, 2008 Script gets stuck waiting for a window. If the program encounters an error and the needed window doesn't show, it will get stuck waiting. Func login() WinWaitActive("Sign On") Sleep(1000) Send("user{TAB}") Send("password{ENTER}") timeout() EndFunc Func timeout() (, 0, 3000) EndFunc Won't timeout. Use WinWaitActive with a timeout parameter. If the return is 0 then do something - see the help. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Testy Posted March 7, 2008 Author Share Posted March 7, 2008 Use WinWaitActive with a timeout parameter. If the return is 0 then do something - see the help. Ha ha... Check it expandcollapse popup Func login() WinWaitActive("Sign On", "", 10) Sleep(1000) Send("user{TAB}") Send("password{ENTER}") EndFunc Read the helpfile, and got an interesting result. While the timer works, it will however pop to the next button on the tab and runs it. WTF? Link to comment Share on other sites More sharing options... martin Posted March 7, 2008 martin MVPs 7.1k 3 ~~\o/~~~/0\=¬''~~~ Share Posted March 7, 2008 (edited) Ha ha... Check it Func login() WinWaitActive("Sign On", "", 10) Sleep(1000) Send("user{TAB}") Send("password{ENTER}") EndFunc Read the helpfile, and got an interesting result. While the timer works, it will however pop to the next button on the tab and runs it. WTF? You didn't pay full attention to my post. You have to check to see what WinWaitActive returns. If it returns 0 it means it timed out so you have to take some appropriate action. Without checking it will continue with the next line whatever the result. Func login() if WinWaitActive("Sign On", "", 10) = 0 then MsgBox(0,'failed', '"Sign On" window did not appear before I got bored') return -1;failed endif Sleep(1000) Send("user{TAB}") Send("password{ENTER}") EndFunc Edited March 7, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts