首页 > 解决方案 > 使用剪贴板进行搜索查询时在浏览器中失去焦点 [autohotkey]

问题描述

我正在使用一个简单的脚本来使用热键运行 google/wikipedia/etc 搜索,不幸的是,在搜索结果出现在新选项卡中后,我必须单击,因为选项卡不是焦点,尽管浏览器窗口是焦点。我试图添加一个 WinActivate 但它不起作用。在安装新的操作系统之前,此脚本曾经按预期工作。为什么这个脚本会让浏览器失去焦点?

这是脚本

^+g:: 
{
Send, ^c
sleep 200
Run, https://www.google.com/search?hl=en&q=%Clipboard% 
sleep 50
WinActivate, ahk_exe waterfox.exe
}
Return

标签: autohotkeywaterfox

解决方案


我不知道为什么,但看起来增加 Run 和 WinActivate 之间的延迟似乎可以解决它。

^+g:: 
{
Send, ^c
sleep 200
Run, https://www.google.com/search?hl=en&q=%Clipboard% 
sleep 500 ;Up from 50, you might be able to fine-tune this number based on your computer's speed
WinActivate, ahk_exe waterfox.exe
}

推荐阅读