Jump to content

If / Then error


Iceburg
 Share

Recommended Posts

I have 2 windows that update all day long, they refresh every minute. I want to keep a script going in an infinite loop at if one goes into the page not found state, it will close it, the other one, and then open then both up again.

There are 4 possibilities:

Both in page not found

Neither in page not found

one in page not found

the other in page not found

With an if else statement I want to check for a page not found if it exists, close all the windows and then click on the x,y to reopen them.

Here is what I have so far, and its not working, can someone point me in a direction to take this?

If WinExists("Cannot find server - Microsoft Internet Explorer") Then
             (WinActivate("Cannot find server - Microsoft Internet Explorer", "")
             Sleep (1000) 
         WinClose("Cannot find server - Microsoft Internet Explorer", "") 
         WinActivate("Cannot find server - Microsoft Internet Explorer", "")
         Sleep (1000) 
         WinClose("Cannot find server - Microsoft Internet Explorer", "")
         WinActivate("SiteScope Overview - Microsoft Internet Explorer", "") 
         Sleep (1000) 
         WinClose("Cannot find server - Microsoft Internet Explorer", "") 
     WinActivate("http://apmcso.mercuryportal.com/schedule/esupport.asp?view=1 - Microsoft Internet Explorer", "") 
         Sleep (1000) 
     WinClose("http://apmcso.mercuryportal.com/schedule/esupport.asp?view=1 - Microsoft Internet Explorer", "") 
      MouseMove ( 13, 45, 0) 
      Sleep(2000) 
      MouseClick("left", 13, 45, 1) 
      MouseMove ( 36, 45, 0) 
      Sleep(1000) 
      MouseClick("left", 36, 45, 1))
    
    EndIf
Edited by Larry
Link to comment
Share on other sites

If WinExists("Cannot find server - Microsoft Internet Explorer") Then; single line if..then statements don't use endif.
            
WinActivate("Cannot find server - Microsoft Internet Explorer", "")
            Sleep (1000)
         WinClose("Cannot find server - Microsoft Internet Explorer", "")
         WinActivate("Cannot find server - Microsoft Internet Explorer", ""); you just closed it?
         Sleep (1000)
         WinClose("Cannot find server - Microsoft Internet Explorer", "")
         WinActivate("SiteScope Overview - Microsoft Internet Explorer", "")
         Sleep (1000)
         WinClose("Cannot find server - Microsoft Internet Explorer", "")
    WinActivate("http://apmcso.mercuryportal.com/schedule/esupport.asp?view=1 - Microsoft Internet Explorer", "")
         Sleep (1000)
    WinClose("http://apmcso.mercuryportal.com/schedule/esupport.asp?view=1 - Microsoft Internet Explorer", "")
      MouseMove ( 13, 45, 0); you closed everything, are you clicking desktop?
      Sleep(2000)
      MouseClick("left", 13, 45, 1)
      MouseMove ( 36, 45, 0)
      Sleep(1000)
      MouseClick("left", 36, 45, 1))
    
    EndIf

might help, but I don't see your code to open any windows. I would normally think to have it close any window called Cannot find server, and to then open your browser back to the right page.

You may also want to log it, or to rename the page so that you can track when it refreshes.

Mouseclick pages are not the best for explorer windows most times, I tend to use a find and send the keys, but to each his/her own.

You can use this after the if to remove all Cannot find server windows:

while WinExists("Cannot find server - Microsoft Internet Explorer")  
WinClose("Cannot find server - Microsoft Internet Explorer", "")
sleep(10)
wend

if they are stubborn you can use winkill()

Anyway hope it helps you move in the right direction.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

I would suggest not using mouseclicks etc to open the browser. Use Run with parameters to open the website you want. Then the script you are writing will not interfere with whatever else you may be doing.

Also, you shouldn't need to activate the windows unless you are wanting to see them close, which may happen fast enough that you may not notice anyways. You can eliminate your sleeps and... you are running this in a loop correct? I will assume you are. Place a sleep outside of the main function of the script for say 100 or so.

*edit* Yeah use a while/wend loop, more efficient.

Edited by KnowledgeSponge
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...