【问题标题】:Close windows explorer window with Auto hotkey使用 Autohotkey 关闭 Windows 资源管理器窗口
【发布时间】:2017-01-28 19:58:42
【问题描述】:

我无法找到关闭在 Windows 资源管理器中打开的路径的方法。假设我想关闭打开的窗口“c:\program files”。代码应该看起来像

#::j

    close window "c:\program files"

return 

谢谢。

【问题讨论】:

  • 如果winclose 不起作用,难道没有winkill 命令吗?或者你可以在winclose中用参数杀死一个窗口,不记得了
  • 最后,您还可以尝试使用controlsend!F4 发送到指定窗口。但我猜你没有正确抓住窗户。请先尝试其他命令,例如 winminimize

标签: windows scripting autohotkey


【解决方案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

【讨论】:

  • 这段代码不工作。窗口没有关闭。
  • 对不起,我在上面编辑了一些对我有用的东西:WinClose, C:\Program Files(删除了引号)。此外,资源管理器窗口的一般类称为CabinetWClass,因此这将关闭任何打开的资源管理器窗口:WinClose, ahk_class CabinetWClass(如@ahkcoder 所述,您还可以检查给定的标题)。嗯,
【解决方案2】:

更新代码,这里是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

【讨论】:

  • 我也试过了,但是打开的窗口还是没有关闭。
  • 我在上面发布的代码是与 Windows 资源管理器交互的最佳方法。如果这根本不起作用,则说明您的操作系统有问题,或者您有病毒/恶意软件。无论哪种情况,您都可能需要执行系统擦除并尝试重新安装合法版本的 Windows。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-27
  • 1970-01-01
  • 2011-05-23
  • 1970-01-01
  • 1970-01-01
  • 2016-04-17
  • 2018-07-28
相关资源
最近更新 更多