Modifying this script with ip detection

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
betakill
Posts: 5
Joined: 12 Apr 2018, 12:39

Modifying this script with ip detection

12 Apr 2018, 12:46

I need to modify this current script with ip detection so qbittorrent is only started only after the ip changes to a address that is NOT in the 67.0.0.0 or 98.0.0.0 ranges
if I can do that I can eliminate restarting qbittorrent twice to get it to pickup the vpn

#notrayicon
#Persistent
#SingleInstance force
SetTimer, ProcCheck, 5000
Return
ProcCheck:
Process, Exist, qbittorrent.exe
If (ErrorLevel == 0) {
Process, Exist, openvpn.exe
If (ErrorLevel == 0) {
Return
}
Else {
Run, c:\Program Files\OpenVPN\bin\openvpn-gui.exe --command disconnect wind
Return
}
}
Else {
Process, Exist, openvpn.exe
If (ErrorLevel == 0) {

sleep 5000
Process, Close, qBittorrent.exe
Run, c:\Program Files\OpenVPN\bin\openvpn-gui.exe --command connect wind
sleep 8000
Run, C:\Program Files\qBittorrent\qbittorrent.exe
Return
}
Else {
Return
}
}
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Modifying this script with ip detection

12 Apr 2018, 13:12

Hey bud,

I presume you want to make sure the vpn is disabled.

Write this in the area of code where you want to check your IP address:

Code: Select all

Originalip := "" 
UrlDownloadToFile, http://myip.dnsdynamic.com/, myip.txt
FileRead, myip, myip.txt
FileDelete, myip.txt

If (myip = Originalip) {
} ; whatever
else {
Msgbox VPN is active!
ExitApp
}
Assign Originalip to your current ip. Cheers! :D
I am your average ahk newbie. Just.. a tat more cute. ;)
betakill
Posts: 5
Joined: 12 Apr 2018, 12:39

Re: Modifying this script with ip detection

12 Apr 2018, 13:50

accually I want to kill qbittorrent
wait for the vpn to be UP and then start qbittorrent again after killing it
the reason is qbittorrent network interface detection is a bit buggy and this is my work around

the problem with my current script is I can't always trust that after 8's seconds the vpn will be up thus needing to restart qbittorrent manually

ideally I would like something that could intercept the shell execute when clicking a magnet link wait for the vpn to be up and then open said torrent/magnet link with qbittorrent but thats way above my coding ability
betakill
Posts: 5
Joined: 12 Apr 2018, 12:39

Re: Modifying this script with ip detection

12 Apr 2018, 13:50

deleted doublepost forum is being quiet slow for me
Last edited by betakill on 12 Apr 2018, 13:52, edited 1 time in total.
betakill
Posts: 5
Joined: 12 Apr 2018, 12:39

Re: Modifying this script with ip detection

12 Apr 2018, 13:50

accually I want to kill qbittorrent
wait for the vpn to be UP and then start qbittorrent again after killing it
the reason is qbittorrent network interface detection is a bit buggy and this is my work around

the problem with my current script is I can't always trust that after 8's seconds the vpn will be up thus needing to restart qbittorrent manually

ideally I would like something that could intercept the shell execute Open-with when clicking a magnet link wait for the vpn to be up and then open said torrent/magnet link with qbittorrent but thats way above my coding ability

if I had a script that would just check if the ip was NOT one of my isp provided ones and then run a program, if the vpn was not up kill qbittorrent.exe

that I could just compile it as exe and replace qbittorrent.exe with the script,but the script would need to parse the arguments being sent to it and then wait for the vpn to be up and hand them off to qbittorrent.exe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: GEOVAN and 120 guests