global $my_version = "0.3.7.5" #AutoIt3Wrapper_Res_Fileversion=0.3.7.5 #cs LiNK Fixer Fixes paths inside Windows Shortcuts. From corz.org #ce #include #include #include #include #include #include "..\..\Includes\LFN.au3" global $my_name = "LiNK Fixer" global $my_title = "LiNK Fixer.." global $ini_file = $my_name & ".ini" global $my_url = "http://corz.org/windows/software/accessories/LiNKFixer.php" global $version_url = "http://corz.org/inc/versions.php?app=LiNKFixer" global $download_url = $my_url & "#section-Download" const $message_linefeed = @LF global $newline = @CRLF global $ce_debug = 0 global $exit_code = false ; ; GetFileList() ; Builds a file list matching the requested criteria. ; func GetFileList($directory, $file_masks, $top_level_only=false, $output_file="", $return_directories=false, $entry_capacity=1000000, $directories_match_mask=false) debug("dir: " & $directory & $message_linefeed & "<=", @ScriptLineNumber) debug("mask: " & $file_masks & $message_linefeed & "<=", @ScriptLineNumber) debug("dont_recurse: " & $top_level_only & $message_linefeed & "<=", @ScriptLineNumber) debug("Dump: " & $output_file & $message_linefeed & "<=", @ScriptLineNumber) debug("return_dirs: " & $return_directories & $message_linefeed & "<=", @ScriptLineNumber) debug("mx: " & $entry_capacity & $message_linefeed & "<=", @ScriptLineNumber) debug("dirs_match_mask: " & $directories_match_mask & $message_linefeed & "<=", @ScriptLineNumber) local $directory_queue[$entry_capacity] local $directory_index = 0 local $entry_path local $search_handle local $file_paths local $file_list_text local $directory_list_text local $directory_count = 1 local $plain_directory = __LFN_Target_UnSetUnicodePrefix($directory) debug("no_unc_dir =>" & $plain_directory & "<=", @ScriptLineNumber) $directory = __LFN_Target_SetUnicodePrefix($directory) debug("dir =>" & $directory & "<=", @ScriptLineNumber) local $prefixed_directory = $directory if not _LFN_FileExists($directory) then return -1 if StringRight($directory, 1) = "\" then $directory = StringTrimRight($directory, 1) $directory_queue[$directory_count] = $directory while $directory_count > $directory_index if $exit_code = 1 then return -50 $directory_index += 1 $search_handle = _LFN_FileFindFirstFile($directory_queue[$directory_index] & "\*.*") while 1 $entry_path = _LFN_FileFindNextFile($search_handle) if @error then _LFN_FileClose($entry_path) exitloop endif if $entry_path = "." or $entry_path = ".." then continueloop $entry_path = $directory_queue[$directory_index] & "\" & $entry_path if StringInStr(_LFN_FileGetAttrib($entry_path), "D") and not $top_level_only then $directory_count += 1 if $directory_count >= $entry_capacity then $entry_capacity += 10000 debug("Increasing folder limit to " & $entry_capacity & "<=", @ScriptLineNumber) ReDim $directory_queue[$entry_capacity] endif $directory_queue[$directory_count] = $entry_path endif wend _LFN_FileClose($search_handle) if StringInStr($file_masks, ",", 2) then local $mask_list = StringSplit($file_masks, ",") else local $mask_list[2] = [1, $file_masks] endif for $mask_index = 1 to $mask_list[0] $search_handle = _LFN_FileFindFirstFile($directory_queue[$directory_index] & "\" & $mask_list[$mask_index]) if $search_handle = -1 then continueloop if @error then _LFN_FileClose($search_handle) exitloop endif while 1 $entry_path = _LFN_FileFindNextFile($search_handle) if @error then _LFN_FileClose($entry_path) exitloop endif if $entry_path = "." or $entry_path = ".." then continueloop $entry_path = $directory_queue[$directory_index] & "\" & $entry_path if not StringInStr(_LFN_FileGetAttrib($entry_path), "D") then $file_list_text &= $entry_path & $message_linefeed else $directory_list_text &= $entry_path & "|" endif wend _LFN_FileClose($search_handle) next _LFN_FileClose($search_handle) wend if $return_directories then local $directory_output = "" local $index = 1 if $directories_match_mask then $directory_list_text = StringTrimRight($directory_list_text, 1) $directory_queue = StringSplit($directory_list_text, "|") return $directory_queue else while $directory_queue[$index] <> "" $directory_output &= $directory_queue[$index] & "|" $index += 1 wend $directory_output = StringTrimRight($directory_output, 1) $directory_queue = StringSplit($directory_output, "|") return $directory_queue endif endif debug("filenames =>" & $file_list_text & "<=", @ScriptLineNumber) $file_list_text = StringTrimRight($file_list_text, 1) if $file_list_text = "" then return -99 $file_paths = StringSplit($file_list_text, $message_linefeed) if $plain_directory = $prefixed_directory then for $index = 1 to $file_paths[0] $file_paths[$index] = __LFN_Target_SetUnicodePrefix($file_paths[$index]) next endif if $output_file then local $output_handle = _LFN_FileOpen($output_file, 2) _LFN_FileWrite($output_handle, $file_list_text) _LFN_FileClose($output_handle) endif return ($file_paths) endfunc global const $TRAY_EVENT_PRIMARYDOWN = -7 global const $TRAY_EVENT_MOUSEOVER = -11 AutoItSetOption("GUIOnEventMode", 1) AutoItSetOption("GUICoordMode", 0) AutoItSetOption("TrayMenuMode", 11) AutoItSetOption("TrayOnEventMode", 1) HotKeySet("{Esc}", "EscapeHotkey") TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "ToggleWindowEvent") $exit_code = -99 global $command_option, $command_find_text, $command_replacement, $command_path, $main_gui, $default_ini_installed global $min_width, $min_height global $show_tips, $reserved_gui_option, $taskbar_entry, $always_on_top, $beep_enabled global $tray_topmost_item, $tray_about_item, $fade_in global $hover_timer = 0, $window_visible, $hover_to_show, $hover_delay global $source_dir, $source_combo global $dropped_source global $replace_combo, $find_combo, $replace_label, $replacement, $find_text, $fixed_count global $app_path 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 $command_path = StringStripWS($cmdline[$cmdline[0]], 3) $source_dir = $command_path endif if $command_path = "portable" then $default_ini_installed = FileInstall("Resources\LiNK Fixer.ini", @ScriptDir & "\" & $ini_file) $command_path = "" endif if FileExists(@ScriptDir & "\" & $ini_file) then $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\LiNK Fixer.ini", $ini_path) endif if not $default_ini_installed then UpgradeSettings() ReadSettings() CreateTrayMenu() CreateGUI() ApplyAlwaysOnTop() RegisterHotkeys() TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "HoverCheck") ; We just sit here waiting! while $exit_code = -99 Sleep(25) wend func FinishWorking() WinSetTitle($main_gui, "", $my_title & " v" & $my_version) EnableMainGUI($main_gui) AdlibUnRegister() endfunc ; ; FixLinks() ; Finds and fixes shortcuts in the selected folder. ; func FixLinks() WinSetTitle($my_title, "", $my_title & " working...") DisableMainGUI($main_gui) $fixed_count = 0 $source_dir = GUICtrlRead($source_combo) if not FileExists($source_dir) then FinishWorking() return false endif $find_text = GUICtrlRead($find_combo) $replacement = GUICtrlRead($replace_combo) if not $find_text then FinishWorking() return false endif local $shortcut_files = GetFileList($source_dir, "*.lnk") if not IsArray($shortcut_files) then return false for $index = 1 to $shortcut_files[0] local $shortcut_data = FileGetShortcut($shortcut_files[$index]) if not IsArray($shortcut_data) then continueloop for $field_index = 0 to 6 if StringInStr($shortcut_data[$field_index], $find_text) then if not FixShortcut($shortcut_files[$index], $shortcut_data) then continueloop endif $fixed_count += 1 continueloop endif next next FinishWorking() AdlibRegister("FinishWorking", 3000) if $fixed_count then WinSetTitle($main_gui, "", $my_title & " All done. Fixed " & $fixed_count & " shortcuts") else WinSetTitle($main_gui, "", $my_title & " All done. [nothing done!]") endif return true endfunc ; ; FixShortcut() ; Updates matching path fields within one shortcut. ; func FixShortcut($shortcut_path, $shortcut_data) if not $shortcut_path or not IsArray($shortcut_data) then return false for $index = 0 to 6 local $original_field = $shortcut_data[$index] $shortcut_data[$index] = StringReplace($shortcut_data[$index], $find_text, $replacement) if $original_field <> $shortcut_data[$index] then endif next if FileCreateShortcut($shortcut_data[0], $shortcut_path, $shortcut_data[1], $shortcut_data[2], $shortcut_data[3], $shortcut_data[4], "", $shortcut_data[5], $shortcut_data[6]) then return true endfunc ; ; CreateGUI() ; Creates and configures the main application window. ; func CreateGUI() if $taskbar_entry = $gui_checked then $main_gui = GUICreate($my_title & " v" & $my_version, $window_width, $window_height, $window_x, $window_y, _ BitOR($WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_SIZEBOX), $WS_EX_ACCEPTFILES) else local $taskbar_owner_gui = GUICreate("", -1, -1, 0, 0, 0, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOOLWINDOW)) $main_gui = GUICreate($my_title & " v" & $my_version, $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) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseEvent") GUISetOnEvent($GUI_EVENT_RESIZED, "ConstrainWindow") GUISetOnEvent($GUI_EVENT_DROPPED, "HandleDrop") GUISetOnEvent($GUI_EVENT_PRIMARYUP, "MinimizeEvent") GUISetOnEvent($GUI_EVENT_MINIMIZE, "ToggleWindowEvent") GUISetCoord(5, 5) local $links_group = GUICtrlCreateGroup("Fix LiNKs.. ", 0, 0, $window_width - 10, 70) local $folder_label = GUICtrlCreateLabel("Folder:", 8, 20, 50, 22) $source_combo = GUICtrlCreateCombo("", 45, -2, $window_width - 115, 200) GUICtrlSetState(-1, $GUI_DROPACCEPTED) LoadHistory($source_combo, "source_dir") local $source_history_menu = GUICtrlCreateContextMenu($source_combo) GUICtrlCreateMenuItem("Delete this item..", $source_history_menu) GUICtrlSetOnEvent(-1, "RemoveSourceHistory") GUICtrlCreateMenuItem("Wipe this list..", $source_history_menu) GUICtrlSetOnEvent(-1, "ClearSourceHistory") GUISetCoord(5, 5) local $run_button = GUICtrlCreateButton("Do It!", $window_width - 55, 18, 40, 22) GUICtrlSetOnEvent(-1, "FixLinks") GUISetCoord(5, 50) local $find_replace_width = Int(($window_width - 140) / 2) local $find_label = GUICtrlCreateLabel("Find:", 8, 0, 30, 22) $find_combo = GUICtrlCreateCombo("", 45, -2, $find_replace_width, 200) GUICtrlSetState(-1, $GUI_DROPACCEPTED) LoadHistory($find_combo, "find") local $find_history_menu = GUICtrlCreateContextMenu($find_combo) GUICtrlCreateMenuItem("Delete this item..", $find_history_menu) GUICtrlSetOnEvent(-1, "RemoveFindHistory") GUICtrlCreateMenuItem("Wipe this list..", $find_history_menu) GUICtrlSetOnEvent(-1, "ClearFindHistory") $replace_label = GUICtrlCreateLabel("Replace:", $find_replace_width + 25, 3, 40, 22) $replace_combo = GUICtrlCreateCombo("", 45, -2, $find_replace_width, 200) GUICtrlSetState(-1, $GUI_DROPACCEPTED) LoadHistory($replace_combo, "replace") local $replace_history_menu = GUICtrlCreateContextMenu($replace_combo) GUICtrlCreateMenuItem("Delete this item..", $replace_history_menu) GUICtrlSetOnEvent(-1, "RemoveReplaceHistory") GUICtrlCreateMenuItem("Wipe this list..", $replace_history_menu) GUICtrlSetOnEvent(-1, "ClearReplaceHistory") local $last_resizable_control = GUICtrlCreateGroup("", -9999, -9999) for $index = $links_group to $last_resizable_control GUICtrlSetResizing($index, $GUI_DOCKALL) next GUICtrlSetResizing($links_group, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($source_combo, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($run_button, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKTOP) GUICtrlSetResizing($find_label, $GUI_DOCKLEFT) GUICtrlSetResizing($find_combo, $GUI_DOCKAUTO) GUICtrlSetResizing($replace_label, $GUI_DOCKVCENTER) GUICtrlSetResizing($replace_combo, $GUI_DOCKAUTO) if $show_tips = $gui_checked then local $folder_tip = "some tip." & @CRLF & "more info here. " GUICtrlSetTip($folder_label, $folder_tip) GUICtrlSetTip($source_combo, $folder_tip) endif ConstrainWindow() if $fade_in = $gui_checked then FadeInWindow($main_gui) else GUISetState() endif $window_visible = true endfunc ; ; ReadSettings() ; Loads the saved application settings. ; 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", 490) $window_height = IniRead($ini_path, $my_name, "height", 86) $min_width = IniRead($ini_path, $my_name, "min_width", 490) $min_height = IniRead($ini_path, $my_name, "min_height", 86) $show_tips = IniReadCheckBoxValue($ini_path, $my_name, "show_tips", $gui_checked) $taskbar_entry = IniReadCheckBoxValue($ini_path, $my_name, "taskbar_entry", $gui_unchecked) $always_on_top = IniReadCheckBoxValue($ini_path, $my_name, "always_on_top", $gui_unchecked) $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) $find_text = IniRead($ini_path, $my_name, "find", "") $replacement = IniRead($ini_path, $my_name, "replace", "") endfunc ; ; HandleDrop() ; Processes files or folders dropped onto the window. ; func HandleDrop() $dropped_source = false if @GUI_DragId = -1 then if StringInStr(FileGetAttrib(@GUI_DragFile), "D") then $dropped_source = @GUI_DragFile else if GetExtension(@GUI_DragFile) = "lnk" then local $shortcut_details = FileGetShortcut(@GUI_DragFile) $dropped_source = $shortcut_details[0] else $dropped_source = GetParent(@GUI_DragFile) endif endif endif if $dropped_source then AddHistoryItem($source_combo, $dropped_source, "source_dir") LoadHistory($source_combo, "source_dir") ControlCommand($main_gui, "", $source_combo, "SelectString", $dropped_source) endif endfunc ; ; ReadHistory() ; Reads the stored items for a history list. ; func ReadHistory($history_key) local $history_text = IniRead($ini_path, $my_name, $history_key, "") $history_text = StringStripWS($history_text, 3) $history_text = StringReplace($history_text, "||", "|") while StringRight($history_text, 1) = "|" $history_text = StringTrimRight($history_text, 1) wend while StringLeft($history_text, 1) = "|" $history_text = StringTrimLeft($history_text, 1) wend return $history_text endfunc ; ; LoadHistory() ; Loads a history list into a combo box. ; func LoadHistory(byref $combo_control, $history_key) local $history_items = ReadHistory($history_key) $history_items = StringSplit($history_items, "|") GUICtrlSetData($combo_control, "") if $history_items[0] then for $index = 1 to $history_items[0] if $history_items[$index] then ControlCommand($main_gui, "", $combo_control, "AddString", $history_items[$index]) endif next ControlCommand($main_gui, "", $combo_control, "SelectString", $history_items[$history_items[0]]) endif endfunc func AddHistoryItem(byref $combo_control, $history_item, $history_key) if SaveHistoryItem($history_item, $history_key) then ControlCommand($main_gui, "", $combo_control, "AddString", $history_item) ControlCommand($main_gui, "", $combo_control, "SelectString", $history_item) endif endfunc ; ; SaveHistoryItem() ; Stores a history list in the settings file. ; func SaveHistoryItem($history_items, $history_key) local $history_text = "|" & ReadHistory($history_key) & "|" if $history_items <> "" and not StringInStr($history_text, "|" & $history_items & "|") then IniWrite($ini_path, $my_name, $history_key, $history_text & $history_items & "|") return true endif endfunc func RemoveSourceHistory() RemoveHistoryItem($source_combo, "source_dir") endfunc func ClearSourceHistory() ClearHistory($source_combo, "source_dir") endfunc func RemoveFindHistory() RemoveHistoryItem($find_combo, "find") endfunc func ClearFindHistory() ClearHistory($find_combo, "find") endfunc func RemoveReplaceHistory() RemoveHistoryItem($replace_combo, "replace") endfunc func ClearReplaceHistory() ClearHistory($replace_combo, "replace") endfunc func ClearHistory(byref $combo_control, $history_key) IniWrite($ini_path, $my_name, $history_key, "") LoadHistory($combo_control, $history_key) endfunc ; ; RemoveHistoryItem() ; Removes the selected item from a history list. ; func RemoveHistoryItem(byref $combo_control, $history_key) if GUICtrlRead($combo_control) = "" then return false local $history_text = "|" & ReadHistory($history_key) & "|" $history_text = StringReplace($history_text, "|" & GUICtrlRead($combo_control) & "|", "|") IniWrite($ini_path, $my_name, $history_key, $history_text) LoadHistory($combo_control, $history_key) endfunc ; ; SaveCurrentHistory() ; Saves the current combo box value to history. ; func SaveCurrentHistory(byref $combo_control, $history_key) if GUICtrlRead($combo_control) = "" then return false local $history_text = "|" & ReadHistory($history_key) & "|" $history_text = StringReplace($history_text, "|" & GUICtrlRead($combo_control) & "|", "|") IniWrite($ini_path, $my_name, $history_key, $history_text & GUICtrlRead($combo_control) & "|") LoadHistory($combo_control, $history_key) endfunc func SaveHistory() SaveCurrentHistory($source_combo, "source_dir") SaveCurrentHistory($find_combo, "find") SaveCurrentHistory($replace_combo, "replace") endfunc ; ; CreateTrayMenu() ; Creates the notification-area menu. ; func CreateTrayMenu() TrayCreateItem("Edit ini file (prefs)") TrayItemSetOnEvent(-1, "EditPrefs") TrayCreateItem("") $tray_topmost_item = TrayCreateItem("Always On Top") TrayItemSetState(-1, $always_on_top) TrayItemSetOnEvent(-1, "ToggleAlwaysOnTop") TrayCreateItem("") TrayCreateItem("About " & $my_name) TrayItemSetOnEvent(-1, "ShowAbout") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TrayExit") TraySetClick(8) TraySetState(1) TraySetIcon($app_path, 0) endfunc func ToggleWindowEvent() ToggleWindow() endfunc ; ; ToggleWindow() ; Shows or hides the main application window. ; 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 MinimizeEvent() ConstrainWindow() endfunc ; ; ConstrainWindow() ; Keeps the window within its allowed bounds. ; func ConstrainWindow() local $window_position = WinGetPos($main_gui) if $window_visible = false then return if not IsArray($window_position) then return 0 if $window_position[2] < $min_width then WinMove($main_gui, "", default, default, $min_width) if $window_position[3] < $min_height then WinMove($main_gui, "", default, default, default, $min_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) Sleep(25) $window_position = WinGetPos($main_gui) if not IsArray($window_position) then return 0 if $window_position[0] < 0 then WinMove($main_gui, "", 0, default) endif if $window_position[0] > @DesktopWidth - $window_position[2] then WinMove($main_gui, "", @DesktopWidth - $window_position[2], default) endif if $window_position[1] < 0 then WinMove($main_gui, "", default, 0) endif if $window_position[1] > @DesktopHeight - $window_position[3] then WinMove($main_gui, "", default, @DesktopHeight - $window_position[3]) endif $window_position = WinGetPos($main_gui) if not IsArray($window_position) then return 0 SaveWindowSettings() return true endfunc ; ; SaveWindowSettings() ; Saves the current window position and size. ; func SaveWindowSettings() if $window_visible = false then return local $window_position = WinGetPos($main_gui) if not IsArray($window_position) then return 0 IniWrite($ini_path, $my_name, "x", $window_position[0]) IniWrite($ini_path, $my_name, "y", $window_position[1]) $window_width = $window_position[2] $window_height = $window_position[3] $window_position = WinGetClientSize($main_gui) if IsArray($window_position) then local $client_width = $window_position[0] local $client_height = $window_position[1] else return 0 endif IniWrite($ini_path, $my_name, "width", $client_width) IniWrite($ini_path, $my_name, "height", $client_height) endfunc ; ; UpgradeSettings() ; Updates settings from earlier application versions. ; 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\LiNK 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, getparent($ini_path) & "\[" & @YEAR & "-" & @MON & "-" & @MDAY & "@" & @HOUR & "." & @MIN & "] " & $ini_file) FileMove($new_ini_path, $ini_path, 1) IniWrite($ini_path, $my_name, "version", $my_version) endfunc func EditPrefs() local $editor_path = IniRead($ini_path, $my_name, "editor", "notepad.exe") Run($editor_path & " " & $ini_path) endfunc ; ; FadeInWindow() ; Fades the specified window into view. ; 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 ; ; HoverCheck() ; Checks whether the pointer is over the window. ; 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 WinSetOnTop($main_gui, "", 1) WinSetOnTop($main_gui, "", 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 ; ; ApplyAlwaysOnTop() ; Applies the configured always-on-top state. ; func ApplyAlwaysOnTop() if $always_on_top = $gui_checked then WinSetOnTop($main_gui, "", 1) else WinSetOnTop($main_gui, "", 0) endif endfunc ; ; ToggleAlwaysOnTop() ; Toggles the always-on-top window state. ; func ToggleAlwaysOnTop() if $always_on_top = $gui_unchecked then $always_on_top = $gui_checked else $always_on_top = $gui_unchecked endif ApplyAlwaysOnTop() TrayItemSetState($tray_topmost_item, $always_on_top) iniwritecheckboxvalue($ini_path, $my_name, "always_on_top", $always_on_top) endfunc ; ; ShowAbout() ; Displays the application information dialog. ; func ShowAbout() local $previous_event_mode = AutoItSetOption("GUIOnEventMode", 0) local $previous_coord_mode = AutoItSetOption("GUICoordMode", 1) DisableMainGUI($main_gui) 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($main_gui) endfunc func DisableMainGUI($owner_gui) GUISetState(@SW_DISABLE, $owner_gui) TraySetState(2) UnregisterHotkeys() endfunc ; ; EnableMainGUI() ; Re-enables the main window after a modal dialog. ; func EnableMainGUI($owner_gui) TraySetState(1) GUISetState(@SW_ENABLE, $owner_gui) WinActivate($main_gui) GUISwitch($main_gui) RegisterHotkeys() endfunc func RegisterHotkeys() HotKeySet("{Esc}", "EscapeHotkey") endfunc func UnregisterHotkeys() HotKeySet("{Esc}") endfunc ; ; EscapeHotkey() ; Handles the Escape keyboard shortcut. ; 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 ; Bye now! func Quit($window_x = 0) SaveHistory() SaveWindowSettings() DisableMainGUI($main_gui) GUIDelete($main_gui) VersionCheckOnline($my_name, $version_url, $download_url, $ini_path, $my_name, $my_version) 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=Y #AutoIt3Wrapper_Run_Stop_OnError=Y #AutoIt3Wrapper_Res_HiDpi=Y ; *** YOU MIGHT NEED TO USE FORWARD SLASHES IN RELATIVE PATHS - YMMV!!! ** #AutoIt3Wrapper_Icon=Resources\LiNK 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 LiNK Fixer.exe. #AutoIt3Wrapper_Res_Field=Long Description|LiNK Fixer fixes the paths inside your Windows shortcuts so when you move stuff, you can re-map all your old shortcuts in one go. #AutoIt3Wrapper_Res_Field=ProductName|LiNK 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=LiNK Fixer ; this is the one that shows up in Process Explorer.. #AutoIt3Wrapper_Res_Description=LiNK Fixer - from corz.org #AutoIt3Wrapper_Res_LegalCopyright=corz.org #AutoIt3Wrapper_Res_ProductVersion=1 #AutoIt3Wrapper_Res_Field=Build|Public 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\LiNK Fixer\LiNK 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