最终效果展示
- 智能路径提示:当你打开任何标准的“打开/另存为”对话框时,屏幕左上角会“浮现”一个带阴影的、半透明的窗口,实时显示当前 Directory Opus 正在浏览的路径。

- 一键丝滑跳转:在对话框中,无需 Ctrl+G,只需快速双击左 Alt 键,脚本就会自动将 DOpus 的路径填入对话框并回车,瞬间带你“穿越”到目标文件夹。
完整脚本(可直接使用)
#NoEnv
#SingleInstance force
SendMode Input
SetWorkingDir %A_ScriptDir%
; =================================================================
; 脚本常量定义
; =================================================================
DOUBLE_CLICK_PERIOD := 400 ; 定义双击间隔时间(毫秒)
TOOLTIP_WIDTH := 210 ; 提示窗口宽度
TOOLTIP_HEIGHT := 30 ; 提示窗口高度
; =================================================================
; 脚本初始化设置
; =================================================================
Menu, Tray, Icon, %A_WinDir%\System32\imageres.dll, 243
SetTitleMatchMode, 2
OnExit, GuiExit
; =================================================================
; 创建带阴影效果的自定义GUI窗口
; =================================================================
Gui, PathTooltip: +AlwaysOnTop -Caption +ToolWindow +E0x20 +HwndPathTooltipHwnd
Gui, PathTooltip: Color, FFFFFF
Gui, PathTooltip: Font, s10 c000000, Microsoft YaHei
Gui, PathTooltip: Add, Text, Center vPathDisplayText w200 x5 y6, Initializing...
; --- DWM API 调用以实现窗口阴影 ---
if DllCall("dwmapi\DwmIsCompositionEnabled", "Int*", compositionEnabled) = 0 && compositionEnabled
{
attrValue := 2
DllCall("dwmapi\DwmSetWindowAttribute", "Ptr", PathTooltipHwnd, "Int", 2, "Int*", attrValue, "Int", 4)
VarSetCapacity(margins, 16, 0)
NumPut(1, &margins, 0, "Int"), NumPut(1, &margins, 4, "Int"), NumPut(1, &margins, 8, "Int"), NumPut(1, &margins, 12, "Int")
DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", PathTooltipHwnd, "Ptr", &margins)
}
; =================================================================
; 文件对话框分组
; =================================================================
GroupAdd, FileDialogs, 另存为 ahk_class #32770
GroupAdd, FileDialogs, 保存 ahk_class #32770
GroupAdd, FileDialogs, 打开 ahk_class #32770
GroupAdd, FileDialogs, 选择文件 ahk_class #32770
; =================================================================
; 定时器:当文件对话框激活时,显示DOpus路径提示
; =================================================================
SetTimer, ShowDopusPathInDialog, 250
return
ShowDopusPathInDialog:
; [修复] 判断窗口激活的同时,获取其唯一句柄(HWND)到变量 hwnd
if (hwnd := WinActive("ahk_group FileDialogs"))
{
dopusPath := GetActiveDopusPath()
display_text := (dopusPath != "") ? dopusPath : "未找到活动的 Directory Opus 路径"
GuiControl, PathTooltip:, PathDisplayText, % display_text
; [修复] 使用窗口句柄(ahk_id)来精确获取位置,避免竞态条件
WinGetPos, DlgX, DlgY, , , ahk_id %hwnd%
; 计算提示窗口的位置
NewX := DlgX + 25
NewY := DlgY + 10
; 确保提示窗口不会显示在屏幕之外
SysGet, screenWidth, 78
SysGet, screenHeight, 79
if (NewX + TOOLTIP_WIDTH > screenWidth)
NewX := screenWidth - TOOLTIP_WIDTH
if (NewY + TOOLTIP_HEIGHT > screenHeight)
NewY := screenHeight - TOOLTIP_HEIGHT
; 显示并定位提示窗口,使用 NoActivate 避免抢占焦点
Gui, PathTooltip: Show, x%NewX% y%NewY% w%TOOLTIP_WIDTH% h%TOOLTIP_HEIGHT% NoActivate
}
else
{
Gui, PathTooltip: Hide
}
return
; =================================================================
; 核心逻辑 - 双击Alt跳转路径
; =================================================================
#IfWinActive ahk_group FileDialogs
~LAlt::
{
if (A_PriorHotkey = "~LAlt" and A_TimeSincePriorHotkey < DOUBLE_CLICK_PERIOD)
{
dopusPath := GetActiveDopusPath()
if (dopusPath = "")
{
dopusPath := "C:\"
MsgBox, 48, 路径错误, 无法获取Directory Opus路径!`n将使用默认路径: %dopusPath%
}
NavigateFileDialog(dopusPath)
}
return
}
#IfWinActive
; =================================================================
; 函数与子程序
; =================================================================
GetActiveDopusPath()
{
if WinActive("ahk_exe dopus.exe")
{
WinGetTitle, activeTitle, A
path := ParseDopusTitle(activeTitle)
if (path != "")
return path
}
WinGet, id, List, ahk_exe dopus.exe
if (id = 0)
return ""
WinGetTitle, topTitle, ahk_id %id1%
return ParseDopusTitle(topTitle)
}
ParseDopusTitle(title)
{
if (SubStr(title, 1, 6) = "DOpus " and StrLen(title) > 8)
return SubStr(title, 9)
return ""
}
NavigateFileDialog(path)
{
ControlFocus, Edit1, A
Sleep, 50
ControlSetText, Edit1, %path%, A
Sleep, 100
ControlSend, Edit1, {Space}{Backspace}, A
Sleep, 150
Send, {Enter}
}
GuiExit:
Gui, PathTooltip: Destroy
ExitApp
当然,它还有扩展的空间。欢迎各位 AHK 高手提出宝贵的优化建议!







