2016-09-20 119 views
0

我無法找到關閉在Windows資源管理器中打開路徑的方法。可以說我想關閉打開的窗口,「c:\ program files」。代碼應該看起來像關閉與自動熱鍵的Windows資源管理器窗口

#::j 

    close window "c:\program files" 

return 

謝謝。

+0

如果'winclose'不工作,wasnt有一個'winkill'命令?或者你可以用winclose中的一個參數殺死一個窗口,最後不記得 – Blauhirn

+0

,你也可以嘗試使用'controlsend'發送'!F4'到指定的窗口。但我想你沒有適當地抓住窗戶。先嚐試其他命令,比如'winminimize'。 – Blauhirn

回答

1

你會想看看這裏:

https://autohotkey.com/docs/commands/WinClose.htm

指定:

WinClose [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]

然後:

#j:: ; Win Key + j 
    WinClose, C:\Program Files ; close Program Files window 
return 

另外,關閉所有瀏覽器窗口,使用:

#j:: ; Win Key + j 
    WinClose, ahk_class CabinetWClass ; closes any explorer window 
return 

H個

+0

這段代碼被禁止了。窗戶不關閉。 – IGRACH

+0

對不起,我上面編輯的東西適合我:'WinClose,C:\ Program Files文件'(刪除引號)。此外,瀏覽器窗口的一般類稱爲'CabinetWClass',因此這將關閉任何打開的資源管理器窗口:'WinClose,ahk_class CabinetWClass'(正如@ahkcoder所提到的,您也可以檢查給定的標題)。 Hth, – PGilm

0

更新的代碼,這裏是一個video stepping through the code

path := "C:\Program Files" 

shell := ComObjCreate("Shell.Application") 
shell.open("file:///c:/") 
shell.open("file:///" . path) 


#If WinExist("ahk_class CabinetWClass") ; explorer 

    F1:: 
    for window in ComObjCreate("Shell.Application").Windows 
     if (path == window.Document.Folder.Self.Path) 
      window.quit() 
    return 

#If 
+0

我也試過這個,但是打開的窗口仍然沒有關閉。 – IGRACH

+0

我上面發佈的代碼是與Windows資源管理器連接的最佳方法。如果這根本不起作用,那麼操作系統出現問題,或者您有病毒/惡意軟件。無論哪種情況,您都可能想要進行系統擦除並嘗試重新安裝合法版本的Windows。 – errorseven

+0

更新我的例子,希望它適合你。 – errorseven

相關問題