向浏览器发送按键事件的问题 window autohotkey

Issues sending key events to browser window autohotkey

我正在尝试打开一个网页并将其保存为一个完整的文件。这对于 autohotkey 来说应该是一个相对容易的任务。出于某种原因,我的脚本没有将关键事件发送到 window。这是脚本:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn All, StdOut  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Run, www.google.com
WinWaitActive firefox.exe
sleep, 4000
ControlSend, ahk_class MozillaWindowClass, ^s

解决这个问题的更好方法是什么?

这是我的解决方案:

Run, www.google.com
WinWaitActive ahk_exe firefox.exe
sleep, 4000
Send ^s

为了使其正常工作,主要更改了两个内容

  1. WinWaitActive 条件
  2. 中的 exe 名称前包含 ahk_exe
  3. 删除了 ControlSend 并将其替换为常规 Send,因为我们已经在等待 Window 被激活

希望这对您有所帮助,如有需要,请随时寻求更多说明或帮助