Jump to content
Sign in to follow this  
gsc

Restart script if winwait doesn't happen

Recommended Posts

gsc

Hi All,

Please excuse my dumbness! I am not a great scripter but have been working on a script for a friend how has had issues with their internet. I have created a script to Ping something like Google if no connection it then runs a script, however, if the issue is with the router rebooting due to a power surge and the page doesn't load, how can I get the script to reboot and start from the beginning?

While 1
$var = Ping("www.google.com")

If not @error Then
MouseMove (0, 728)
MouseClick ("left")
Sleep (500)
MouseClick ("left")
Sleep (1000000)
Else
MouseMove (150, 749)
MouseClick ("left")
Sleep (500)
MouseClick ("left")
run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://192.168.1.1/setup.cgi?next_file=RST_st_poe.htm","")
WinWaitActive("Windows Security")
ControlClick("Windows Security", "", "[CLASS:Edit; INSTANCE:1]")
Send ("{CTRLDOWN}")
Send ("a")
Send ("{CTRLUP}")
Sleep (500)
Send ("****")
Sleep (500)
Send ("{TAB}")
Sleep (500)
Send ("*****")
Sleep (500)
Send ("{ENTER}")
Sleep (5000)
WinWaitActive("NETGEAR Router DGND3700v2 - Windows Internet Explorer")
Send ("{ALTDOWN}")
Sleep (100)
Send ("{SPACE}")
Sleep (100)
Send ("{ALTUP}")
Sleep (500)
Send ("x")
Sleep (3000)
MouseMove (733, 88)
MouseClick ("left")
Sleep (5000)
MouseMove (657, 265)
MouseClick ("left")
Sleep (5000)
ControlClick("Windows Internet Explorer", "", "[CLASS:Button; INSTANCE:1]")
Endif
WEnd

So if the WinWaitActive("Windows Security") isn't found, how can it tell the script to start again?

Please not that the below bit after ELSE is to close all current windows:

MouseMove (150, 749)

MouseClick ("left")

Sleep (500)

MouseClick ("left")

Thanks in advance for any help :)

GSC

Share this post


Link to post
Share on other sites
Mechaflash

if not WinWaitActive("Windows Security", "", [Timeout]) then ContinueLoop

Edited by Mechaflash

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites
gsc

But will that actually restart the loop? as the next item is the controlclick the window it is waiting for? but it cannot if it doesn't load?

Share this post


Link to post
Share on other sites
FireFox

Hi,

Try this :

While 1
    Sleep(10)
    _MyFunc()
WEnd

Func _MyFunc()
    Local Const $iTimeout = 5
    Local $var = Ping("www.google.com")

    If Not @error Then
        MouseMove(0, 728)
        MouseClick("left")
        Sleep(500)
        MouseClick("left")
        Sleep(1000000)
    Else
        MouseMove(150, 749)
        MouseClick("left")
        Sleep(500)
        MouseClick("left")
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://192.168.1.1/setup.cgi?next_file=RST_st_poe.htm")
        If WinWaitActive("Windows Security", "", $iTimeout) = 0 Then Return
        ControlClick("Windows Security", "", "[CLASS:Edit; INSTANCE:1]")
        Send("{CTRLDOWN}")
        Send("a")
        Send("{CTRLUP}")
        Sleep(500)
        Send("****")
        Sleep(500)
        Send("{TAB}")
        Sleep(500)
        Send("*****")
        Sleep(500)
        Send("{ENTER}")
        Sleep(5000)
        If WinWaitActive("NETGEAR Router DGND3700v2 - Windows Internet Explorer", "", $iTimeout) = 0 Then Return
        Send("{ALTDOWN}")
        Sleep(100)
        Send("{SPACE}")
        Sleep(100)
        Send("{ALTUP}")
        Sleep(500)
        Send("x")
        Sleep(3000)
        MouseMove(733, 88)
        MouseClick("left")
        Sleep(5000)
        MouseMove(657, 265)
        MouseClick("left")
        Sleep(5000)
        ControlClick("Windows Internet Explorer", "", "[CLASS:Button; INSTANCE:1]")
    EndIf
EndFunc

Br, FireFox.

Edited by FireFox
  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
gsc

FireFox! you are a genius! thank you so much... I find it all so confusing haha... I have so many scripts that have an issue somewhere or another....

My current issue is that there is other scripts that run but I need something at the beginning of each script that says if the following scripts are working then sleep 10 seconds... any ideas?

GSC

Share this post


Link to post
Share on other sites
Mechaflash
  • Like 1

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites
gsc

Quick note on this... is there a way to make the script keep a log of each time it needs to reconnect the internet? so if it is fine then the mouse clicks something twice, however, if the internet drops it keeps a continuing log of it, and reports even if it timesout and has to start again?

GSC

Share this post


Link to post
Share on other sites
FireFox

My current issue is that there is other scripts that run but I need something at the beginning of each script that says if the following scripts are working then sleep 10 seconds... any ideas?

You can check for function return values/@error macro and if it fails then for example return 0 instead of 1 if it's successful.

While 1
    If _MyFunc() = 0 Then
        Sleep(10000)
    EndIf
    Sleep(10)
WEnd

Func _MyFunc()
    ;do something
    If @error Then Return 0

    Return 1
EndFunc

is there a way to make the script keep a log of each time it needs to reconnect the internet?

Sure, or you go :)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.