I'd like to create a script that can "kill" internet access for 10 minutes (or any customizable time).
So in a moment of time-wasting madness, I can press a keyboard shortcut that BAM -- disables internet connection for 10 minutes.
Can AHK interact with the OS at this type of level? If not, might there be another way?
Kill internet access for 10 minutes?
- Coldblackice
- Posts: 29
- Joined: 13 Nov 2013, 14:39
Re: Kill internet access for 10 minutes?
Probably, but if you Google "disable network connection command line" you will find some info, once you have that working via the command prompt you can simply use the Run command and a Sleep to disable/enable your network connection.
-
- Posts: 11
- Joined: 29 Sep 2013, 16:48
- Location: The Kindom Of Sweden
Re: Kill internet access for 10 minutes?
If not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
Run, %comspec% /c ipconfig /release,, Hide ; off
sleep, 6000 ; 10 Minutes
Run, %comspec% /c ipconfig/renew,, Hide ; On
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
Run, %comspec% /c ipconfig /release,, Hide ; off
sleep, 6000 ; 10 Minutes
Run, %comspec% /c ipconfig/renew,, Hide ; On
- ErrorOnLine2
- Posts: 16
- Joined: 31 Oct 2013, 18:54
Re: Kill internet access for 10 minutes?
Many thanks to Guest for his\her Google "disable network connection command line" suggestion. I haven't implemented any of the code snippets yet, but I'm sure I can get one of them to work, or piece together a working solution.
Your suggestion will allow me to elegantize my Enable\Disable Internet Connection code by a factor of 1000! And I'm talking minimum here!
(OK, well maybe not a factor of 1000, but you know what I mean)
Your suggestion will allow me to elegantize my Enable\Disable Internet Connection code by a factor of 1000! And I'm talking minimum here!
(OK, well maybe not a factor of 1000, but you know what I mean)
Re: Kill internet access for 10 minutes?
Releasing the Ip address and disabling your network connection will also disconnect you from your network. Which would disconnect you from any network shares, network printers, ETC....
If you want to disable internet browsing from Internet Explorer changing the proxy address to 127.0.0.1 would work.
Notes on the script below....
Ctrl Space sets a bad proxy address for Internet Explorer. After 10 minutes it resets proxy address back to what it was when the script was started
The Escape key and exiting the script resets proxy address back to what it was when the script was started
Thanks to SuperFraggle for Proxy function found here: http://www.autohotkey.com/board/topic/1 ... ntry128031
If you want to disable internet browsing from Internet Explorer changing the proxy address to 127.0.0.1 would work.
Notes on the script below....
Ctrl Space sets a bad proxy address for Internet Explorer. After 10 minutes it resets proxy address back to what it was when the script was started
The Escape key and exiting the script resets proxy address back to what it was when the script was started
Thanks to SuperFraggle for Proxy function found here: http://www.autohotkey.com/board/topic/1 ... ntry128031
Code: Select all
BadProxyServerAddress = 127.0.0.1:0000
RegRead, ProxyAddress, REG_SZ,HKCU, Software\Microsoft\Windows\CurrentVersion\Internet Settings, ProxyServer
RegRead, ProxyState,REG_DWORD,HKCU, Software\Microsoft\Windows\CurrentVersion\Internet Settings, ProxyEnable
KillSleep = 0
OnExit,ResetProxyStateAndExit
^space::
TrayTip,Internet Explorer browsing is disabled,Press Escape to re-enable,3
setproxy(BadProxyServerAddress,"ON") ;turn on bad proxy address
Loop 600 ;wait 10 minutes ( 600 x 1000 milliseconds is 10 minutes)
{
sleep 1000
{
if KillSleep = 1
break
}
}
Gosub, ResetProxySettings ;resets proxy address back to what it was when the script was started and waits for the Ctrl Space hotkey to be pressed
return
Escape:: ;resets proxy address back to what it was when the script was started and waits for the Ctrl Space hotkey to be pressed
KillSleep = 1
Gosub, ResetProxySettings
TrayTip,Internet Explorer browsing is re-enabled,Press Ctrl Space to disable,3
return
ResetProxyStateAndExit: ;resets proxy address back to what it was when the script was started then exits script
Gosub, ResetProxySettings
exitapp
ResetProxySettings:
If ProxyState = 1
setproxy(ProxyAddress,"ON")
else
setproxy(ProxyAddress,"OFF")
return
setproxy(address = "",state = ""){
if (address = "") and (state = "")
state = TOGGLE
if address
regwrite,REG_SZ,HKCU,Software\Microsoft\Windows\CurrentVersion\Internet Settings,ProxyServer,%address%
if (state ="ON")
regwrite,REG_DWORD,HKCU,Software\Microsoft\Windows\CurrentVersion\Internet Settings,Proxyenable,1
else if (state="OFF")
regwrite,REG_DWORD,HKCU,Software\Microsoft\Windows\CurrentVersion\Internet Settings,Proxyenable,0
else if (state = "TOGGLE")
{
if regread("HKCU","Software\Microsoft\Windows\CurrentVersion\Internet Settings","Proxyenable") = 1
regwrite,REG_DWORD,HKCU,Software\Microsoft\Windows\CurrentVersion\Internet Settings,Proxyenable,0
else if regread("HKCU","Software\Microsoft\Windows\CurrentVersion\Internet Settings","Proxyenable") = 0
regwrite,REG_DWORD,HKCU,Software\Microsoft\Windows\CurrentVersion\Internet Settings,Proxyenable,1
}
dllcall("wininet\InternetSetOptionW","int","0","int","39","int","0","int","0")
dllcall("wininet\InternetSetOptionW","int","0","int","37","int","0","int","0")
Return
}
RegRead(RootKey, SubKey, ValueName = "") {
RegRead, v, %RootKey%, %SubKey%, %ValueName%
Return, v
}
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
- ErrorOnLine2
- Posts: 16
- Joined: 31 Oct 2013, 18:54
Re: Kill internet access for 10 minutes?
The code snippets I found on the internet pertaining to 'enable\disable internet connection by command line' pointed to netsh. Unfortunately, all of them failed on my Win XP system.
To use the code posted below, you must download DevCon, the console version of Device Manager available from Microsoft. You must also determine the Device ID number of the network adapter you want to disconnect. On my system, it's DEV_1064.
I'm posting the code because it's a slow Sunday morning here in western New York. I don't think anyone, aside from the OP, actually has a need to disconnect then reconnect 10 minutes later, but you never know.
http://support.microsoft.com/kb/311272
To use the code posted below, you must download DevCon, the console version of Device Manager available from Microsoft. You must also determine the Device ID number of the network adapter you want to disconnect. On my system, it's DEV_1064.
I'm posting the code because it's a slow Sunday morning here in western New York. I don't think anyone, aside from the OP, actually has a need to disconnect then reconnect 10 minutes later, but you never know.
Spoiler
DevCon Win XP http://support.microsoft.com/kb/311272
Who is online
Users browsing this forum: No registered users and 134 guests