当我在 Chrome 中双击一个单词时,我想模拟一个“查找”操作。
我设法做到了这一点:
~LButton::
SetTitleMatchMode, 2
#IfWinActive, ahk_class Chrome
If (A_TimeSincePriorHotkey<400) and (A_TimeSincePriorHotkey<>-1)
{
SendInput ^c
Sleep, 10
SendInput ^f
Sleep, 10
SendInput ^v
}
Return
Run Code Online (Sandbox Code Playgroud)
但它甚至可以在非 Chrome 进程中运行(当双击一个单词时)
题:
如何仅在 chrome 中双击时才能运行此脚本?
#IfWinActive, ahk_exe Chrome.exe ;; start of IfWinActive condition, for me it didn't work with ahk_class so i changed it to ahk_exe
~LButton::
SetTitleMatchMode, 2
If (A_TimeSincePriorHotkey<400) and (A_TimeSincePriorHotkey<>-1)
{
SendInput ^c
Sleep, 10
SendInput ^f
Sleep, 10
SendInput ^v
}
Return
~RButton::
SendInput {Escape}
Return
#IfWinActive ;; end of condition IfWinActive
Run Code Online (Sandbox Code Playgroud)