#Region Compiler directives section
;** This is a list of compiler directives used by AutoIt3Wrapper.exe.
;** comment the lines you don't need or else it will override the default settings
#Compiler_Prompt=n ;y=show compile menu
;** AUTOIT3 settings
#Compiler_AUTOIT3= ;Override the default Interpreter version.
;** AUT2EXE settings
#Compiler_AUT2EXE= ;Override the default compiler with this version.
#Compiler_Icon=Globe.ico ;Filename of the Ico file to use
#Compiler_OutFile= ;Target exe/a3x filename.
#Compiler_OutFile_Type=exe ;a3x=small AutoIt3 file; exe=Standalone executable(Default)
#Compiler_Compression=4 ;Compression parameter 0-4 0=Low 2=normal 4=High
#Compiler_Allow_Decompile=y ;y= allow decompile
#Compiler_PassPhrase= ;Password to use for compilation
#Compiler_UseUpx=y ;(y/n) Compress output program works only for 3.1.1.110 and up. Default=Yes
;** Target program Resource info
#Compiler_Res_Comment= Change IE Proxy ;Comment field
#Compiler_Res_Description=Change IE Proxy ;Description field
#Compiler_Res_Fileversion=1.2 ;File Version
#Compiler_Res_FileVersion_AutoIncrement=n ;AutoIncrement FileVersion After Aut2EXE is finished.
;#Compiler_Res_Language=2057 ;Resource Language code . default 2057=English (United Kingdom)
#Compiler_Res_LegalCopyright=Giuseppe Criaco ;Copyright field
; free form resource fields ... max 15
; you can use the following variables:
; %AutoItVer% which will be replaced with the version of AutoIt3
; %date% = PC date in short date format
; %longdate% = PC date in long date format
; %time% = PC timeformat
#Compiler_Res_Field=AutoIt Version|%AutoItVer%
#Compiler_Res_Field=Email|[email protected] ;Free format fieldname|fieldvalue
#Compiler_Res_Field=Release Date|21/5/2007 ;Free format fieldname|fieldvalue
#Compiler_Res_Field=Name|Value ;Free format fieldname|fieldvalue
#Compiler_Res_Field=Name|Value ;Free format fieldname|fieldvalue
; Tidy Settings
#Compiler_Run_Tidy=n ;Run au3check before compilation. default=y
#Compiler_Tidy_Stop_OnError=n ;Continue when only Warnings. default=y
#Tidy_Parameters= ;Tidy Parameters...see SciTE4AutoIt3 Helpfile for options
; AU3CHECK settings
#Compiler_Run_AU3Check= ;(Y/N) Run au3check before compilation. Default=Y
#Compiler_AU3Check_Parameters= ;Au3Check parameters
#Compiler_AU3Check_Dat= ;Override the default au3check definition
#Compiler_AU3Check_Stop_OnWarning= ;(Y/N) N=Continue on Warnings.(Default) Y=Always stop on Warnings
#Compiler_AU3Check_Parameters= ;Au3Check parameters
#Compiler_PlugIn_Funcs= ;Define PlugIn function names separated by a Comma to avoid AU3Check errors
; RUN BEFORE AND AFTER definitions
; The following directives can contain:
; %in% , %out%, %icon% which will be replaced by the fullpath\filename.
; %scriptdir% same as @ScriptDir and %scriptfile% = filename without extension.
; %fileversion% is the information from the #Compiler_Res_Fileversion directive
; %scitedir% will be replaced by the SciTE program directory
#Compiler_Run_Before= ;process to run before compilation - you can have multiple records that will be processed in sequence
#Compiler_Run_After= ;process to run After compilation - you can have multiple records that will be processed in sequence
#Compiler_Run_cvsWrapper=n ;(y/n) Run cvsWrapper to update the script source. Default=n
; Run Settings
#Run_Debug_Mode=n ; Run Script with console debugging
#EndRegion
;===================================================================================================================================================
;
; Program Name: ChangeProxy()
; Description: IE Proxy Changer
; Parameter(s): None
; Requirement(s): ChgProxy.ini
; Return Value(s): None
; Author(s): Giuseppe Criaco <[email protected]>
;
;===================================================================================================================================================
#Region - Include and Declarations
;~ AutoItSetOption("TrayIconDebug", 1) ;Debug: 0=no info, 1=debug line info
#include <GuiConstants.au3>
#include <GuiList.au3>
Global Const $WM_COMMAND = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK = 2
Dim $asCmd[50], $iCmd = 0, $IP, $sHostName, $sEncryptPwd, $sPwd, $sUser, $iSleep = 1000, $sPutty, $iSendKeyDelay = 50
#EndRegion - Include and Declarations
;Batch Proxy Change
;Command-line parameters:
;1st: e/d (enable/disable proxy)
;2nd: proxyname:port
;Example: ChgProxy e MyProxy:8080
If $CmdLine[0] > 0 Then _Batch()
#Region ### START Koda GUI section ### Form=c:\autoit\proxy\chgproxy.kxf
$AForm1 = GUICreate("ChgProxy v. 1.2", 235, 369, 493, 134)
$btnOk = GUICtrlCreateButton("&Start", 88, 336, 65, 25, $BS_DEFPUSHBUTTON)
$lstServer = GUICtrlCreateList("", 8, 64, 217, 97)
$btnExit = GUICtrlCreateButton("&Exit", 160, 336, 65, 25, 0)
$AGroup1 = GUICtrlCreateGroup("Settings", 8, 280, 217, 49)
$optEnabled = GUICtrlCreateRadio("Enabled", 24, 304, 73, 17)
$optDisabled = GUICtrlCreateRadio("Disabled", 144, 304, 73, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$grpProxy = GUICtrlCreateGroup("Proxy Server", 8, 8, 217, 49)
$lblProxy = GUICtrlCreateLabel("lblProxy", 24, 32, 192, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$edtExceptions = GUICtrlCreateEdit("", 8, 200, 217, 73, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("Exceptions:", 8, 180, 59, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If Not FileExists(@ScriptDir & "\ChgProxy.ini") Then
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Warning
MsgBox(48, "File Not Found", "Required file not found (" & @ScriptDir & "\ChgProxy.ini" & ")" & @CRLF & "" & @CRLF & "ChgProxy will now exit!!!")
Exit
EndIf
; Get IE Proxy server Registry values
$sProxy = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer")
$iEnabled = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable")
$sExceptions = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride")
If $iEnabled Then
GUICtrlSetState($optEnabled, $GUI_CHECKED)
TrayTip("Proxy Server: ", $sProxy, 5, 1)
TraySetToolTip("Proxy Server: " & $sProxy)
GUICtrlSetData($lblProxy, $sProxy)
Else
GUICtrlSetState($optDisabled, $GUI_CHECKED)
TrayTip("Proxy Server: ", "Disabled(Direct Connection)", 5, 1)
TraySetToolTip("Proxy Server: Disabled(Direct Connection)")
GUICtrlSetData($lblProxy, $sExceptions)
EndIf
GUICtrlSetData($edtExceptions, $sExceptions)
HotKeySet("{ESC}", "_Terminate")
;Servers
$sSection = IniReadSection(@ScriptDir & "\ChgProxy.ini", "Servers")
If @error Then
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical
MsgBox(16, "ChgProxy", "Unable to read the section Server")
#EndRegion --- CodeWizard generated code End ---
Exit
Else
;Load ListBox
Local $iLstIndex = 0
For $iSection = 1 To $sSection[0][0]
GUICtrlSetData($lstServer, $sSection[$iSection][0] & " (" & $sSection[$iSection][1] & ")")
If $sProxy = $sSection[$iSection][1] Then
GUICtrlSetData($grpProxy, "Proxy: " & $sSection[$iSection][0])
$iLstIndex = $iSection - 1
EndIf
Next
If $iLstIndex > 0 Then
$ret = _GUICtrlListSelectIndex($lstServer, $iLstIndex)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListSelectIndex")
EndIf
EndIf
EndIf
;Register a user defined function for the Windows Message ID WM_COMMAND.
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $btnExit
_Terminate()
Case $msg = $btnOk
_Start()
EndSelect
WEnd
;----------------------------------------------------------------------------------------------------------------
Func _Start()
;Proxy enabled
If GUICtrlRead($optEnabled) = $GUI_CHECKED Then
$sTmpKey = GUICtrlRead($lstServer)
$sKey = StringLeft($sTmpKey, StringInStr($sTmpKey, " ("))
If $sKey = "" Then
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Warning
MsgBox(48, "Error Message", "No Proxy selected")
#EndRegion --- CodeWizard generated code End ---
Else
$sProxy = IniRead(@ScriptDir & "\ChgProxy.ini", "Servers", $sKey, "NotFound")
If @error Or $sProxy = "NotFound" Then
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical
MsgBox(16, "ChgProxy", "Unable to read the Key " & $sKey)
Exit
Else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", "REG_SZ", $sProxy)
TrayTip("Proxy Server: ", $sProxy, 5, 1)
TraySetToolTip("Proxy Server: " & $sProxy)
GUICtrlSetData($lblProxy, $sProxy)
GUICtrlSetData($grpProxy, "Proxy: " & $sKey)
EndIf
EndIf
$sExceptions = GUICtrlRead($edtExceptions)
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 1)
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride", "REG_SZ", $sExceptions)
Else
;Proxy Disabled
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 0)
TrayTip("Proxy Server: ", "Disabled (Direct Connection)", 5, 1)
TraySetToolTip("Proxy Server: Disabled(Direct Connection)")
GUICtrlSetData($lblProxy, "Disabled (Direct Connection)")
GUICtrlSetData($grpProxy, "proxy")
EndIf
EndFunc ;==>_Start
;----------------------------------------------------------------------------------------------------------------
Func _Terminate()
Exit 0
EndFunc ;==>_Terminate
;----------------------------------------------------------------------------------------------------------------
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
$nNotifyCode = BitShift($wParam, 16)
$nID = BitAND($wParam, 0x0000FFFF)
$hCtrl = $lParam
If $nID = $lstServer Then
Switch $nNotifyCode
Case $LBN_DBLCLK
_Start()
Return 0
EndSwitch
EndIf
EndFunc ;==>MY_WM_COMMAND
;==============================================================================================================
Func _Batch()
If (StringLower ($CmdLine[1]) <> "e" And StringLower ($CmdLine[1]) <> "d") Or _
(StringLower ($CmdLine[1]) = "e" And $CmdLine[0] < 2) Then
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical
MsgBox(16,"Error Message","Command-line parameters: " & @CRLF & "1st: e/d (enable/disable proxy)" & @CRLF & "2nd: proxyname:port" & @CRLF & "Example: ChgProxy e MyProxy:8080")
Else
If StringLower ($CmdLine[1]) = "e" Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", "REG_SZ", $CmdLine[2])
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 1)
Else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 0)
EndIf
EndIf
_Terminate()
EndFunc