Created
July 1, 2026 17:47
-
-
Save alexey-goloburdin/a7e54fdc280fc813c2c19941361d65db to your computer and use it in GitHub Desktop.
Autohotkey v2 for setup or clear system proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires AutoHotkey v2.0 | |
| #SingleInstance Force | |
| ; Порт локального proxy в v2rayN | |
| ProxyServer := "127.0.0.1:10808" | |
| RegKey := "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | |
| ProxyOverride := "localhost;127.*;<local>" | |
| ; Win+P — включить/отключить системный proxy | |
| #p:: | |
| { | |
| ToggleProxy() | |
| } | |
| ToggleProxy() { | |
| global RegKey | |
| enabled := RegRead(RegKey, "ProxyEnable", 0) | |
| SetProxy(!enabled) | |
| } | |
| SetProxy(enable) { | |
| global RegKey, ProxyServer, ProxyOverride | |
| if enable { | |
| RegWrite 1, "REG_DWORD", RegKey, "ProxyEnable" | |
| RegWrite ProxyServer, "REG_SZ", RegKey, "ProxyServer" | |
| RegWrite ProxyOverride, "REG_SZ", RegKey, "ProxyOverride" | |
| RegWrite "", "REG_SZ", RegKey, "AutoConfigURL" | |
| RefreshSystemProxy() | |
| TrayTip "v2rayN proxy", "System proxy: ON → " ProxyServer, 1 | |
| } else { | |
| RegWrite 0, "REG_DWORD", RegKey, "ProxyEnable" | |
| RegWrite "", "REG_SZ", RegKey, "ProxyServer" | |
| RegWrite "", "REG_SZ", RegKey, "ProxyOverride" | |
| RegWrite "", "REG_SZ", RegKey, "AutoConfigURL" | |
| RefreshSystemProxy() | |
| TrayTip "v2rayN proxy", "System proxy: OFF", 1 | |
| } | |
| } | |
| RefreshSystemProxy() { | |
| ; INTERNET_OPTION_SETTINGS_CHANGED = 39 | |
| ; INTERNET_OPTION_REFRESH = 37 | |
| DllCall("wininet\InternetSetOptionW", "Ptr", 0, "UInt", 39, "Ptr", 0, "UInt", 0) | |
| DllCall("wininet\InternetSetOptionW", "Ptr", 0, "UInt", 37, "Ptr", 0, "UInt", 0) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment