【问题标题】:Autohotkey monitor IP script and close applicationAutohotkey 监控 IP 脚本并关闭应用程序
【发布时间】:2014-12-22 08:27:40
【问题描述】:

使用检查 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 vCurrentaddr)

【问题讨论】:

    标签: autohotkey


    【解决方案1】:
    #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 后,该值会发生变化。

    编辑:

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

    【讨论】:

      猜你喜欢
      • 2015-05-29
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多