Jump to content

[(UN)SOLVED] Count how many tabs are open in firefox


Recommended Posts

What have you tried so far? Did you check the Firefox UDF?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 2 weeks later...

To be honest this isn't working. I thought it does because tabs have always been in a control and never in overflowing number. Anyone has an idea why this ain't working? Mozrepl is on. What should I try? Any suggestions?

Global Const $_FF_AU3VERSION = "0.6.0.1b-15"

Firefox 54.0.1 (32-bit)

mozRepl 1121-signed.1-signed by hyperstruct (https://github.com/bard/mozrepl/wiki)

Windows 7 ultimate SP1

Edited by Fr33b0w
Link to comment
Share on other sites

i basically want to limit number of open tabs in firefox so if there is more opened then (lets say) 5, I need to limit them down, as simple as it sounds and as complicated as it is when trying to code it :) . At this point I am getting "" as an answer no matter how many tabs exist in firefox...   $tabs=0

Link to comment
Share on other sites

On 8/29/2017 at 2:23 AM, Somerset said:

If you click on a tab, and locate in the menu "Close Other Tabs" and click.

it will give you a dialog box with the number of tabs.

It won't give me right click menu on tabs on win7. It did before on XP but I guess upgrade or something wont work like that.

 

 

On 8/28/2017 at 7:52 PM, Danp2 said:

Ok... there's nothing wrong with the UDF. You have to first establish the connection to FF. So the revised script would be --

#Include <FF.au3>

_FFConnect()

While _FFGetLength("tabs") > 5
    _FFTabClose('last', 'key')
WEnd

 

It did showed me first time or with first run of the script but now it won't show me how much tabs are open... 

 

My code:

#Include <FF.au3>

_FFConnect()
Sleep(2000)
If _FFIsConnected() Then
$tabs=_FFGetLength("tabs")
If $tabs > 4 Then
;_FFTabClose("first")
_FFTabClose("last")
Sleep(1000)
;_FFDisConnect()
EndIf
EndIf

Is there any kind of workaround with this or anyone knows why it won't count tabs? Help again much appreciated.

Edited by Fr33b0w
Link to comment
Share on other sites

You had a problem in your _FFTabClose line, but otherwise looks fine to me. Try running the following in Scite and post the complete results from the output window --

#Include <FF.au3>

_FFConnect()
Sleep(2000)

If _FFIsConnected() Then
    $tabs=_FFGetLength("tabs")
    ConsoleWrite("$tabs=" & $tabs & @CRLF)

    If $tabs > 4 Then
        _FFTabClose("last", 'key')
    EndIf
EndIf

 

Link to comment
Share on other sites

Thanks!

_FFConnect: OS:    WIN_7 WIN32_NT 7601 Service Pack 1
_FFConnect: AutoIt:    3.3.14.2
_FFConnect: FF.au3:    0.6.0.1b-15
_FFConnect: IP:    127.0.0.1
_FFConnect: Port:    4242
_FFConnect: Delay:     2ms
_FFConnect: Socket:     536
_FFConnect: Browser:    
__FFSendJavaScripts: Sending functions to FireFox .......... done
__FFSend: try{FFau3 != null?1:0}catch(e){'_FFCmd_Err';};
__FFRecv:
_FFIsConnected ==> Socket Error: 536
>Exit code: 0    Time: 3.747

 

Link to comment
Share on other sites

Are you sure that you have MozRepl installed and running? Your output should look like this --

_FFConnect: OS: WIN_10 WIN32_NT 15063 
_FFConnect: AutoIt: 3.3.14.2
_FFConnect: FF.au3: 0.6.0.2b-1
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     872
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
__FFSend: try{FFau3 != null?1:0}catch(e){'_FFCmd_Err';};
__FFRecv: 1
__FFSend: try{gBrowser.tabContainer.childNodes.length}catch(e){'_FFCmd_Err';};
__FFRecv: 16
$tabs=16
__FFSend: try{gBrowser.tabContainer.childNodes.length}catch(e){'_FFCmd_Err';};
__FFRecv: 16
__FFSend: try{gBrowser.removeTab(gBrowser.mTabs[gBrowser.tabContainer.childNodes.length-1]);gBrowser.tabContainer.childNodes.length}catch(e){'_FFCmd_Err';};
__FFRecv: 15
+>10:50:44 AutoIt3.exe ended.rc:0
+>10:50:44 AutoIt3Wrapper Finished.

Also, what version of Firefox are you using? If you are using FF 55 or greater, then MozRepl is no longer working and that would explain your issues.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...