2016-08-31 72 views
0

我使用autohotkey版本:1.0.48.05(因爲我堅​​持使用activeaid)。 讀取當前路徑的腳本如下(並且一直運行到Win 7)。Autohotkey和Windows 10:如何獲取當前資源管理器路徑

; 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時,我似乎也切換了語言。 地址::V: 如果我和 WinGetText,FULLPATH,A MSGBOX%FULLPATH% 我看到除其他字符串(由CRobvoíously分隔)清潔前MSGBOX出%FULLPATH%\ VERTRIEB \前景\ MyFile的

所以我如何調整正則表達式來提取那個字符串!

問候 漢納斯

回答

0

嘗試:

f1::MsgBox % Explorer_GetSelection() 

Explorer_GetSelection(hwnd="") { 
    WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A") 
    WinGetClass class, ahk_id %hwnd% 
    if (process = "explorer.exe") 
     if (class ~= "(Cabinet|Explore)WClass") { 
      for window in ComObjCreate("Shell.Application").Windows 
       if (window.hwnd==hwnd) 
        path := window.Document.FocusedItem.path 

      SplitPath, path,,dir 
     } 
     return dir 
} 
2
#If WinActive("ahk_class CabinetWClass") ; explorer 

    F1:: 
     ; https://autohotkey.com/boards/viewtopic.php?p=28751&sid=8c658dfc0a082c915aeefff6b5a92a23#p28751 
     for window in ComObjCreate("Shell.Application").Windows 
     { 
      fullpath := "" 
      try fullpath := window.Document.Folder.Self.Path 
      IfWinActive, % "ahk_id " window.HWND 
       break 
     } 
     MsgBox % fullpath 
     window := "" 
    return 

#If 
+0

可這也沒有autohotkey_l做些什麼呢? – user668338

+0

您可以下載可移植版本的AHK_L以運行代碼或使用https://autohotkey.com/download/中的編譯器將腳本編譯爲.exe。 – user3419297

+0

有一個由Sean編寫的與舊版AutoHotkey 1.0配合使用的COM庫,您必須修改上面的代碼才能使用它,因爲它與使用最新版本的AutoHotkey獲得的內置COM支持的接口不同。此外,沒有AHK_L,它只是AutoHotkey 1.1,因爲Lexicos已經接任了AutoHotkey的主要開發人員。 – errorseven

相關問題