#include #NoTrayIcon ; Detect first run $first_run = RegRead("HKEY_CLASSES_ROOT\Directory\shell\Folder Tweaker\command", "") If @Error Then QuickStart() EndIf ; Write Uninstaller RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker", "DisplayName", "REG_SZ", "Folder Tweaker (remove only)") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker", "DisplayVersion", "REG_SZ", "1.1") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker", "Publisher", "REG_SZ", "Quang Anh Do") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker", "URLInfoAbout", "REG_SZ", "http://qad.donationcoders.com/wp/folder-tweaker") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker", "DisplayIcon", "REG_SZ", '"' & @ScriptFullPath & '", 0"') RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker", "UninstallString", "REG_SZ", '"' & @ScriptFullPath & '" -byebye') ; Shell Integration RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Folder Tweaker", "", "REG_SZ", "T&weak This Folder") RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Folder Tweaker\command", "", "REG_SZ", '"' & @ScriptFullPath & '" "%1"') ;========================================================================================================================================================================= ; If the user double click FolderTweaker.exe, ask for a folder If $CmdLine[0] = 0 Then $current_folder = FileSelectFolder("Select a folder", "", 1 + 2 + 4) If @Error Then Exit Else ; Otherwise, take the first parameter $current_folder = $CmdLine[1] ; If it's '-byebye', run the uninstaller & exit If $CmdLine[1] = "-byebye" Then RegDelete("HKEY_CLASSES_ROOT\Directory\shell\Folder Tweaker") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Folder Tweaker") MsgBox(0, "Information", "Folder Tweaker uninstalled.") Exit EndIf EndIf ; Initiate some values $current_file = IniRead($current_folder & "\desktop.ini", ".ShellClassInfo", "IconFile", @SystemDir & "\shell32.dll") $def_icon_file = $current_file $def_icon_index = IniRead($current_folder & "\desktop.ini", ".ShellClassInfo", "IconIndex", 3) $prev_icon_file = "" $def_bg_file = IniRead($current_folder & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Image", "") $prev_bg_file = $def_bg_file $def_info = IniRead($current_folder & "\desktop.ini", ".ShellClassInfo", "InfoTip", "") $def_color = IniRead($current_folder & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Text", "Black") $icon_index = Round($def_icon_index / 10) * 10 $def_icon_index = Mod($def_icon_index, 10) $start = 1 ;========================================================================================================================================================================= ; Icon preview array Global $ip[11] ;========================================================================================================================================================================= ; Create a GUI, as well as 7 groups $gui = GUICreate("Folder Tweaker", 622, 565, -1, -1, -1, $WS_EX_ACCEPTFILES) ;========================================================================================================================================================================= $group1 = GUICtrlCreateGroup("Current Folder", 8, 8, 609, 89) $current_folder_icon = GUICtrlCreateButton("", 24, 32, 49, 49, $BS_ICON + $BS_FLAT) $current_folder_name = GUICtrlCreateLabel($current_folder, 80, 48, 493, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $group2 = GUICtrlCreateGroup("Icon", 8, 104, 297, 65) $icon_file = GUICtrlCreateInput($def_icon_file, 24, 128, 217, 21, $ES_READONLY, $WS_EX_CLIENTEDGE ) $select_icon = GUICtrlCreateButton("...", 256, 128, 33, 25) GuiCtrlSetState($icon_file, $GUI_ACCEPTFILES) GUICtrlSetTip($icon_file, "You can drop an file here...") GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $group4 = GUICtrlCreateGroup("Background Image", 320, 104, 297, 65) $bg_file = GUICtrlCreateInput($def_bg_file, 336, 128, 217, 21, $ES_READONLY, $WS_EX_CLIENTEDGE) $select_bg = GUICtrlCreateButton("...", 568, 128, 33, 25) GuiCtrlSetState($bg_file, $GUI_ACCEPTFILES) GUICtrlSetTip($bg_file, "You can drop an file here...") GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $group3 = GUICtrlCreateGroup("Icon Selector", 8, 176, 297, 209) $ip[1] = GUICtrlCreateRadio("", 24, 200, 59, 49, $BS_ICON + $BS_FLAT) $ip[2] = GUICtrlCreateRadio("", 96, 200, 49, 49, $BS_ICON + $BS_FLAT) $ip[3] = GUICtrlCreateRadio("", 168, 200, 49, 49, $BS_ICON + $BS_FLAT) $ip[4] = GUICtrlCreateRadio("", 232, 200, 49, 49, $BS_ICON + $BS_FLAT) $ip[5] = GUICtrlCreateRadio("", 24, 264, 49, 49, $BS_ICON + $BS_FLAT) $ip[6] = GUICtrlCreateRadio("", 24, 328, 49, 49, $BS_ICON + $BS_FLAT) $ip[7] = GUICtrlCreateRadio("", 96, 264, 49, 49, $BS_ICON + $BS_FLAT) $ip[8] = GUICtrlCreateRadio("", 96, 328, 49, 49, $BS_ICON + $BS_FLAT) $ip[9] = GUICtrlCreateRadio("", 168, 264, 49, 49, $BS_ICON + $BS_FLAT) $ip[10] = GUICtrlCreateRadio("", 232, 264, 49, 49, $BS_ICON + $BS_FLAT) $prev = GUICtrlCreateButton("<<", 168, 336, 49, 33, $BS_ICON + $BS_FLAT) $next = GUICtrlCreateButton(">>", 232, 336, 49, 33, $BS_ICON + $BS_FLAT) GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $group5 = GUICtrlCreateGroup("Background Preview", 320, 176, 297, 209) $bg = GUICtrlCreatePic($def_bg_file, 336, 200, 265, 169) GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $group6 = GUICtrlCreateGroup("Info Tip", 8, 392, 609, 65) $info_tip = GUICtrlCreateInput($def_info, 24, 416, 577, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $group7 = GUICtrlCreateGroup("Text color", 8, 464, 609, 65) $black = GUICtrlCreateRadio("Black (Default)", 24, 488, 281, 25) $white = GUICtrlCreateRadio("White", 328, 488, 281, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) ;========================================================================================================================================================================= $what = GUICtrlCreateButton("About", 8, 536, 121, 25) $uki = GUICtrlCreateButton("OK", 208, 536, 121, 25) $go = GUICtrlCreateButton("Apply", 496, 536, 121, 25) $bb = GUICtrlCreateButton("Cancel", 352, 536, 121, 25) ;========================================================================================================================================================================= ; Define context menu $context_menu = GUICtrlCreateContextMenu() $quick_start = GuiCtrlCreateMenuItem("Quick Start", $context_menu) $seperator = GuiCtrlCreateMenuItem("", $context_menu) $no_bg = GUICtrlCreateMenuitem("Remove Background Image", $context_menu) $seperator = GuiCtrlCreateMenuItem("", $context_menu) $reset_icon = GUICtrlCreateMenuitem("Reset Icon", $context_menu) $reset_bg = GUICtrlCreateMenuitem("Reset Background Image", $context_menu) $reset_info = GuiCtrlCreateMenuItem("Reset Infotip", $context_menu) $reset_color = GuiCtrlCreateMenuItem("Reset Text Color", $context_menu) $seperator = GuiCtrlCreateMenuItem("", $context_menu) $reset_all = GuiCtrlCreateMenuItem("Reset All", $context_menu) ;========================================================================================================================================================================= GUISetState(@SW_SHOW) GuiCtrlSetImage($current_folder_icon, $current_file, $def_icon_index) If $def_color = "Black" Then GUICtrlSetState($black, $GUI_CHECKED) Else GuiCtrlSetState($white, $GUI_CHECKED) EndIf ;========================================================================================================================================================================= ; Application loop While 1 $msg = GuiGetMsg() $icon_dropped = GuiCtrlRead($icon_file) If $icon_dropped <> $prev_icon_file Then $icon_index = 0 IPUpdate() $prev_icon_file = $icon_dropped EndIf $bg_dropped = GuiCtrlRead($bg_file) If $bg_dropped <> $prev_bg_file Then BGUpdate() $prev_bg_file = $bg_dropped EndIf Select Case ($msg = $GUI_EVENT_CLOSE) Or ($msg = $bb) ExitLoop Case $msg = $next $icon_index = $icon_index + 10 IPUpdate() Case $msg = $prev $icon_index = $icon_index - 10 IPUpdate() Case $msg = $select_bg $bg_dropped = FileOpenDialog("Select an image", "", "Images (*.jpg;*.bmp)", 1 + 2) If Not @Error Then BGUpdate() Case $msg = $select_icon $icon_dropped = FileOpenDialog("Select an icon", "", "Icons, Executables & dll's (*.ico;*.exe;*.dll;*.ocx;*.icl)", 1 + 2) If Not @Error Then GUICtrlSetData($icon_file, $icon_dropped) IPUpdate() EndIf Case $msg = $quick_start QuickStart() Case $msg = $reset_icon ResetIcon() Case $msg = $reset_bg ResetBg() Case $msg = $reset_info ResetInfo() Case $msg = $reset_color ResetColor() Case $msg = $reset_all ResetAll() Case $msg = $no_bg $bg_dropped = "" BGUpdate() Case $msg = $go Go() Case $msg = $uki Go() Exit Case $msg = $what Intro() EndSelect WEnd Exit ;========================================================================================================================================================================= ; Update Icon Previews Func IPUpdate() GuiCtrlSetState($ip[1], $GUI_CHECKED) If $start = 1 Then GuiCtrlSetState($ip[$def_icon_index + 1], $GUI_CHECKED) $start = 0 EndIf For $i = 1 To 10 GUICtrlSetImage($ip[$i], $def_icon_file, 49) Next For $i = 1 To 10 GUICtrlSetImage($ip[$i], $icon_dropped, $i + $icon_index - 1) Next If $icon_index = 0 Then GUICtrlSetState($prev, $GUI_DISABLE) Else GUICtrlSetState($prev, $GUI_ENABLE) Endif EndFunc ;========================================================================================================================================================================= ; Updaet Background's preview Func BGUpdate() GuiCtrlSetData($bg_file, $bg_dropped) GuiCtrlDelete($bg) $bg = GUICtrlCreatePic($bg_dropped, 336, 200, 265, 169) ; Minimize & restore the window to fit the image WinSetState("Folder Tweaker", "", @SW_MINIMIZE) WinSetState("Folder Tweaker", "", @SW_RESTORE) EndFunc ;========================================================================================================================================================================= ; Write INI Func Go() RunWait(@ComSpec & " /c " & "attrib +s " & '"' & $current_folder & '"', "", @SW_HIDE) For $i = 1 To 10 $state = GuiCtrlRead($ip[$i]) If $state = $GUI_CHECKED Then $index = $i + $icon_index - 1 EndIf Next IniWrite($current_folder & "\desktop.ini", ".ShellClassInfo", "IconFile", $icon_dropped) IniWrite($current_folder & "\desktop.ini", ".ShellClassInfo", "IconIndex", $index) IniWrite($current_folder & "\desktop.ini", ".ShellClassInfo", "ConfirmFileOp", 0) $new_bg = GuiCtrlRead($bg_file) If $new_bg <> "" Then IniWrite($current_folder & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Image", $new_bg) $new_tip = GUICtrlRead($info_tip) If $new_tip <> "" Then IniWrite($current_folder & "\desktop.ini", ".ShellClassInfo", "InfoTip", $new_tip) $state = GuiCtrlRead($black) If $state = $GUI_CHECKED Then IniDelete($current_folder & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Text") Else IniWrite($current_folder & "\desktop.ini", "{BE098140-A513-11D0-A3A4-00C04FD706EC}", "IconArea_Text", "0x00FFFFFF") EndIf EndFunc ;========================================================================================================================================================================= ; Context menu actions Func ResetIcon() $data = GuiCtrlRead($icon_file) GuiCtrlSetData($icon_file, $def_icon_file) $icon_index = Round($def_icon_index / 10) * 10 $def_icon_index = Mod($def_icon_index, 10) $start = 1 If $data = $def_icon_file Then IPUpdate() EndFunc ;========================================================================================================================================================================= Func ResetBg() $bg_dropped = $def_bg_file BGUpdate() If $def_bg_file = "" Then GuiCtrlSetData($bg_file, "") EndFunc ;========================================================================================================================================================================= Func ResetInfo() GuiCtrlSetData($info_tip, $def_info) EndFunc ;========================================================================================================================================================================= Func ResetColor() If $def_color = "Black" Then GUICtrlSetState($black, $GUI_CHECKED) Else GuiCtrlSetState($white, $GUI_CHECKED) EndIf EndFunc ;========================================================================================================================================================================= Func ResetAll() ResetIcon() ResetBg() ResetInfo() ResetColor() EndFunc ;========================================================================================================================================================================= ; About box Func Intro() MsgBox(0, "About", "This app is written by Quang Anh." & @CRLF & "Use at your own risk!") EndFunc ;========================================================================================================================================================================= ; QuickStart box Func QuickStart() MsgBox(0, "Quick Start", '1. To tweak a folder, simply right click on it and choose "Tweak This Folder".' & @CRLF &_ "2. If something went wrong, access Folder Tweaker's context menu for more options." & @CRLF &_ '3. To uninstall Folder Tweaker, use "Add/Remove Programs" on Control Panel.' & @CRLF &_ "Or, give Folder Tweaker the '-byebye' flag on the command line.") EndFunc