Jump to content

While I'm in a loop


jaweb
 Share

Recommended Posts

Hi, I use a proxy and sometimes need a specific IP from the Proxy's IP range so I wrote a simple auto

#include <Inet.au3>
$PublicIP = _GetIP()

While 1
If $PublicIP = "***.***.***.***" Then 
    MsgBox(0, "IP Search", "Confirmed", 5)
Else
    MsgBox(0, "IP Search", "Not Found", 5)
    ControlClick("Proxy App", "", "Change IP Address")
    Sleep(5000)
EndIf
Wend

The only thing is I'm stuck in a loop. What did I miss?

Link to comment
Share on other sites

You didn't miss anything. While 1 means to just keep looping. To stop looping you need to add an ExitLoop where you want to break the loop.

So you want something like.

#include <Inet.au3>
$PublicIP = _GetIP()

While 1
If $PublicIP = "***.***.***.***" Then 
    MsgBox(0, "IP Search", "Confirmed", 5)
    ExitLoop ; This will exit the loop
Else
    MsgBox(0, "IP Search", "Not Found", 5)
    ControlClick("Proxy App", "", "Change IP Address")
    Sleep(5000)
EndIf
Wend
Edited by Deltaforce229

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

i would do it something like this if it was me.

i hate using If statements if i can avoid them.

#include <Inet.au3>
While _GetIP() <> "***.***.***.***"
Sleep(100)
Wend
ControlClick("Proxy App", "", "Change IP Address")
Sleep(5000)
Edited by supadodger
Link to comment
Share on other sites

It seems 'while 1' isn't the issue. The IP address _GetIP() gets from whatismyip.com will refresh only if I restart the script.

So if I start the script, it will stay in a loop even if the IP is located,

For example, Say I want to verify my own ISP assigned IP, if I turn on the proxy (which changes the IP) and start the script, it'll say 'Not Found', because ofcourse my IP was already change by the proxy, but if I turn off the proxy to get back my ISP assigned IP, the script continue to say 'Not Found' because the info _GetIP() gets from whatismyip.com isn't refreshed.

In other words, how to get _GetIP() to refresh on every loop? or what are _GetIP() alternatives.

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