如果使用 AHK 打开,关闭 Win10 'Start Menu'?

Close Win10 'Start Menu' if open using AHK?

我已经制作了一个 AHK 脚本来保持应用程序在 Windows 启动/登录后立即打开和集中。我发现虽然 WinActivate 在 Windows 中不起作用10 如果“开始”菜单已打开。显然 "WinClose, Start Menu" 最后一次工作是在 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
}

我不想通过完全禁用“开始”菜单来做任何激烈的事情。我只是想关闭它以提醒用户 "this PC is only to run this application"。如果随机用户走进来并说 "The Start Menu keeps closing???" 如果他们想中断应用程序,则他们必须通过系统托盘图标手动暂停脚本,它也会提醒这个事实。

TIA

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

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。