notbillcosby Posted March 2, 2005 Posted March 2, 2005 Hello... I'm painfully new to this, and I'm trying to flip my way through the help files to figure out how to write a script to do what I'm trying to do. I'm getting bits and pieces, but not quite enough to get the job done. Anyone feel like helping? Alright, for those still reading... Here's what I'm trying to do: There is a website I keep open that refreshes itself every 30 seconds. Occasionally, for whatever reason, I don't connect properly to the server and I get a "Page Cannot be Displayed" page in Internet Explorer. Hitting F5 reloads the page and gets me back on track. I'd like to write a script that can automatically refresh the page after getting the "cannot be displayed" message, so I don't have to keep babysitting it. Is this possible without too much work? Can someone help me figure it out? Thanks in advance, Ian
Blue_Drache Posted March 2, 2005 Posted March 2, 2005 Hello... I'm painfully new to this, and I'm trying to flip my way through the help files to figure out how to write a script to do what I'm trying to do. I'm getting bits and pieces, but not quite enough to get the job done. Anyone feel like helping? Alright, for those still reading... Here's what I'm trying to do:There is a website I keep open that refreshes itself every 30 seconds. Occasionally, for whatever reason, I don't connect properly to the server and I get a "Page Cannot be Displayed" page in Internet Explorer. Hitting F5 reloads the page and gets me back on track. I'd like to write a script that can automatically refresh the page after getting the "cannot be displayed" message, so I don't have to keep babysitting it. Is this possible without too much work? Can someone help me figure it out?Thanks in advance,Ian<{POST_SNAPBACK}>Unfortunately, IE is very difficult to work with, much less get anything out of.Here's an idea, does the title of the window change when the "Page Cannot be Displayed" error crops up? Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
notbillcosby Posted March 2, 2005 Author Posted March 2, 2005 Unfortunately, IE is very difficult to work with, much less get anything out of.Here's an idea, does the title of the window change when the "Page Cannot be Displayed" error crops up?<{POST_SNAPBACK}>Sure does, changes to "Cannot find server - Microsoft Internet Explorer"
ioliver Posted March 2, 2005 Posted March 2, 2005 Try: $title = WinGetTitle("- Microsoft Internet Explorer") If $title = "Cannot find server - Microsoft Internet Explorer" Then Send("{F5}") EndIf Also, in case I'm wrong b/c I haven't tested this code, I just wrote it in the window, search the help file for 'WinGetTitle', and 'Send'. Hope that helps, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
SlimShady Posted March 2, 2005 Posted March 2, 2005 I just made this for you. Opt("WinTitleMatchMode", 2) ;Change mode to match substrings in titles While 1 ;Create infinite loop Sleep(2 * 1000) ;Sleep 2 seconds each time, before continuing If WinExists("Cannot find server") Then ControlSend("Cannot find server", "", "", "^{F5}") ;Send Ctrl+F5 WEnd
GraveReaper0 Posted March 3, 2005 Posted March 3, 2005 SlimShady, quick question, wonder if you can answer. Is there a way for the script to only refresh if the Cannot Find Server title would be there for longer than lets say 20 seconds? What I mean is,if the Error is there for only couple seconds, I dont want the script to do anything, but if it was there for more then 10 seconds, only then I would want it to refresh. Is there a way to do that?
notbillcosby Posted March 3, 2005 Author Posted March 3, 2005 I just made this for you.Opt("WinTitleMatchMode", 2) ;Change mode to match substrings in titles While 1 ;Create infinite loop Sleep(2 * 1000) ;Sleep 2 seconds each time, before continuing If WinExists("Cannot find server") Then ControlSend("Cannot find server", "", "", "^{F5}") ;Send Ctrl+F5 WEnd<{POST_SNAPBACK}>This does exactly what I want, but with one flaw: The script does not reload the page unless the IE window is the active window. Any way to change that?By the way, thanks for the help!
Insolence Posted March 3, 2005 Posted March 3, 2005 Yes, read up 'WinActive' and make a new If statement "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
GraveReaper0 Posted March 3, 2005 Posted March 3, 2005 (edited) So something like this? If WinActive("Cannot find server") Then Opt("WinTitleMatchMode", 2) ;Change mode to match substrings in titles While 1 ;Create infinite loop Sleep(2 * 1000) ;Sleep 2 seconds each time, before continuing If WinExists("Cannot find server") Then ControlSend("Cannot find server", "", "", "^{F5}") ;Send Ctrl+F5 WEnd EndIf EDIT: Actually It hink the WinActive and While commands would have to switch around, so.. While1 If WinActive("Cannot find server") Then Sleep(2 * 1000) ;Sleep 2 seconds each time, before continuing If WinExists("Cannot find server") Then ControlSend("Cannot find server", "", "", "^{F5}") ;Send Ctrl+F5 EndIf Wend Edited March 3, 2005 by GraveReaper0
MHz Posted March 3, 2005 Posted March 3, 2005 This should work? Opt ("WinTitleMatchMode", 2);Change mode to match substrings in titles ; User variables $time = 2000; 1000 is 1 second. $title = 'Cannot find server'; SubString of title name ; The never-ending loop While 1 If WinExists($title) Then WinActivate($title) Sleep($time); Sleep before continuing. If WinActive($title) Then ControlSend($title, "", "", "^{F5}");Send Ctrl+F5 EndIf WEnd
Neoborn Posted March 19, 2005 Posted March 19, 2005 This should work?Opt ("WinTitleMatchMode", 2);Change mode to match substrings in titles ; User variables $time = 2000; 1000 is 1 second. $title = 'Cannot find server'; SubString of title name ; The never-ending loop While 1 If WinExists($title) Then WinActivate($title) Sleep($time); Sleep before continuing. If WinActive($title) Then ControlSend($title, "", "", "^{F5}");Send Ctrl+F5 EndIf WEnd<{POST_SNAPBACK}>Would be nice for a reply on this, if it worked or not and if it did perhaps a thank you is in order ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT
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