Jump to content

How can I count chrome tabs/windows without "extensions" in python?

12345678

Like seleniums needs it's own webdriver, so it can't be used

 

I want to open let's say 5 tabs and 3 windows of chrome, and have an output of those in my console 

 

There's psutil/precess libs, but I am struggling to make those work, they actually seem to get subprocesses vs windows, which do not correspond due to the way that chrome works

 

https://pastebin.com/i4bWsS8p

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

i dont think you can, because however you slice it, you'd need to tie into chrome somehow to read the currently open tabs.

Link to comment
Share on other sites

Link to post
Share on other sites

You could effectively do "reference counting" on tabs and windows, basically your code would keep track of the tabs and windows as it opens and closes them. However, this is unreliable if a tab or window is opened/closed when your code doesn't expect it.

 

Beyond that, perhaps computer vision, but that adds a lot of complexity. Maybe one of the many chromium based browsers has more predictable process usage?

 

What is preventing you from using an extension?

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...
On 12/21/2023 at 11:22 PM, BobVonBob said:

You could effectively do "reference counting" on tabs and windows, basically your code would keep track of the tabs and windows as it opens and closes them. However, this is unreliable if a tab or window is opened/closed when your code doesn't expect it.

 

Beyond that, perhaps computer vision, but that adds a lot of complexity. Maybe one of the many chromium based browsers has more predictable process usage?

It doesn't seem so

On 12/21/2023 at 11:22 PM, BobVonBob said:

What is preventing you from using an extension?

What do you mean?

Link to comment
Share on other sites

Link to post
Share on other sites

17 hours ago, 12345678 said:

What do you mean?

Why can't you use Selenium (or other similar browser automation)?

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

13 hours ago, BobVonBob said:

Why can't you use Selenium (or other similar browser automation)?

It's not up to me, also I don't know if chrome or any other random browser would behave the same

 

In a nutshell there's this issue, where Chrome to time to time opens two tabs one up to another, we can't understand why, and so I thought that to get rid of the issue I may just close all windows whenever there are two or more tabs opened, but then I see no way, outside as you said visual procesing to effectively detect it

Link to comment
Share on other sites

Link to post
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

×