Advertisement
eptesicus

AutoHotKey - VPN Check

Sep 22nd, 2017
1,657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Menu, Tray, Icon, shell32.dll, 138
  2.  
  3. #Persistent
  4.  
  5. SetTimer, CheckIP, 3000 ; Set a timer that will repeat the label CheckIP every 3 seconds
  6. sentForDiff := False
  7. sentForSame := False
  8. Return
  9. CheckIP:
  10. ;GET VPN WAN IP
  11.     UrlDownloadToFile, http://myvps/visitor_ip.php, %A_Temp%\ipcheckvpn
  12.     FileRead, VPNIP, %A_Temp%\ipcheckvpn
  13.    
  14. ;GET LOCAL WAN IP
  15.     UrlDownloadToFile, http://myvps/homedomain_ip.php, %A_Temp%\ipcheckwan
  16.     FileRead, WANIP, %A_Temp%\ipcheckwan
  17.    
  18. ;COMPARE
  19.     IF (WANIP = VPNIP AND !sentForSame) {
  20.         ; Send Your Email for Same
  21.         Runwait, taskkill /im qbittorrent.exe /f
  22.         Run, c:\swithmail\SwithMail.exe  /s /from "myemail@gmail.com" /name "myemail" /pass "password" /server "smtp.gmail.com" /p "587" /SSL /to "mytextemail" /cc "myemailaddress" /sub "VPN TRNT is DOWN" /b "VPN IP: %VPNIP%  |  WAN IP: %WANIP%"
  23.         sentForSame := True
  24.         sentForDiff := False
  25.     }
  26.     Else IF (WANIP != VPNIP AND !sentForDiff) {
  27.         ; Send Your Email for Different
  28.         Process, Exist, qbittorrent.exe
  29.             {
  30.             If (ErrorLevel = 0) ; If application is NOT running
  31.                 {
  32.                 Run, "C:\Program Files\qBittorrent\qbittorrent.exe"
  33.                 }
  34.             }
  35.         Run, c:\swithmail\SwithMail.exe  /s /from "myemail@gmail.com" /name "myemail" /pass "password" /server "smtp.gmail.com" /p "587" /SSL /to "mytextemail" /cc "myemailaddress" /sub "VPN TRNT is UP" /b "VPN IP: %VPNIP%  |  WAN IP: %WANIP%"
  36.         sentForDiff := True
  37.         sentForSame := False
  38.     }
  39. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement