Using notifications to activate a Chrome tab

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
meliksahd
Posts: 2
Joined: 22 Jan 2018, 23:35

Using notifications to activate a Chrome tab

22 Jan 2018, 23:49

Hey, I'm trying to code a script that needs to activate a Chrome Tab which has notifications in it. I mean if a tab in Chrome notifies me with sound and a red circled "1" in tab bar, that tab should be the active tab immediately.

I already tried to use that red circle to detect different pixel colors and click on that tab but this only works when I have 20 tabs (as I set my coordinates those correspond to red pixels for 20 tabs)

Is there a way to make this code responsive to the tab count? Or any other way to trigger tab activation?

Code: Select all

	Loop,
	{
		PixelGetColor, tab1, 39, 28, RGB
		Sleep, 25
		if tab1 = 0xF36654
		{
			Click, 39, 28
			...
			tab1 = 0
		}
		PixelGetColor, tab2, 122, 28, RGB
		Sleep, 25
		if tab2 = 0xF36654
		{
			Click, 122, 28
			...
			tab2 = 0
		}
		PixelGetColor, tab3, 205, 28, RGB
		Sleep, 25
		if tab3 = 0xF36654
		{
			Click, 205, 28
			...
			tab3 = 0
		}
		PixelGetColor, tab4, 288, 28, RGB
		Sleep, 25
		if tab4 = 0xF36654
		{
			Click, 288, 28
			...
			tab4 = 0
		}
		PixelGetColor, tab5, 371, 28, RGB
		Sleep, 25
		if tab5 = 0xF36654
		{
			Click, 371, 28
			...
			tab5 = 0
		}
		... //this goes on for 20tabs
	}
Thanks in advance!!
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Using notifications to activate a Chrome tab

23 Jan 2018, 09:57

I don't know about an easier way, but as for doing it the hard way, it should be possible to have the script constantly "count" how many tabs there are by looking for the empty spaces between tabs and counting those; then you could adjust the coordinates based on the number of tabs.
imgsearcher

Re: Using notifications to activate a Chrome tab

23 Jan 2018, 10:08

meliksahd wrote:Hey, I'm trying to code a script that needs to activate a Chrome Tab which has notifications in it. I mean if a tab in Chrome notifies me with sound and a red circled "1" in tab bar, that tab should be the active tab immediately.

I already tried to use that red circle to detect different pixel colors and click on that tab but this only works when I have 20 tabs (as I set my coordinates those correspond to red pixels for 20 tabs)

Is there a way to make this code responsive to the tab count? Or any other way to trigger tab activation?

Code: Select all

	Loop,
	{
		PixelGetColor, tab1, 39, 28, RGB
		Sleep, 25
		if tab1 = 0xF36654
		{
			Click, 39, 28
			...
			tab1 = 0
		}
		PixelGetColor, tab2, 122, 28, RGB
		Sleep, 25
		if tab2 = 0xF36654
		{
			Click, 122, 28
			...
			tab2 = 0
		}
		PixelGetColor, tab3, 205, 28, RGB
		Sleep, 25
		if tab3 = 0xF36654
		{
			Click, 205, 28
			...
			tab3 = 0
		}
		PixelGetColor, tab4, 288, 28, RGB
		Sleep, 25
		if tab4 = 0xF36654
		{
			Click, 288, 28
			...
			tab4 = 0
		}
		PixelGetColor, tab5, 371, 28, RGB
		Sleep, 25
		if tab5 = 0xF36654
		{
			Click, 371, 28
			...
			tab5 = 0
		}
		... //this goes on for 20tabs
	}
Thanks in advance!!
Use imagesearch
meliksahd
Posts: 2
Joined: 22 Jan 2018, 23:35

Re: Using notifications to activate a Chrome tab

23 Jan 2018, 11:53

Every millisecond is important for me. Wouldn't imagesearch make the process much slower? If there is no difference between imagesearch and pixelgetcolor, I can give it a try.

I was actually looking for a more integrated solution with chrome.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 319 guests