Autohotkey 和 Windows 10:如何获取当前资源管理器路径 [英] Autohotkey and Windows 10: How to get current explorer path
问题描述
我使用 autohotkey 版本:1.0.48.05(因为我坚持使用 activeaid).读取当前路径的脚本如下(一直工作到 Win 7).
I use autohotkey version: 1.0.48.05 (because I stick with activeaid). The script to read the current path is as follows (and worked until Win 7).
; Get full path from open Explorer window
WinGetText, FullPath, A
; Clean up result
StringReplace, FullPath, FullPath, `r, , all
FullPath := RegExReplace(FullPath, "^.*`nAddress: ([^`n]+)`n.*$", "$1")
我怎么怀疑在切换到 Win10 时,我似乎也切换了语言.如果我在使用 MsgBox 清理 %FullPath% 之前WinGetText,完整路径,AMsgBox %FullPath%我在其他字符串中看到(显然由 CR 分隔):地址:V:VertriebProspectsMyFile
How I suspect that while switching to Win10 it seems that I also switched the language. If I MsgBox out the %FullPath% before cleaning with WinGetText, FullPath, A MsgBox %FullPath% I see amongst other strings (obvoíously separated by CR): Adresse: V:VertriebProspectsMyFile
那么我需要如何调整正则表达式来提取那个字符串!
so how do I need to adjust the regexp to extract that very string!
最好的问候汉斯
推荐答案
#If WinActive("ahk_class CabinetWClass") ; explorer
F1:: MsgBox, % GetActiveExplorerPath()
; or
F2::
ActiveExplorerPath := GetActiveExplorerPath()
MsgBox, % ActiveExplorerPath
return
#If
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=69925
GetActiveExplorerPath() {
explorerHwnd := WinActive("ahk_class CabinetWClass")
if (explorerHwnd)
{
for window in ComObjCreate("Shell.Application").Windows
{
if (window.hwnd==explorerHwnd)
return window.Document.Folder.Self.Path
}
}
}
这篇关于Autohotkey 和 Windows 10:如何获取当前资源管理器路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!