Jump to content

Timeout for program error.


Recommended Posts

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

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

Use WinWaitActive with a timeout parameter. If the return is 0 then do something - see the help.

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?


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


martin
            
            
                Posted 
                
            
        
    
    
        


martin
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                MVPs
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 7.1k
                            
                                
                            
                        
                        
                            
                                
                                    
                                        
                                        3
                                
                                    
                                
                            
                        
                    
                
            
            
                

    
    
        
~~\o/~~~/0\=¬''~~~
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                    (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 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

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