Phenom Posted October 19, 2010 Share Posted October 19, 2010 (edited) I want to create a Hotkey that when pressed blocks network traffic to Google Chrome. Then when pressed again it will quickly resume traffic. How can this be done? I know how to create the hotkey. It's the part about stopping and starting network traffic that I need to figure out. The reason I want to do this is I want to be able to freeze Chrome. Is there another way to cause this to happen? Also, it doesn't have to block network traffic specifically to a single application. It can block all network traffic if that's easier to do. Edited October 19, 2010 by Phenom Link to comment Share on other sites More sharing options...
BugFix Posted October 19, 2010 Share Posted October 19, 2010 I've made this a long time before. But should do, what you want. expandcollapse popup;------------------------------------------------------------------------------------------ ; Funktion _ChangeGatewayAndBack($MY_IP, $GATEWAY_IP, $FAKE_GATEWAY_IP [,$TIMEOUT=-1]) ; ; Beschreibung sets a wrong Gateway-IP to your network card and breaks so current connection ; network card must be configurated manually ; ; Parameter $MY_IP IP network card ; $GATEWAY_IP Gateway ; $FAKE_GATEWAY_IP wrong IP ; $TIMEOUT Time do get back to right Gateway ; -1 (default) 2000 ms ; 0 Emergency stop - gateway will not be set back ; n ms ; ; Autor BugFix [EMAIL]bugfix@autoit.de[/EMAIL] ;------------------------------------------------------------------------------------------ Func _ChangeGatewayAndBack($MY_IP, $GATEWAY_IP, $FAKE_GATEWAY_IP ,$TIMEOUT=-1) Local $ARGATEWAY[2] = [$GATEWAY_IP, $GATEWAY_IP] Local $ARFAKEGATEWAY[2] = [$FAKE_GATEWAY_IP, $FAKE_GATEWAY_IP] Local $TIME, $EMERGENCY = 0, $strComputer = "." Switch $TIMEOUT Case -1 $TIME = 2000 Case 0 $EMERGENCY = 1 Case Else $TIME = $TIMEOUT EndSwitch $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colNetCards = $objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") If $EMERGENCY = 0 Then For $objNetCard in $colNetCards If $objNetCard.IPAddress(0) = $MY_IP Then $objNetCard.SetGateways($ARFAKEGATEWAY) Sleep($TIME) $objNetCard.SetGateways($ARGATEWAY) ExitLoop EndIf Next Else For $objNetCard in $colNetCards If $objNetCard.IPAddress(0) = $MY_IP Then $objNetCard.SetGateways($ARFAKEGATEWAY) ExitLoop EndIf Next EndIf EndFunc ;==>_ChangeGatewayAndBack Best Regards BugFix Link to comment Share on other sites More sharing options...
Phenom Posted October 19, 2010 Author Share Posted October 19, 2010 I've made this a long time before. But should do, what you want. expandcollapse popup;------------------------------------------------------------------------------------------ ; Funktion _ChangeGatewayAndBack($MY_IP, $GATEWAY_IP, $FAKE_GATEWAY_IP [,$TIMEOUT=-1]) ; ; Beschreibung sets a wrong Gateway-IP to your network card and breaks so current connection ; network card must be configurated manually ; ; Parameter $MY_IP IP network card ; $GATEWAY_IP Gateway ; $FAKE_GATEWAY_IP wrong IP ; $TIMEOUT Time do get back to right Gateway ; -1 (default) 2000 ms ; 0 Emergency stop - gateway will not be set back ; n ms ; ; Autor BugFix [EMAIL]bugfix@autoit.de[/EMAIL] ;------------------------------------------------------------------------------------------ Func _ChangeGatewayAndBack($MY_IP, $GATEWAY_IP, $FAKE_GATEWAY_IP ,$TIMEOUT=-1) Local $ARGATEWAY[2] = [$GATEWAY_IP, $GATEWAY_IP] Local $ARFAKEGATEWAY[2] = [$FAKE_GATEWAY_IP, $FAKE_GATEWAY_IP] Local $TIME, $EMERGENCY = 0, $strComputer = "." Switch $TIMEOUT Case -1 $TIME = 2000 Case 0 $EMERGENCY = 1 Case Else $TIME = $TIMEOUT EndSwitch $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colNetCards = $objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") If $EMERGENCY = 0 Then For $objNetCard in $colNetCards If $objNetCard.IPAddress(0) = $MY_IP Then $objNetCard.SetGateways($ARFAKEGATEWAY) Sleep($TIME) $objNetCard.SetGateways($ARGATEWAY) ExitLoop EndIf Next Else For $objNetCard in $colNetCards If $objNetCard.IPAddress(0) = $MY_IP Then $objNetCard.SetGateways($ARFAKEGATEWAY) ExitLoop EndIf Next EndIf EndFunc ;==>_ChangeGatewayAndBack How do you use this? Link to comment Share on other sites More sharing options...
BugFix Posted October 31, 2010 Share Posted October 31, 2010 How do you use this?See description in function header. What is misunderstanding with it? Best Regards BugFix Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now