AutoHotKey - 打开网站时不需要给它焦点。

问题描述 投票:0回答:1

我刚刚创建了这个脚本,它几乎完美(满足我的需求)。我唯一希望能够改进它的是,当它运行Google.com时,它不会让我的Google Chrome成为焦点。如何才能做到这一点呢?

#PgDn::
Run https://www.google.com
Sleep 2000
SetControlDelay -1
ControlClick, x1570 y600, Google - Google Chrome,,,, NA
Return

基本上,当我按Windows键+Page Down时,它会运行google chrome(并给它焦点),然后等待两秒钟,并控制点击页面上的一个坐标(不移动我的鼠标)。我很想让这整个操作在没有谷歌获得焦点或我的鼠标移动的情况下完成。

autohotkey
1个回答
0
投票

可能要想等它获得焦点,然后立即将其恢复到任何有焦点的地方。如果这样做还不够好,我想你需要一些自定义的Chrome扩展来做到这一点。

要在Chrome盗取焦点后恢复焦点,你可以这样做。

SetControlDelay -1

#PgDn::
    ActiveWindow := WinActive("A") ;store the hwnd of current active window
    Run, https://www.google.com
    WinWaitActive, ahk_exe chrome.exe ;wait for chrome to get focus
    WinActivate, % "ahk_id " ActiveWindow ;restore focus
    ControlClick, x1570 y600, Google - Google Chrome, , , , NA
Return

也可以这样做: SetControlDelay -1 要在热键之外设置。不需要每次运行热键时都设置它,只需要在脚本的 自动执行部分 (你的剧本的顶部)。

© www.soinside.com 2019 - 2024. All rights reserved.