Autohotkey 如何设置自动热键';s代码只在chrome中运行?
我想在Chrome中双击一个单词时模拟“查找”操作 我设法做到了这一点:Autohotkey 如何设置自动热键';s代码只在chrome中运行?,autohotkey,Autohotkey,我想在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 } Retur
~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
~LButton::
SetTitleMatchMode,2
#IfWinActive,ahk_级铬
如果(A_timesinceprior热键您可以使用WinGet获取窗口或活动窗口的标题,然后仅在给定窗口处于活动状态时应用代码
SetTitleMatchMode,2
IfWinActive,-Google Chrome
这是我发现的一个片段:
DetectHiddenText, On ; the url of the active Chrome window is hidden text...
SetTitleMatchMode, Slow ; ...we also need match mode 'slow' to detect it
; activate chrome window,
; just for demonstation:
WinActivate, ahk_class Chrome_WidgetWin_1
IfWinActive, ahk_class Chrome_WidgetWin_1 ; we only want to check for the hidden text if Chrome is the active window,
{
WinGetText, wintext, ahk_class Chrome_WidgetWin_1 ; if it is we grab the text from the window...
If InStr(wintext,"autohotkey.com") ; ...and if it contains a url that we want,
{
;### code conditional on url goes here ###
msgbox % "The active Chrome window is on the autohotkey.com domain! The page title and URL is:`n`n>" wintext ; <<== we run the desired code here.
}
}
exitapp
DetectHiddenText,打开;活动Chrome窗口的url为隐藏文本。。。
SetTitleMatchMode,Slow;…我们还需要匹配模式“Slow”来检测它
;激活chrome窗口,
;仅供演示:
WinActivate,ahk_类Chrome_WidgetWin_1
IfWinActive,ahk_class Chrome_WidgetWin_1;如果Chrome是活动窗口,我们只想检查隐藏文本,
{
WinGetText,wintext,ahk_类Chrome_WidgetWin_1;如果是,我们从窗口抓取文本。。。
如果InStr(wintext,“autohotkey.com”);…并且如果它包含我们想要的url,
{
#####以url为条件的代码放在这里###
msgbox%“活动的Chrome窗口位于autohotkey.com域上!页面标题和URL为:`n`n>“wintext;”IfWinActive,ahk#u exe Chrome.exe;;IfWinActive条件的开始,对我来说,它不适用于ahk#u类,因此我将其更改为ahk#u exe
~LButton::
SetTitleMatchMode,2
如果(A_TimesSincePriorHotkey我试过了,但它对我双击的每个程序都有反应。谢谢。有效。可以在同一个脚本中添加一个右击触发器吗?我的意思是它看起来怎么样?我不太明白你的意思。如果你双击和/或按下右击,你想添加这样的触发器吗?或者你想这样做,当你进行ri时右键单击热键打开或关闭?我想在同一个脚本中添加一个代码,这样,如果我右键单击,它将调用sendInput“escape”。但我不知道如何“添加”另一个条件。这里有一个名为lbutton的转到标签。如何添加另一个用于右键单击的标签?据我所知,就是这样。这是常规热键,不包括标签。如果条件使用标签,则有热键,但它们略有不同。哦,我想~RButton::
是转到标签。谢谢你。
#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