我需要在使用另一个窗口时保持一个浏览器窗口处于活动状态。
“保持置顶”并不是我之前所寻找的,因为当我切换页面时,它仍然处于非活动状态。
我试图阻止页面识别我正在离开窗口(识别前大约有 10 秒钟的窗口)。
我偶然发现了 AutoHotKey,但我不太懂如何使用它:
SetTimer, constantActivation, 10
return
constantActivation:
WinWaitNotActive, your_window
WinActivate, your_window
return
有什么建议或提示吗?现在,我将鼠标设置为只需悬停在页面上即可激活页面,但如果我必须每 9 秒悬停在窗口上一次,那么这实际上行不通。
答案1
未经测试,但您可以尝试一下...
; Keeping window active while a script is running.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent ; Keeps a script permanently running until the user closes it or ExitApp is encountered.
#SingleInstance, Force ; Determines whether a script is allowed to run again when it is already running.
DetectHiddenWindows, On ; Determines whether invisible windows are "seen" by the script.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode, 2 ; Sets the matching behavior of the WinTitle parameter in commands.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTimer, WinExist_YOUR-WINDOW, 100
WinExist_YOUR-WINDOW:
If WinExist("YOUR-WINDOW ahk_class AutoHotkey")
WinActivate, ahk_exe YOUR-WINDOW.EXE
Return