Jump to content
Sign in to follow this  
notbillcosby

I'm a stupid newbie who wants to learn.

Recommended Posts

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? :lmao:

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

Share this post


Link to post
Share on other sites

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? :lmao:

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

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Yes, read up 'WinActive' and make a new If statement :lmao:


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

Share this post


Link to post
Share on other sites

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 by GraveReaper0

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...