Autohotkey监控IP脚本并关闭应用程序

时间:2014-12-21 20:09:30

标签: autohotkey

处理检查IP的脚本,然后在IP不相等时关闭notepad2.exe。问题是脚本无论如何关闭notepad2.exe。

#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

编辑: 更正后的脚本所以现在它不会一直关闭notepad2.exe,但现在问题是它没有更新 vCurrentaddr =%A_IPAddress1%的值。现在它不会关闭notepad2.exe:

if(vIPaddress&lt;&gt; vCurrentaddr)

1 个答案:

答案 0 :(得分:0)

#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

这似乎有效,因为 vCurrentaddr2 包含更改的IP。未连接到VPN时,值 0.0.0.0 ,连接到VPN后,值会更改。

编辑:

清理不需要的语句的代码!

相关问题