0
votes

Working on a script that checks IP and then closes notepad2.exe if IP is not equal. Problem is that script closes notepad2.exe regardless.

#SingleInstance
#Persistent

Settimer, CheckIP, 500

vIPaddress = "192.168.1.14"

CheckIP:
    vCurrentaddr = %A_IPAddress1%

    if (vIPaddress <> vCurrentaddr)
    {
        Process, Close, Notepad2.exe
    }      
    return

f10::exitapp ; when I need to stop watchdog

edit: corrected script so now it doesn't shut down notepad2.exe all the time, but now problem it doesn't update value for vCurrentaddr = %A_IPAddress1%. Now it doesn't close notepad2.exe with:

if (vIPaddress <> vCurrentaddr)

1

1 Answers

0
votes
#SingleInstance
#Persistent

Settimer, CheckIP, 500

vIPaddress = 192.168.1.4

CheckIP:
    vCurrentaddr = %A_IPAddress1%
    vCurrentaddr2 = %A_IPAddress2%

    if (vIPaddress <> vCurrentaddr)
    {
          Process, Close, Notepad2.exe
    }
    else if (vCurrentaddr2 <> "0.0.0.0")
    {
          if (vIPaddress <> vCurrentaddr2)
          {
              Process, Close, Notepad2.exe
          }
    } 
    return

f10::exitapp ; when I need to stop watchdog

This seems to work as vCurrentaddr2 holds the changed IP. When not connected to a VPN the value is 0.0.0.0 and after connecting to VPN the value changes.

edit:

cleaning up code for uneeded statements!