tags:

views:

667

answers:

5

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

A: 

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

setMousePos(x, y)    // tab position
click("left")
Coronatus
I want it to active a tab based on its name, not on its position.
Phenom
MouseClick("Left", x, y,) would be how you would left click somewhere in AutoIt v3.
Copas
+2  A: 

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).

Jeanne Pindar
It's Ctrl+Tab, isn't it?
grossvogel
You're right, it is.
Jeanne Pindar
I saw someone do it without having to alt-tab through all of the window titles using autoit, but I don't know how they did it because I didn't see the source.
Phenom
+2  A: 

Stilgar on the AutoIt forms has made a UDF (what the AutoIt community call an include file for some reason). To do just this sort of thing with AutoIt. They call it FF.au3

Looks like the function you want is _FFTabSetSelected() good luck!

Hopefully I will post an example of FF.au3 working later today below is an example of Jeanne Pindar's method. I had the same idea, if it were not production software (ie. something just for me) 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
Copas
I already tried that and it didn't work.
Phenom
@Phenom Thanks, I will look into it and get back to you.
Copas
A: 

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!

MemphiZ
A: 

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

atomizer