Created
July 3, 2025 14:45
-
-
Save z4none/7258567b2fe3041276c048c42c03a06d to your computer and use it in GitHub Desktop.
win11 file explorer
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 | |
| #NoTrayIcon | |
| OldColor := "" | |
| TitlePrior := "" | |
| Title := "" | |
| LTickCound := 0 | |
| RTickCound := 0 | |
| DblClickTime := DllCall("GetDoubleClickTime", "UInt") ; 从系统获取双击时间间隔 | |
| #HotIf WinActive("ahk_class CabinetWClass") | |
| ~LButton:: | |
| { | |
| global LTickCound, RTickCound, TitlePrior, Title, OldColor, DblClickTime | |
| ; 尝试获取当前窗口标题 | |
| Try { | |
| Title := WinGetTitle("A") | |
| } | |
| ; 获取当前鼠标位置的颜色 | |
| MouseGetPos(&x, &y) | |
| local currentColor := PixelGetColor(x, y) ; 使用 local 避免与 OldColor 混淆 | |
| ; 逻辑判断: | |
| ; 1. currentColor 为特定颜色 "0x191919" | |
| ; 2. 上一个热键是 ~LButton 且两次点击间隔小于双击时间 | |
| ; 3. 上次左键点击时间晚于上次右键点击时间 | |
| ; 4. 当前窗口标题与上次点击时的窗口标题相同 | |
| if (currentColor = "0x191919") | |
| { | |
| ; 检查是否是双击且在双击时间内 | |
| if (A_PriorHotkey = "~LButton" && A_TimeSincePriorHotkey < DblClickTime) | |
| { | |
| ; 检查左键点击时间是否晚于右键点击时间 (避免左右键混按的误触发) | |
| if (LTickCound > RTickCound) | |
| { | |
| ; 检查窗口标题是否相同 (避免在不同窗口中触发) | |
| if (Title = TitlePrior) | |
| { | |
| Send "!{up}" ; 发送 Alt + Up 返回上一级 | |
| } | |
| } | |
| } | |
| } | |
| ; 更新全局变量以供下次点击使用 | |
| OldColor := currentColor | |
| LTickCound := A_TickCount | |
| TitlePrior := Title | |
| } | |
| ; ~RButton 热键的修复 | |
| ~RButton:: | |
| { | |
| global RTickCound | |
| RTickCound := A_TickCount | |
| } | |
| ; ^+t 热键的修复和改进 | |
| ; 这个热键的逻辑是:在当前应用程序的地址栏复制内容,然后打开新标签页,粘贴,回车两次,然后返回地址栏再回车一次。 | |
| ^+t:: | |
| { | |
| ShortSleep := 50 | |
| MediumSleep := 100 | |
| ; LongSleep := 1000 ; This variable isn't used in the script, so it can be removed if not needed elsewhere. | |
| ; Initialize clipboardBackup to an empty string. This ensures it always has a value. | |
| local clipboardBackup := "" | |
| ; Attempt to retrieve clipboard content, but only if it's not empty. | |
| ; Check if Clipboard is not empty before backing it up to avoid the error. | |
| if (A_Clipboard != "") { | |
| clipboardBackup := A_Clipboard | |
| } | |
| ; Clear the clipboard for the upcoming copy operation. | |
| A_Clipboard := "" | |
| Send "!d" ; Usually selects the address bar (e.g., in a browser or file explorer) | |
| Sleep ShortSleep | |
| Send "^c" ; Copy the content of the address bar | |
| ; Use ClipWait to ensure the clipboard has successfully received content. | |
| ClipWait 2 ; Wait for clipboard content, up to 2 seconds | |
| ; If the clipboard is still empty after ClipWait, the copy failed. | |
| if (A_Clipboard = "") | |
| { | |
| MsgBox "Error: Failed to copy content to the clipboard.", "Operation Failed", "IconStop" | |
| return ; Exit the hotkey routine | |
| } | |
| Send "^t" ; Open a new tab (e.g., in a browser) | |
| Sleep MediumSleep | |
| Send "!d" ; Select the address bar/input field of the new tab | |
| Sleep MediumSleep | |
| Send "^v" ; Paste the copied content | |
| Sleep ShortSleep | |
| Send "{Enter}" ; First Enter, typically to confirm paste and navigate | |
| Sleep ShortSleep | |
| Send "{Enter}" ; Second Enter, might be needed for confirmation or further navigation in some apps | |
| Sleep MediumSleep | |
| Send "!d" ; Select the address bar again (return to the address bar) | |
| Sleep ShortSleep | |
| Send "{Enter}" ; Final Enter (may be a confirmation in some applications) | |
| Sleep ShortSleep | |
| ; Restore the original clipboard content, if a backup exists. | |
| if (clipboardBackup != "") { | |
| A_Clipboard := clipboardBackup | |
| } | |
| clipboardBackup := "" ; Clear the backup variable to free memory | |
| } | |
| #HotIf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment