【发布时间】: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