问题描述
我使用自动热键版本: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,FullPath,AMsgBox%FullPath%我看到其他字符串(以CR分隔):地址:V:\ Vertrieb \ Prospects \ MyFile
How I suspect that while switching to Win10 it seems that I also switched the language.If I MsgBox out the %FullPath% before cleaning withWinGetText, FullPath, AMsgBox %FullPath%I see amongst other strings (obvoíously separated by CR):Adresse: V:\Vertrieb\Prospects\MyFile
所以我该如何调整正则表达式以提取字符串呢?
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:如何获取当前资源管理器路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!