我希望 AutoIt 激活 Firefox 中的特定选项卡。这怎么能做到呢?

发布于 2024-09-03 15:03:19 字数 66 浏览 4 评论 0原文

我在 Firefox 中打开了几个选项卡。我希望 AutoIt 激活 Firefox 中的特定选项卡。这怎么能做到呢?

I have several tabs open in Firefox. I want AutoIt to activate a particular tab in Firefox. How can this be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

瘫痪情歌 2024-09-10 15:03:19

让整个浏览器窗口获得焦点,然后使用 send 命令重复发送 cntl-tab ,直到窗口的标题是您想要的选项卡的名称(末尾带有 - Mozilla Firefox)。

Give the whole browser window focus, then use the send command to repeatedly send it cntl-tab until the window's title is the name of the tab you want (with - Mozilla Firefox at the end).

我一直都在从未离去 2024-09-10 15:03:19

有一个名为 FF.au3 的 UDF(用户定义函数 - 包含文件) 。看起来您想要的函数是_FFTabSetSelected(),祝您好运!

下面是珍妮品达方法的一个例子。我就是这样做的。

#include <array.au3>

Opt("WinTitleMatchMode", 2)

activateTab("Gmail")
Func activateTab($targetWindowKeyphrase)
    WinActivate("- Mozilla Firefox")
    For $i = 0 To 100
        If StringInStr(WinGetTitle(WinActive("")),$targetWindowKeyphrase) Then
            MsgBox(0,"Found It", "The tab with the key phrase " & $targetWindowKeyphrase & " is now active.")
            Return
        EndIf
        Send("^{TAB}")
        Sleep(200)
    Next
EndFunc

There's a UDF (User Defined Functions -include file) called FF.au3. Looks like the function you want is _FFTabSetSelected(), good luck!

Below is an example of Jeanne Pindar's method. This is the way I would do it.

#include <array.au3>

Opt("WinTitleMatchMode", 2)

activateTab("Gmail")
Func activateTab($targetWindowKeyphrase)
    WinActivate("- Mozilla Firefox")
    For $i = 0 To 100
        If StringInStr(WinGetTitle(WinActive("")),$targetWindowKeyphrase) Then
            MsgBox(0,"Found It", "The tab with the key phrase " & $targetWindowKeyphrase & " is now active.")
            Return
        EndIf
        Send("^{TAB}")
        Sleep(200)
    Next
EndFunc
平安喜乐 2024-09-10 15:03:19

给你...

AutoItSetOption("WinTitleMatchMode", 2)

$searchString = "amazon"

WinActivate("Mozilla Firefox")
For $i = 0 To 100
    Send("^" & $i)
    Sleep(250)
    If Not(StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
        MsgBox(0, "Done", "Found it!")
        ExitLoop
    EndIf
Next

只需删除 MsgBox 就可以了!

Here you go...

AutoItSetOption("WinTitleMatchMode", 2)

$searchString = "amazon"

WinActivate("Mozilla Firefox")
For $i = 0 To 100
    Send("^" & $i)
    Sleep(250)
    If Not(StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
        MsgBox(0, "Done", "Found it!")
        ExitLoop
    EndIf
Next

Just delete the MsgBox and you're all set!

メ斷腸人バ 2024-09-10 15:03:19

正如Copas所说,使用FF.au3。函数 _FFTabSetSelected($regex,"label") 将选择名称与给定 $regex 匹配的第一个选项卡。

As Copas said, use FF.au3. Function _FFTabSetSelected($regex,"label") will select first tab with name matching given $regex.

み零 2024-09-10 15:03:19

Nop...脚本有 bug ^^'...不需要数到 100,并且后面的“发送”有问题:

如果发送 ctrl + number
=>数字不能大于9...因为10是一个有2个字符的数字,Firefox无法使用快捷方式激活选项卡10。

顺便说一下,当脚本运行时,有一刻他松开了 ctrl 键。它不会发送 10,但 ctrl 和 1 会结束零......然后溅起!它只是发送窗口中的号码。
所以我们需要让脚本知道,当他第二次回到 $i = 0 或 1 时,所有选项卡都被看到,无需继续,即使您正在搜索的文本没有找到。
所以我根据旧脚本制作了自己的脚本:

##
AutoItSetOption("WinTitleMatchMode", 2)

$searchString = "The string you're looking for"
Local $o = 0
WinActivate("The Name of the process where you're searching")
For $i = 0 To 9
   Send("^" & $i)
   Sleep(250)
      if ($i = 9) Then
         $o += 1
      EndIf
      If not (StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
            MsgBox("","","Found it !") ;your action,  the text was found.
            ExitLoop
      ElseIf ($o = 1) Then
            MsgBox("","","All tab seen, not found...") ;your action, the text was not found, even after looking all title.
            ExitLoop
      EndIf
   Next
##

Nop... The script is buggy ^^'... no need to count to 100, and there is a problem with the "send" after it:

If you send ctrl + number
=>the number can't be bigger than 9... Because ten is a number with 2 caracters, Firefox can't activate tab 10 with shortcut.

And by the way when the script is working there is a moment he release the ctrl key.. It don't send ten, but ctrl and 1 end zero ... and splash !!! It just send the number in the window.
So we need to learn to the script that the second time he's back to $i = 0 or one, all the tabs was seen, no need to continue, even if the text you're searching for was not found.
So I made my own script based on the old one:

##
AutoItSetOption("WinTitleMatchMode", 2)

$searchString = "The string you're looking for"
Local $o = 0
WinActivate("The Name of the process where you're searching")
For $i = 0 To 9
   Send("^" & $i)
   Sleep(250)
      if ($i = 9) Then
         $o += 1
      EndIf
      If not (StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
            MsgBox("","","Found it !") ;your action,  the text was found.
            ExitLoop
      ElseIf ($o = 1) Then
            MsgBox("","","All tab seen, not found...") ;your action, the text was not found, even after looking all title.
            ExitLoop
      EndIf
   Next
##
鸠魁 2024-09-10 15:03:19

我已经很多年没有碰过 AutoIt 了,但 IIRC 将会是:

setMousePos(x, y)    // tab position
click("left")

I haven't touched AutoIt in years, but IIRC it will be:

setMousePos(x, y)    // tab position
click("left")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文