【问题标题】:Trigger Brave "Search Tabs" feature from Autohotkey从 Autohotkey 触发勇敢的“搜索标签”功能
【发布时间】:2021-11-27 16:54:49
【问题描述】:

我希望能够从 Autohotkey 触发“搜索选项卡”,因为我有很多打开的选项卡,这将帮助我快速找到我正在寻找的选项卡,我知道我可以通过以下方式遍历所有选项卡编写脚本,但这不是我想要的。

这就是我所做的

!+a::
  WinActivate, Brave
  Sleep, 100
  Send, {Ctrl}{Shift}a
Return

如果我将Send, {Ctrl}{Shift}a 更改为Send, {Ctrl}t 会正确打开一个选项卡,那么问题肯定是我的{Ctrl}{Shift}a 配置中的一些错误,或者Brave 以某种方式没有反应。

【问题讨论】:

  • 试试 Send, ^+aSend, {Ctrl down}{Shift down}a{Shift up}{Ctrl up}
  • 如果 Brave 与您必须添加的窗口标题不完全匹配 SetTitleMatchMode 2
  • 请写下您的第一条评论作为答案,它解决了我的问题!第二个是我已经拥有的配置。谢谢。

标签: google-chrome autohotkey brave


【解决方案1】:

激活特定窗口并向其发送击键的最合适方法如下:

!+a::
    SetTitleMatchMode, 2 ; if you want to use it only in this hotkey
    IfWinNotExist, Brave
    {
        MsgBox, Cannot find Brave
            Return ; end of the hotkey's code
    }
    ; otherwise:
    WinActivate, Brave
    WinWaitActive, Brave, ,2  ; wait 2 seconds maximally  until the specified window is active
    If (ErrorLevel)  ;  if the command timed out
    {
        MsgBox, Cannot activate Brave
            Return
    }
    ; otherwise:
    ; Sleep 300 ; needed in some programs that may not react immediately after activated
    Send, ^+a
Return

否则脚本可以将击键发送到另一个窗口。

为了不在每个热键中重复整个代码,您可以创建一个函数:

!+b::
    SetTitleMatchMode, 2
    Activate("Brave", 2)
    ; Sleep 300
    Send, ^+a
Return

Activate(title, seconds_to_wait){
    IfWinNotExist, % title
    {
        MsgBox % "Cannot find """ . title . """."
            Return
    }
    ; otherwise:
    WinActivate, % title
    WinWaitActive, % title, ,% seconds_to_wait
    If (ErrorLevel) 
    {
        MsgBox % "Cannot activate """ . title . """."
            Return
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-29
    • 2010-11-16
    • 2022-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-06
    相关资源
    最近更新 更多