【问题标题】:Close Win10 'Start Menu' if open using AHK?如果使用 AHK 打开,请关闭 Win10 的“开始菜单”?
【发布时间】:2020-05-21 04:13:09
【问题描述】:

我制作了一个 AHK 脚本,以在 Windows 启动/登录后立即保持应用程序打开并集中注意力。我后来发现,如果“开始”菜单打开,WinActivate 在 Windows 10 中不起作用。显然,“WinClose,开始菜单”最后一次工作是在 WinXP 中。

这是我的代码更改为使用记事本,因此您可以轻松查看我正在尝试做什么(WinClose 开始菜单步骤):

#WinActivateForce
FocusTimer = 3000                               ;Time spent between refocusing on window (in milliseconds)
APP_TITLE = Untitled - Notepad                  ;Title of application window
APP_EXE = C:\Windows\System32\notepad.exe       ;Application executable filepath

Sleep, %FocusTimer%                             ;Allows time for Windows to login and run other startup processes
While(TRUE)                                     ;Infinite loop for program commands
{
    Run, %APP_EXE%                              ;Opens application
    Sleep, %FocusTimer%                         ;Allows time for previous action
    While WinExist(APP_TITLE)                   ;Infinite loop for while application window is available
    {
        WinClose, Start Menu                    ;Closes Start Menu if open so as not to interrupt WinActivate command 
        WinActivate, %APP_TITLE%                ;Commands focus on the application window
        WinWaitActive, %APP_TITLE%, , 0         ;Waits for application window to have focus
        Sleep, %FocusTimer%                     ;Wait timer before starting the loop again
    }
    Sleep, %FocusTimer%                         ;Allows clean-up time before starting the program commands again
}

我不想通过完全禁用“开始”菜单来做任何激烈的事情。我只是想关闭它来提醒用户“这台电脑只是为了运行这个应用程序”。如果随机进入并说“开始菜单一直关闭???”,它也会提醒这一事实。如果他们想中断应用程序,则必须通过系统托盘图标手动暂停脚本。

TIA

【问题讨论】:

  • Send, {Esc} 关闭开始菜单。

标签: windows windows-10 autohotkey


【解决方案1】:

开始菜单的标题不再是“开始菜单”。这似乎对我有用:

WinClose ahk_class Windows.UI.Core.CoreWindow ahk_exe SearchUI.exe
WinClose ahk_class Windows.UI.Core.CoreWindow ahk_exe StartMenuExperienceHost.exe ; Suggested by 0x464e

它也会关闭搜索和 Cortana。

【讨论】:

  • 如果开始菜单的特定部分处于活动状态,也可以是StartMenuExperienceHost.exe,以上不会关闭它。需要检测它是哪一个。
  • @D. Pardal,@0x464e,你试过上面的代码吗?在我的系统上,开始菜单仅以 Process Close, StartMenuExperienceHost.exe 关闭。
  • 我测试了所有这些,但只有WinClose ahk_class Windows.UI.Core.CoreWindow ahk_exe SearchUI.exe 似乎有效。尽管作为故障保险,我已将所有这些都包含在我的代码中。谢谢!
  • @S.Hampton 您不必只选择一个。您可以使用两条线,这样如果第一条不起作用,第二条可能会起作用。
猜你喜欢
  • 2015-08-14
  • 1970-01-01
  • 2015-09-09
  • 1970-01-01
  • 2018-07-06
  • 1970-01-01
  • 2020-02-11
  • 2019-11-30
  • 1970-01-01
相关资源
最近更新 更多