global $my_version = "0.9.1.0" #AutoIt3Wrapper_Res_Fileversion=0.9.1.0 #include #include #include #include #include #include #include #include global $my_name = "Long Path Fixer" global $my_title = $my_name global $ini_file = $my_name & ".ini" global $my_url = "http://corz.org/windows/software/accessories/Long-Path-Fixer-for-Windows.php" global $download_url = $my_url & "#section-Download" global $version_url = "http://corz.org/inc/versions.php?app=LongPathFixer" #include "..\..\Includes\LFN.au3" const $message_linefeed = @LF global $ce_debug = 0 global $exit_code = false func GetParentPath($path) local $had_long_path_prefix = false if StringLeft($path, 4) = "\\?\" or StringLeft($path, 8) = "\\?\UNC\" then $had_long_path_prefix = true if StringRight($path, 1) = "\" then $path = StringTrimRight($path, 1) $path = getparent($path) if not StringInStr($path, "\", 2, 1, 3) or (StringInStr($path, "\UNC\") and not StringInStr($path, "\", 2, 1, 9)) then if $had_long_path_prefix then return __LFN_Target_SetUnicodePrefix($path) else return $path endif endif $path = StringLeft($path, StringInStr($path, "\", 0, -1) - 1) if $had_long_path_prefix then return __LFN_Target_SetUnicodePrefix($path) else return $path endif endfunc func IsDirectory($path) return StringInStr(_LFN_FileGetAttrib($path), "D") endfunc func CheckForUpdate($application_name, $version_check_url, $download_url, $ini_path, $ini_section, $my_version, $owner_gui = default, $disable_owner = false) #ignorefunc DisableMainGUI, EnableMainGUI local $check_interval_days = IniRead($ini_path, $ini_section, "version_checking", "") if $check_interval_days == 0 then return if $check_interval_days = -1 or $check_interval_days = "" then if $disable_owner then DisableMainGUI($disable_owner) local $new_check_interval = InputBox("Automatic Version Checking?", $application_name & " can check online for a new version of itself." & $message_linefeed & "Enter the number of days between checks (0 to disable version checking). ", "", " M", 400, 150, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 50, 0, $owner_gui) if $disable_owner then EnableMainGUI($disable_owner) if $new_check_interval = "" then return false _LFN_IniWrite($ini_path, $ini_section, "version_checking", Int($new_check_interval)) if $new_check_interval = 0 then return endif if $check_interval_days > 365 then $check_interval_days = 365 if $check_interval_days > 0 then local $last_checked = IniRead($ini_path, $ini_section, "version_checked", "2000/01/01 00:00:00") local $days_since_check = _DateDiff("D", $last_checked, _NowCalc()) if $days_since_check < $check_interval_days then return endif local $plural_suffix = "" if $check_interval_days > 1 then $plural_suffix = "s" ProgressOn("Version Check (every " & $check_interval_days & " day" & $plural_suffix & ")", "Checking for new version..") ProgressSet(25) local $online_version = InetRead($version_check_url, 1) if @error <> 0 then ProgressOff() MsgBox(16, "Version Check FAILED!", "Could not determine version online." & $message_linefeed & "Check your firewall.") return endif $online_version = BinaryToString($online_version) ProgressSet(50) IniWrite($ini_path, $ini_section, "version_checked", _NowCalc()) ProgressSet(75) local $version_comparison = _VersionCompare($my_version, $online_version) switch $version_comparison case 0, 1 ProgressSet(100) ProgressOff() return false case -1 ProgressSet(100) local $update_prompt_result = MsgBox(4 + 48 + 262144, "New Version Available", "A newer version of " & $application_name & " is available." & $message_linefeed & "Would you like to visit the download page?") ProgressOff() switch $update_prompt_result case 6 ShellExecute($download_url) endswitch endswitch endfunc global const $TRAY_ENABLE = 64 global const $TRAY_EVENT_PRIMARYDOWN = -7 global const $TRAY_EVENT_MOUSEOVER = -11 AutoItSetOption("GUIOnEventMode", 1) AutoItSetOption("GUICoordMode", 0) AutoItSetOption("TrayMenuMode", 5) AutoItSetOption("TrayOnEventMode", 1) HotKeySet("{Esc}", "EscapeHotkey") TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "ToggleWindowEvent") $exit_code = -99 global $temp_dir = @TempDir & "\Long Path Fixer" global $command_option, $command_source, $command_target, $current_path global $min_width, $window_border_width, $min_height, $window_border_height global $show_tips, $show_hidden_files, $beep_enabled, $taskbar_entry, $always_on_top, $explorer_context global $tray_topmost_item, $tray_context_item, $tray_prefs_item, $tray_about_item, $fade_in global $hover_timer = 0, $window_visible, $hover_to_show, $hover_delay global $delete_to_recycle_bin, $tray_recycle_item, $confirm_delete, $tray_confirm_delete_item global $path_combo global $last_path, $unlocker_path, $unlocker_switches global $file_list, $context_menu global $main_gui global $app_path, $portable_mode, $default_ini_installed if @Compiled then $app_path = @ScriptFullPath else $app_path = ".\" & $my_name & ".exe" endif if $cmdline[0] then if $cmdline[0] > 1 then $command_option = StringStripWS($cmdline[1], 3) endif if IsDirectory($cmdline[$cmdline[0]]) then $current_path = StringStripWS($cmdline[$cmdline[0]], 3) else $current_path = StringStripWS(GetParentPath($cmdline[$cmdline[0]]), 3) endif endif if FileExists(@ScriptDir & "\" & $ini_file) then $portable_mode = true $data_dir = @ScriptDir $ini_path = $data_dir & "\" & $ini_file else $data_dir = @AppDataDir & "\corz\" & $my_name if not FileExists($data_dir) then DirCreate($data_dir) $ini_path = $data_dir & "\" & $ini_file $default_ini_installed = FileInstall("Resources\Long Path Fixer.ini", $ini_path) endif if not $default_ini_installed then UpgradeSettings() ReadSettings() CreateTrayMenu() CreateGUI() ApplyAlwaysOnTop() RegisterHotkeys() TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "HoverCheck") while $exit_code = -99 Sleep(25) wend Quit(0) func ReadSettings() $window_x = IniRead($ini_path, $my_name, "x", -1) $window_y = IniRead($ini_path, $my_name, "y", -1) $window_width = IniRead($ini_path, $my_name, "width", 800) $window_height = IniRead($ini_path, $my_name, "height", 500) $min_width = IniRead($ini_path, $my_name, "min_width", 240) $window_border_width = 8 $min_height = IniRead($ini_path, $my_name, "min_height", 196) $window_border_height = 27 $show_tips = inireadcheckboxvalue($ini_path, $my_name, "show_tips", $gui_checked) $taskbar_entry = inireadcheckboxvalue($ini_path, $my_name, "taskbar_entry", $gui_checked) $always_on_top = inireadcheckboxvalue($ini_path, $my_name, "always_on_top", $gui_unchecked) $beep_enabled = inireadcheckboxvalue($ini_path, $my_name, "beep", $gui_checked) $hover_to_show = inireadcheckboxvalue($ini_path, $my_name, "hover_to_show", $gui_checked) $hover_delay = Abs(Int(IniRead($ini_path, $my_name, "hover_sensitivity", 8))) $fade_in = inireadcheckboxvalue($ini_path, $my_name, "fade_in", $gui_checked) $last_path = IniRead($ini_path, $my_name, "last_path", $last_path) if not $current_path and _LFN_FileExists($last_path) then $current_path = $last_path endif $unlocker_path = IniRead($ini_path, $my_name, "unlocker_path", "C:\Program Files\LockHunter\LockHunter.exe") $unlocker_switches = IniRead($ini_path, $my_name, "unlocker_switches", "-u -sm -x") $unlocker_switches &= " " $delete_to_recycle_bin = inireadcheckboxvalue($ini_path, $my_name, "delete_to_recycle_bin", $gui_unchecked) $confirm_delete = inireadcheckboxvalue($ini_path, $my_name, "confirm_delete", $gui_checked) $ce_debug = inireadcheckboxvalue($ini_path, $my_name, "do_debug", $gui_unchecked) $explorer_context = inireadcheckboxvalue($ini_path, $my_name, "explorer_context", $gui_checked) UpdateExplorerContext() endfunc func CreateTrayMenu() $tray_prefs_item = TrayCreateItem("Edit ini file (prefs)") TrayItemSetOnEvent(-1, "EditPrefs") TrayCreateItem("") $tray_topmost_item = TrayCreateItem("Always On Top") TrayItemSetState(-1, $always_on_top) TrayItemSetOnEvent(-1, "ToggleAlwaysOnTop") $tray_context_item = TrayCreateItem("Keep in Explorer Context Menu") TrayItemSetState(-1, $explorer_context) TrayItemSetOnEvent(-1, "ToggleExplorerContext") TrayCreateItem("") $tray_recycle_item = TrayCreateItem("Always delete to Recycle Bin") TrayItemSetState(-1, $delete_to_recycle_bin) TrayItemSetOnEvent(-1, "ToggleDeleteOption") $tray_confirm_delete_item = TrayCreateItem("Confirm Deletions") TrayItemSetState(-1, $confirm_delete) TrayItemSetOnEvent(-1, "ToggleConfirmDelete") TrayCreateItem("") $tray_about_item = TrayCreateItem("About " & $my_name) TrayItemSetOnEvent(-1, "ShowAbout") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TrayExit") TraySetClick(8) TraySetState(1) TraySetIcon($app_path, 0) endfunc func CreateGUI() local $gui_font = "Segeo UI" if StringInStr(@OSType, "XP") or StringInStr(@OSType, "2003") then $gui_font = "Tahoma" endif if $taskbar_entry = $gui_checked then $main_gui = GUICreate($my_title, $window_width, $window_height, $window_x, $window_y, BitOR($WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_SIZEBOX), $WS_EX_ACCEPTFILES) else global $taskbar_owner_gui = GUICreate("", -1, -1, 0, 0, 0, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOOLWINDOW)) $main_gui = GUICreate($my_title, $window_width, $window_height, $window_x, $window_y, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_SIZEBOX), -1, $taskbar_owner_gui) endif GUISetIcon($app_path, 0, $main_gui) GUISetFont(10, 400, default, $gui_font, $main_gui) GUIRegisterMsg($WM_COMMAND, "ListBoxCommand") GUISetOnEvent($GUI_EVENT_CLOSE, "CloseEvent") GUISetOnEvent($GUI_EVENT_RESIZED, "ConstrainWindow") GUISetOnEvent($GUI_EVENT_DROPPED, "HandleDrop") GUISetOnEvent($GUI_EVENT_RESIZED, "ResizeEvent") GUISetOnEvent($GUI_EVENT_PRIMARYUP, "MinimizeEvent") GUISetOnEvent($GUI_EVENT_MINIMIZE, "ToggleWindowEvent") $path_combo = GUICtrlCreateCombo("", 10, 10, $window_width - 20, 23, -1, $WS_EX_ACCEPTFILES) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKHEIGHT + $GUI_DOCKRIGHT) GUICtrlSetOnEvent(-1, "PathChanged") GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSetTip(-1, " Select a drive from this drop-down lost (or drag and drop a folder onto the list itself). ") local $drive_list = DriveGetDrive("all") for $index = 1 to $drive_list[0] GUICtrlSetData($path_combo, StringUpper($drive_list[$index]) & "\") next GUISetCoord(0, 0) $file_list = GUICtrlCreateList("", 10, 40, $window_width - 20, $window_height - 85, BitOR($LBS_NOTIFY, $WS_MAXIMIZEBOX), $WS_EX_ACCEPTFILES) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSetTip(-1, " This is the list of files and folders in the current directory. You can drag stuff into here. ") CreateContextMenu() GUISetCoord(0, 0) GUICtrlCreateButton("Move", 10, $window_height - 40, ($window_width / 3) - 12, 35) GUICtrlSetOnEvent(-1, "MoveItem") GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKLEFT + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, " Click this to move the currently selected file or folder. ") GUICtrlCreateButton("Copy", ($window_width / 3) - 5, 0, ($window_width / 3) - 12, 35) GUICtrlSetOnEvent(-1, "CopyItem") GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, " Click this to move the currently selected file or folder. ") GUICtrlCreateButton("Delete", ($window_width / 3), 0, ($window_width / 3) - 12, 35) GUICtrlSetOnEvent(-1, "DeleteItem") GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, " Click this to delete the currently selected file or folder. ") ConstrainWindow() RefreshFileList() if $fade_in = $gui_checked then FadeInWindow($main_gui) else GUISetState() endif $window_visible = true endfunc func CreateContextMenu() $context_menu = GUICtrlCreateContextMenu($file_list) GUICtrlCreateMenuItem("Shell Open", $context_menu) GUICtrlSetOnEvent(-1, "OpenItem") GUICtrlCreateMenuItem("", $context_menu) GUICtrlCreateMenuItem("Move", $context_menu) GUICtrlSetOnEvent(-1, "MoveItem") GUICtrlCreateMenuItem("Copy", $context_menu) GUICtrlSetOnEvent(-1, "CopyItem") GUICtrlCreateMenuItem("Rename", $context_menu) GUICtrlSetOnEvent(-1, "RenameItem") GUICtrlCreateMenuItem("", $context_menu) GUICtrlCreateMenuItem("Delete", $context_menu) GUICtrlSetOnEvent(-1, "DeleteItem") if $delete_to_recycle_bin = $gui_unchecked then GUICtrlCreateMenuItem("Delete to Recycle Bin", $context_menu) GUICtrlSetOnEvent(-1, "ForceDeleteItem") endif GUICtrlCreateMenuItem("", $context_menu) GUICtrlCreateMenuItem("Unlock", $context_menu) GUICtrlSetOnEvent(-1, "UnlockItem") GUICtrlCreateMenuItem("", $context_menu) GUICtrlCreateMenuItem("Copy Path", $context_menu) GUICtrlSetOnEvent(-1, "CopyShortPath") GUICtrlCreateMenuItem("Copy Short (8.3) Path", $context_menu) GUICtrlSetOnEvent(-1, "CopyLongPath") endfunc func PathChanged() $current_path = StringTrimRight(GUICtrlRead($path_combo), 1) RefreshFileList() endfunc func HandleDrop() local $dropped_directory = false if @GUI_DragId = -1 then local $dropped_path = @GUI_DragFile if not _IsPressed(11) and getextension($dropped_path) = "lnk" then local $shortcut_details = FileGetShortcut($dropped_path) $dropped_path = $shortcut_details[0] endif if StringInStr(FileGetAttrib($dropped_path), "D") then $dropped_directory = $dropped_path else $dropped_directory = GetParentPath($dropped_path) endif if $dropped_directory then $current_path = $dropped_directory RefreshFileList() endif endif endfunc func RefreshFileList() _GUICtrlListBox_ResetContent($file_list) _GUICtrlListBox_AddString($file_list, ChrW(9679) & ChrW(9679)) if StringRight($current_path, 1) = "\" then StringTrimRight($current_path, 1) local $directory_entries = ExpandFileSearchPattern($current_path & "\*.*") local $entry_name for $index = 1 to $directory_entries[0] $entry_name = BaseName($directory_entries[$index]) if IsDirectory($current_path & "\" & $entry_name) then $entry_name &= "\" _GUICtrlListBox_AddString($file_list, $entry_name) next endfunc func OpenItem() local $selected_item = GetSelectedItem() if not $selected_item then return ShellExecute($current_path & "\" & $selected_item) endfunc func UnlockItem() local $selected_item = GetSelectedItem() if not $selected_item then return if not FileExists($unlocker_path) then local $selected_unlocker_path = FileOpenDialog("Please locate LockHunter", "C:\Program Files", "LockHunter (LockHunter.exe)", 1, "LockHunter.exe", $main_gui) if FileExists($selected_unlocker_path) then $unlocker_path = $selected_unlocker_path IniWrite($ini_path, $my_name, "unlocker_path", $unlocker_path) else MsgBox($MB_TOPMOST, "Couldn't Run LockHunter!", "Couldn't Run LockHunter! ", 0) return endif endif if not FileExists($unlocker_path) then ShellExecute("http://www.lockhunter.com/index.htm") return else local $unlock_target_path = $current_path & "\" & $selected_item if StringLen($unlock_target_path) > 258 then $unlock_target_path = _LFN_FileGetLongName(GetParentPath($current_path)) & "\" & BaseName($current_path) & "\" & $selected_item endif if StringLen($unlock_target_path) > 258 then $unlock_target_path = _LFN_FileGetLongName($current_path) & "\" & $selected_item endif if StringLen($unlock_target_path) > 258 then $unlock_target_path = _LFN_FileGetLongName($current_path & "\" & $selected_item) endif local $unlocker_exit_code = ShellExecuteWait($unlocker_path, $unlocker_switches & '"' & $unlock_target_path & '"', $current_path, "") if $unlocker_exit_code = 0 then MsgBox($MB_TOPMOST, "Unlocked!", $current_path & "\" & $selected_item & " has been unlocked! ", 30) else MsgBox($MB_TOPMOST, "LockHunter Error!", "LockHunter exited with a non-zero status!! ", 30) endif endif endfunc func CopyShortPath() local $resolved_path = _LFN_FileGetShortName($current_path & "\" & GetSelectedItem()) if not $resolved_path then return ClipPut($resolved_path) endfunc func CopyLongPath() local $resolved_path = GetSelectedItem() if not $resolved_path then return ClipPut(_LFN_FileGetLongName($current_path & "\" & $resolved_path)) endfunc func DeleteItem() OperateOnItem("delete") endfunc func ForceDeleteItem() $delete_to_recycle_bin = $gui_checked OperateOnItem("delete") $delete_to_recycle_bin = $gui_unchecked endfunc func MoveItem() OperateOnItem("move") endfunc func CopyItem() OperateOnItem("copy") endfunc func RenameItem() OperateOnItem("rename") endfunc func OperateOnItem($operation) local $operation_succeeded, $intermediate_succeeded local $selected_item = GetSelectedItem() if not $selected_item then return if StringRight($selected_item, 1) = "\" then $selected_item = StringTrimRight($selected_item, 1) local $source_path = $current_path & "\" & $selected_item if not _LFN_FileExists($source_path) then return local $item_type = "file" if IsDirectory($source_path) then $item_type = "directory" switch $operation case "rename" local $current_name = BaseName($source_path) DisableMainGUI() local $new_name = InputBox("Choose a new name", "Please choose a new name for this " & $item_type & "..", $current_name, "", 260 + (3.7 * StringLen($current_name)), 130, default, default, 0, $main_gui) EnableMainGUI() if not $new_name then return if IsDirectory($source_path) then $operation_succeeded = _LFN_DirMove($source_path, GetParentPath($source_path) & "\" & $new_name) else $operation_succeeded = _LFN_FileMove($source_path, GetParentPath($source_path) & "\" & $new_name) endif RefreshFileList() if not $operation_succeeded then MsgBox($MB_TOPMOST + 48, "Rename Failed!", "Rename Failed!" & @LF & @LF & "Possibly you don't have the correct permissions to Rename this " & $item_type & ". ", 0) case "delete" local $delete_confirmation if $confirm_delete = $gui_checked then $delete_confirmation = MsgBox($MB_TOPMOST + 4, "Really Delete?", "Do you really wish to delete this " & $item_type & "? " & @LF & @LF & " " & $source_path, 0) else $delete_confirmation = 6 endif switch $delete_confirmation case 6 if IsDirectory($source_path) then if $delete_to_recycle_bin = $gui_checked then CreateTempDir() $intermediate_succeeded = _LFN_DirMove($source_path, $temp_dir & "\" & $selected_item, 1) if $intermediate_succeeded then $operation_succeeded = FileRecycle($temp_dir & "\" & $selected_item) else $operation_succeeded = _LFN_DirRemove($source_path, 1) endif else if $delete_to_recycle_bin = $gui_checked then CreateTempDir() $intermediate_succeeded = _LFN_FileMove($source_path, $temp_dir & "\" & $selected_item, 1) if $intermediate_succeeded then $operation_succeeded = FileRecycle($temp_dir & "\" & $selected_item) else $operation_succeeded = _LFN_FileDelete($source_path) endif endif case 7 return endswitch local $recycle_warning = "" if $delete_to_recycle_bin = $gui_checked then $recycle_warning = @LF & @LF & "NOTE: Recycling items can fail if the file name is too long. " & @LF & "Either do a full delete, or first rename the file to something shorter." if not $operation_succeeded then MsgBox($MB_TOPMOST + 48, "Delete Failed!", "Delete Failed!" & @LF & @LF & "Possibly you don't have the correct permissions to delete this " & $item_type & ". " & $recycle_warning, 0) case "move", "copy" local $operation_title = _StringProper($operation) local $folder_dialog_root = IniRead($ini_path, $my_name, "root_select_dir", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") DisableMainGUI() local $destination_dir = FileSelectFolder("Select a destination folder..", $folder_dialog_root, 7, "", $main_gui) EnableMainGUI() if $destination_dir = "" or not _LFN_FileExists($destination_dir) then return IniWrite($ini_path, $my_name, "root_select_dir", $destination_dir) if IsDirectory($source_path) then if _LFN_FileExists($destination_dir & "\" & BaseName($source_path)) then MsgBox($MB_TOPMOST + 48, "Folder Already Exists!", $operation_title & " Failed!" & @LF & @LF & "The folder already exists in the target location! ", 0) return endif switch $operation case "move" $operation_succeeded = _LFN_DirMove($source_path, $destination_dir & "\" & $selected_item, 0) case "copy" $operation_succeeded = _LFN_DirCopy($source_path, $destination_dir & "\" & $selected_item, 0) endswitch else if _LFN_FileExists($destination_dir & "\" & BaseName($source_path)) then MsgBox($MB_TOPMOST + 48, "File Already Exists!", $operation_title & " Failed!" & @LF & @LF & "The file already exists in the target location! ", 0) return endif switch $operation case "move" $operation_succeeded = _LFN_FileMove($source_path, $destination_dir, 0) case "copy" $operation_succeeded = _LFN_FileCopy($source_path, $destination_dir, 0) endswitch endif if not $operation_succeeded then MsgBox($MB_TOPMOST + 48, $operation_title & " Failed!", $operation_title & " Failed!" & @LF & @LF & "Possibly you don't have the correct permissions to " & $operation & " this " & $item_type & ". ", 0) endswitch if $operation_succeeded then RefreshFileList() endfunc func CreateTempDir() local $intermediate_succeeded if not FileExists($temp_dir) then $intermediate_succeeded = DirCreate($temp_dir) if not $intermediate_succeeded then MsgBox($MB_TOPMOST, "Temp Folder Error!", "I cannot create the temporary folder! " & @LF & "(" & $temp_dir & ") ", 0) endif endfunc func GetSelectedItem() local $selected_index = _GUICtrlListBox_GetCurSel($file_list) if $selected_index = -1 then MsgBox($MB_TOPMOST, "Nothing Selected!", "Please select something first! ", 0) return false endif return _GUICtrlListBox_GetText($file_list, $selected_index) endfunc func ListBoxCommand($window_handle, $message_id, $wparam, $lparam) #forceref $window_handle, $message_id local $control_id, $file_list_handle if not IsHWnd($file_list) then $file_list_handle = GUICtrlGetHandle($file_list) $control_id = $lparam local $notification_code = BitShift($wparam, 16) switch $control_id case $file_list, $file_list_handle switch $notification_code case $LBN_DBLCLK local $selected_item = GetSelectedItem() if not $selected_item then return if StringRight($selected_item, 1) = "\" then $selected_item = StringTrimRight($selected_item, 1) if $selected_item = ChrW(9679) & ChrW(9679) then $current_path = GetParentPath($current_path) RefreshFileList() elseif IsDirectory($current_path & "\" & $selected_item) then $current_path = $current_path & "\" & $selected_item RefreshFileList() else OpenItem() endif endswitch endswitch return $GUI_RUNDEFMSG endfunc func SaveLastPath() local $last_path = $current_path IniWrite($ini_path, $my_name, "last_path", $last_path) endfunc func ToggleWindowEvent() ToggleWindow() endfunc func ToggleWindow() local $window_state = WinGetState($main_gui) if BitAND($window_state, 2) then UnregisterHotkeys() GUISetState(@SW_HIDE, $main_gui) $window_visible = false else GUISetState(@SW_SHOW, $main_gui) $window_visible = true RegisterHotkeys() endif endfunc func EditPrefs() local $editor_path = IniRead($ini_path, $my_name, "editor", "notepad.exe") TrayItemSetState($tray_prefs_item, 4) Run($editor_path & " " & $ini_path) endfunc func ToggleDeleteOption() switch TrayItemGetState($tray_recycle_item) case $TRAY_ENABLE + $gui_checked $delete_to_recycle_bin = $gui_checked case $TRAY_ENABLE + $gui_unchecked $delete_to_recycle_bin = $gui_unchecked endswitch GUICtrlDelete($context_menu) CreateContextMenu() iniwritecheckboxvalue($ini_path, $my_name, "delete_to_recycle_bin", $delete_to_recycle_bin) endfunc func ToggleConfirmDelete() switch TrayItemGetState($tray_confirm_delete_item) case $TRAY_ENABLE + $gui_checked $confirm_delete = $gui_checked case $TRAY_ENABLE + $gui_unchecked $confirm_delete = $gui_unchecked endswitch iniwritecheckboxvalue($ini_path, $my_name, "confirm_delete", $confirm_delete) endfunc func ToggleAlwaysOnTop() local $previous_topmost_state = $always_on_top switch TrayItemGetState($tray_topmost_item) case $TRAY_ENABLE + $gui_checked $always_on_top = $gui_checked case $TRAY_ENABLE + $gui_unchecked $always_on_top = $gui_unchecked endswitch if $previous_topmost_state <> $always_on_top then iniwritecheckboxvalue($ini_path, $my_name, "always_on_top", $always_on_top) ApplyAlwaysOnTop() endfunc func ApplyAlwaysOnTop() if $always_on_top = $gui_checked then WinSetOnTop($main_gui, "", 1) else WinSetOnTop($main_gui, "", 0) endif endfunc func ToggleExplorerContext() if $explorer_context = $gui_unchecked then $explorer_context = $gui_checked else $explorer_context = $gui_unchecked endif TrayItemSetState($tray_context_item, $explorer_context) iniwritecheckboxvalue($ini_path, $my_name, "explorer_context", $gui_checked) UpdateExplorerContext() endfunc func UpdateExplorerContext() if $explorer_context = $gui_checked then if RegRead("HKEY_CLASSES_ROOT\Directory\shell\" & $my_name, "") = $my_name & ".." then return if RegWrite("HKEY_CLASSES_ROOT\Directory\shell\" & $my_name, "", "REG_SZ", $my_name & "..") and RegWrite("HKEY_CLASSES_ROOT\Directory\shell\" & $my_name & "\command", "", "REG_SZ", '"' & $app_path & '" ' & ' "%1"') then TrayItemSetState($tray_context_item, $explorer_context) else TrayItemSetState($tray_context_item, 128) endif else if RegDelete("HKEY_CLASSES_ROOT\Directory\shell\" & $my_name) then TrayItemSetState($tray_context_item, $explorer_context) else TrayItemSetState($tray_context_item, 128) endif endif endfunc func FadeInWindow($owner_gui, $fade_step = 5) WinSetTrans($owner_gui, "", 0) GUISetState(@SW_SHOW, $owner_gui) local $index = 100 while $index >= 3 WinSetTrans($owner_gui, "", (100 - $index) * 2.55) Sleep(5) $index -= $fade_step wend WinSetTrans($owner_gui, "", 255) WinActivate($owner_gui) endfunc func HoverCheck() if not $window_visible then return if $hover_to_show = $gui_unchecked then return if $hover_timer = 0 or _Timer_Diff($hover_timer) > 1000 then $hover_timer = _Timer_Init() endif local $hover_elapsed = _Timer_Diff($hover_timer) if $hover_elapsed > ((11 - $hover_delay) * 100) then $hover_timer = 0 Sleep(100) WinActivate($main_gui) RedrawWindow($main_gui) endif endfunc func RedrawWindow($window_handle, $update_region = 0, $update_flags = 0, $redraw_flags = 5) local $region_pointer, $dll_result if $update_region <> 0 then $region_pointer = DllStructGetPtr($update_region) $dll_result = DllCall("User32.dll", "int", "RedrawWindow", "hwnd", $window_handle, "ptr", $region_pointer, "int", $update_flags, "int", $redraw_flags) if IsArray($dll_result) then return ($dll_result[0] <> 0) endfunc func ResizeEvent() ConstrainWindow() endfunc func MinimizeEvent() ConstrainWindow() endfunc func ConstrainWindow() local $window_position = WinGetPos($main_gui) if not IsArray($window_position) then return 0 if $window_position[2] < $min_width + $window_border_width then WinMove($main_gui, "", default, default, $min_width + $window_border_width) if $window_position[3] < $min_height + $window_border_height then WinMove($main_gui, "", default, default, default, $min_height + $window_border_height) Sleep(25) $window_position = WinGetPos($main_gui) if not IsArray($window_position) then return 0 if $window_position[0] > @DesktopWidth - $window_position[2] then WinMove($main_gui, "", @DesktopWidth - $window_position[2], default, default) if $window_position[1] > @DesktopHeight - $window_position[3] then WinMove($main_gui, "", default, @DesktopHeight - $window_position[3], default) return true endfunc func SaveWindowSettings() if not ConstrainWindow() then return 0 local $window_position = WinGetPos($main_gui) if not IsArray($window_position) then return 0 if $window_x <> $window_position[0] and $window_position[0] >= 0 and $window_position[0] < (@DesktopWidth - 25) then IniWrite($ini_path, $my_name, "x", $window_position[0]) if $window_y <> $window_position[1] and $window_position[1] >= 0 and $window_position[1] < (@DesktopHeight - 25) then IniWrite($ini_path, $my_name, "y", $window_position[1]) $window_position = WinGetClientSize($main_gui) if not IsArray($window_position) then return 0 IniWrite($ini_path, $my_name, "width", $window_position[0]) IniWrite($ini_path, $my_name, "height", $window_position[1]) endfunc func UpgradeSettings() local $stored_version = IniRead($ini_path, $my_name, "version", 0) local $version_comparison = _VersionCompare($my_version, $stored_version) switch $version_comparison case 0, -1 return false endswitch local $new_ini_path = @TempDir & "\" & $ini_file & ".new" FileInstall("Resources\Long Path Fixer.ini", $new_ini_path, 1) local $section_names = IniReadSectionNames($new_ini_path) if IsArray($section_names) then for $section_index = 1 to $section_names[0] if $section_names[$section_index] <> $my_name then IniDelete($new_ini_path, $section_names[$section_index]) endif next endif $section_names = IniReadSectionNames($ini_path) if IsArray($section_names) then for $section_index = 1 to $section_names[0] local $section_data = IniReadSection($ini_path, $section_names[$section_index]) if IsArray($section_data) then for $key_index = 1 to $section_data[0][0] if StringLeft($section_data[$key_index][0], 1) <> "#" then IniWrite($new_ini_path, $section_names[$section_index], $section_data[$key_index][0], $section_data[$key_index][1]) endif next endif next endif FileMove($ini_path, GetParentPath($ini_path) & "\[" & @YEAR & "-" & @MON & "-" & @MDAY & "@" & @HOUR & "." & @MIN & "] " & $ini_file & ".ini") FileMove($new_ini_path, $ini_path, 1) IniWrite($ini_path, $my_name, "version", $my_version) endfunc func ShowAbout() TrayItemSetState($tray_about_item, 4) local $previous_event_mode = AutoItSetOption("GUIOnEventMode", 0) local $previous_coord_mode = AutoItSetOption("GUICoordMode", 1) DisableMainGUI() local $about_gui = GUICreate(" About " & $my_name & "..", 250, 105, -1, -1, $WS_CAPTION, $WS_EX_TOPMOST) GUICtrlCreateLabel(" " & $my_name & " v" & $my_version & @LF & " from corz.org", 60, 8) GUICtrlCreateIcon($app_path, 0, 10, 10) GUICtrlCreateLabel(" Do you want to visit the " & @LF & " " & $my_name & " web page at this time? ", 60, 40) local $no_button = GUICtrlCreateButton("NO, not right now", 10, 80, 95, 22) GUICtrlSetTip(-1, "The other button is the one you want to click!") local $yes_button = GUICtrlCreateButton("YES, let's do it!", 148, 80, 95, 22) GUICtrlSetTip(-1, "The link will open in your system default browser") GUISetState() if WinExists($my_name) then GUISetState(@SW_DISABLE, $main_gui) while 1 local $gui_message = GUIGetMsg() switch $gui_message case $GUI_EVENT_CLOSE, $no_button GUIDelete($about_gui) exitloop case $yes_button visiturl($my_url) GUIDelete($about_gui) exitloop endswitch wend AutoItSetOption("GUICoordMode", $previous_coord_mode) AutoItSetOption("GUIOnEventMode", $previous_event_mode) EnableMainGUI() endfunc func DisableMainGUI() GUISetState(@SW_DISABLE, $main_gui) TraySetState(2) UnregisterHotkeys() endfunc func EnableMainGUI() TraySetState(1) GUISetState(@SW_ENABLE, $main_gui) WinActivate($main_gui) GUISwitch($main_gui) RegisterHotkeys() endfunc func RegisterHotkeys() HotKeySet("{F5}", "RefreshHotkey") HotKeySet("{F2}", "RenameHotkey") HotKeySet("{Del}", "DeleteHotkey") HotKeySet("{Esc}", "EscapeHotkey") endfunc func UnregisterHotkeys() HotKeySet("{F5}") HotKeySet("{F2}") HotKeySet("{Del}") HotKeySet("{Esc}") endfunc func RefreshHotkey() if WinActive($main_gui) then RefreshFileList() else HotKeySet("{F5}") Send("{F5}") HotKeySet("{F5}", "RefreshHotkey") endif endfunc func DeleteHotkey() if WinActive($main_gui) then DeleteItem() else HotKeySet("{Del}") Send("{Del}") HotKeySet("{Del}", "DeleteHotkey") endif endfunc func RenameHotkey() if WinActive($main_gui) then RenameItem() else HotKeySet("{F2}") Send("{F2}") HotKeySet("{F2}", "RenameHotkey") endif endfunc func EscapeHotkey() if WinActive($main_gui) then Quit(-9) else HotKeySet("{Esc}") Send("{Esc}") HotKeySet("{Esc}", "EscapeHotkey") endif endfunc func TrayExit() Quit(-9) endfunc func CloseEvent() Quit(-9) endfunc func Quit($window_x = 0) SaveLastPath() SaveWindowSettings() if FileExists($temp_dir) then DirRemove($temp_dir) CheckForUpdate($my_name, $version_url, $download_url, $ini_path, $my_name, $my_version, $main_gui) exit $window_x endfunc ; Compiler Directives.. ; #Region #pragma compile(AutoItExecuteAllowed, true) ; #pragma compile(ExecLevel, HighestAvailable) #pragma compile(Compression, 9) #AutoIt3Wrapper_LogFile="%scriptdir%\wrapper.log" #AutoIt3Wrapper_Run_Au3Stripper=Y #Au3Stripper_Parameters=/StripOnly /rsln #AutoIt3Wrapper_UseX64=Y #AutoIt3Wrapper_UseUpx=N #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 -v 1 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=N #AutoIt3Wrapper_Run_Stop_OnError=N #AutoIt3Wrapper_Res_HiDpi=Y ; *** YOU MIGHT NEED TO USE FORWARD SLASHES IN RELATIVE PATHS - YMMV!!! ** #AutoIt3Wrapper_Icon=Resources\Long Path Fixer.ico ; Free-Form Res Fields.. #AutoIt3Wrapper_Res_Field=Author|corz.org #AutoIt3Wrapper_Res_Field=CompanyName|corz.org #AutoIt3Wrapper_Res_Field=Contact|software@corz.org #AutoIt3Wrapper_Res_Field=Copyright|corz.org #AutoIt3Wrapper_Res_Field=Instructions|Launch Long Path Fixer.exe. #AutoIt3Wrapper_Res_Field=Long Description|Long Path Fixer fixes the paths that Explorer (and others) can't reach. #AutoIt3Wrapper_Res_Field=ProductName|Long Path Fixer #AutoIt3Wrapper_Res_Field=Publisher|corz.org #AutoIt3Wrapper_Res_Field=Web Page|http://corz.org/ #AutoIt3Wrapper_Res_Field=Compiled|%date% %time% ; application's resource info.. #AutoIt3Wrapper_Res_Comment=Long Path Fixer ; this is the one that shows up in Process Explorer.. #AutoIt3Wrapper_Res_Description=Long Path Fixer - from corz.org #AutoIt3Wrapper_Res_LegalCopyright=corz.org #AutoIt3Wrapper_Res_ProductVersion=1 #AutoIt3Wrapper_Res_Field=Build|Beta Release ;; BASIC BACKUP: ; Backup this version of the script (dropped into a backup.zip, below). So I don't have to remember to.. #AutoIt3Wrapper_Run_After=copy "%in%" ".\%scriptfile% - %fileversion%.au3" ; Handy to keep a backup of the stripped version, too.. #AutoIt3Wrapper_Run_After=move /Y .\%scriptfile%_stripped.au3 ".\%scriptfile% - %fileversion%_stripped.au3" ;::dev::.. ; Copy latest binaries to app folders (overwrites existing binary). Your copy may be somewhere else.. ; #AutoIt3Wrapper_Run_After=copy "%outx64%" "C:\Program Files\corz\Long Path Fixer\Long Path Fixer.exe" ; Backup this version of the source files to BackUp.zip.. #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip ".\BackUp.zip" ".\%scriptfile% - %fileversion%.au3" #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip ".\BackUp.zip" ".\%scriptfile% - %fileversion%_stripped.au3" ; Note: The 7z and checksum program directories are in my %PATH% (System Properties >> Advanced >> Environment Variables). ; Which is why I don't need to supply the full paths in these commands. ; Finally, remove the (now-zipped) source files.. #AutoIt3Wrapper_Run_After=del /f /q ".\%scriptfile% - %fileversion%.au3" #AutoIt3Wrapper_Run_After=del /f /q ".\%scriptfile% - %fileversion%_stripped.au3" #EndRegion