Hello,
I have an issue and I can't find anything to solve it.
I’m running several Chrome windows which all have the same ahk_class, ahk_exe, and ahk_pid.
The only way to distinguish them is the title, however, it's pretty much useless because the title is different in every window and unpredictable.
Is there a way to distinguish Chrome windows from each other?
Differentiate Chrome windows Topic is solved
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Differentiate Chrome windows
explain what you are trying to do, acc could be a solution for non active windows but I do not know what you need.
Re: Differentiate Chrome windows
My email is a separate Chrome window (Chrome -->more tools --> create shortcut --> open as window)
This window has the same ahk_class, ahk_exe, and ahk_pid with my Chrome browser and any other Chrome window I’ve created in the same way (YouTube, contacts, calendar etc).
For my Gmail, I’ve created an ahk file Gmail.ahk but it works only when I’m in the inbox because I’ve used the title of the window in #IfWinActive
I’ve made a group in this Gmail.ahk file grouping together all titles that do not change frequently.
But when you click to read a message then the window title is changing and includes the subject of the message. At this point, and every other similar, none of the AutoHotKey shortcuts works because the Gmail.ahk doesn’t recognise the window because its title has changed.
I hope I’ve explained it adequately.
Thanks!
This window has the same ahk_class, ahk_exe, and ahk_pid with my Chrome browser and any other Chrome window I’ve created in the same way (YouTube, contacts, calendar etc).
For my Gmail, I’ve created an ahk file Gmail.ahk but it works only when I’m in the inbox because I’ve used the title of the window in #IfWinActive
I’ve made a group in this Gmail.ahk file grouping together all titles that do not change frequently.
But when you click to read a message then the window title is changing and includes the subject of the message. At this point, and every other similar, none of the AutoHotKey shortcuts works because the Gmail.ahk doesn’t recognise the window because its title has changed.
I hope I’ve explained it adequately.
Thanks!
Re: Differentiate Chrome windows
@entropy - Wasn't aware that the ChromeOS "shortcut"-option is available for Windows transforming any URL into an app ![Thumbup :thumbup:](./images/smilies/icon_thumbup.gif)
I've "appified" my GMail/YouTube accounts/Tabs and checked them using AccViewer.ahk (as already mentioned above) AND/OR the below script... (press F11 while your "app" has the focus, the output is copied to the clipboard for further investigation) and would guess that you'll find whatever useful indicator that way to identify a "headless Chrome" window reliably (fingers crossed)
Would love to see your final script/result.
Once you've identified the 'path' you wanna use, check out how to trigger the app accordingly: viewtopic.php?p=460085#p460085
HTH
![Thumbup :thumbup:](./images/smilies/icon_thumbup.gif)
I've "appified" my GMail/YouTube accounts/Tabs and checked them using AccViewer.ahk (as already mentioned above) AND/OR the below script... (press F11 while your "app" has the focus, the output is copied to the clipboard for further investigation) and would guess that you'll find whatever useful indicator that way to identify a "headless Chrome" window reliably (fingers crossed)
![Wink ;)](./images/smilies/icon_e_wink.gif)
Code: Select all
#SingleInstance, Force
#Include Acc.ahk ; https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Libraries/Acc.ahk
F11::
WinGet, hWnd, ID, A
Clipboard := JEE_AccGetTextAll(hWnd, "`r`n")
SoundBeep
Return
; vOpt: space-separated list
; vOpt: n#: e.g. n20 ;limit retrieve name to first 20 characters
; vOpt: v#: e.g. v20 ;limit retrieve value to first 20 characters
JEE_AccGetTextAll(hWnd:=0, vSep:="`n", vIndent:="`t", vOpt:="") { ; https://autohotkey.com/boards/viewtopic.php?f=6&t=40615
vLimN := 20, vLimV := 20
Loop, Parse, vOpt, % " "
{ vTemp := A_LoopField
if (SubStr(vTemp, 1, 1) = "n")
vLimN := SubStr(vTemp, 2)
else if (SubStr(vTemp, 1, 1) = "v")
vLimV := SubStr(vTemp, 2)
}
oMem := {}, oPos := {}
;OBJID_WINDOW := 0x0
oMem[1, 1] := Acc_ObjectFromWindow(hWnd, 0x0)
oPos[1] := 1, vLevel := 1
VarSetCapacity(vOutput, 1000000*2)
Loop
{ if !vLevel
break
if !oMem[vLevel].HasKey(oPos[vLevel]) {
oMem.Delete(vLevel)
oPos.Delete(vLevel)
vLevelLast := vLevel, vLevel -= 1
oPos[vLevel]++
continue
}
oKey := oMem[vLevel, oPos[vLevel]]
vName := "", vValue := ""
if IsObject(oKey) {
vRoleText := Acc_GetRoleText(oKey.accRole(0))
try vName := oKey.accName(0)
try vValue := oKey.accValue(0)
}
else {
oParent := oMem[vLevel-1,oPos[vLevel-1]]
vChildId := IsObject(oKey) ? 0 : oPos[vLevel]
vRoleText := Acc_GetRoleText(oParent.accRole(vChildID))
try vName := oParent.accName(vChildID)
try vValue := oParent.accValue(vChildID)
}
if (StrLen(vName) > vLimN)
vName := SubStr(vName, 1, vLimN) "..."
if (StrLen(vValue) > vLimV)
vValue := SubStr(vValue, 1, vLimV) "..."
vName := RegExReplace(vName, "[`r`n]", " ")
vValue := RegExReplace(vValue, "[`r`n]", " ")
vAccPath := ""
if IsObject(oKey) {
Loop, % oPos.Length() - 1
vAccPath .= (A_Index=1?"":".") oPos[A_Index+1]
}
else {
Loop, % oPos.Length() - 2
vAccPath .= (A_Index=1?"":".") oPos[A_Index+1]
vAccPath .= " c" oPos[oPos.Length()]
}
vOutput .= vAccPath "`t" JEE_StrRept(vIndent, vLevel-1) vRoleText " [" vName "][" vValue "]" vSep
oChildren := Acc_Children(oKey)
if !oChildren.Length()
oPos[vLevel]++
else {
vLevelLast := vLevel, vLevel += 1
oMem[vLevel] := oChildren
oPos[vLevel] := 1
}
}
return SubStr(vOutput, 1, -StrLen(vSep))
}
JEE_StrRept(vText, vNum) {
if (vNum <= 0)
return
return StrReplace(Format("{:" vNum "}", ""), " ", vText)
; return StrReplace(Format("{:0" vNum "}", 0), 0, vText)
}
HTH
Re: Differentiate Chrome windows
Thanks for replying, however, I didn’t find anything in the report (f11).
Since you’ve "appified" your Gmail, would you want to try it at your end and let me know whether you’ve managed to distinguish the Chrome windows?
Since you’ve "appified" your Gmail, would you want to try it at your end and let me know whether you’ve managed to distinguish the Chrome windows?
Re: Differentiate Chrome windows
@entropy
Btw, have you tried
SetTitleMatchMode already?
IMHO, the detected 'paths' are containing enough data to distinguish them.
Would you mind posting that script? Thx.I’ve made a group in this Gmail.ahk file grouping together all titles that do not change frequently.
But when you click to read a message then the window title is changing and includes the subject of the message. At this point, and every other similar, none of the AutoHotKey shortcuts works because the Gmail.ahk doesn’t recognise the window because its title has changed.
Btw, have you tried
![Arrow :arrow:](./images/smilies/icon_arrow.gif)
IMHO, the detected 'paths' are containing enough data to distinguish them.
Code: Select all
2 Titelleiste [][YouTube - I would have kidnapped my son if I had known the truth, but on TV they tell us people don't die - YouTube]
4 Bereich [YouTube - I would have kidnapped my son if I had known the truth, but on TV they tell us people don't die - YouTube – JohnDoe][]
4.1.1.3 Text [YouTube - I would have kidnapped my son if I had known the truth, but on TV they tell us people don't die - YouTube][]
4.1.1.5.1.1.1.1.1 Registerkarte [YouTube - I would have kidnapped my son if I had known the truth, but on TV they tell us people don't die - YouTube][]
4.1.1.5.1.1.1.1.1.1 Text [I would have kidnapped my son if I had known the truth, but on TV they tell us people don't die - YouTube][]
4.1.1.5.1.2.1.2 bearbeitbarer Text [Adress- und Suchleiste][youtube.com/watch?v=YHQFi7BMZEo]
4.1.1.5.2.2 Dokument [I would have kidnapped my son if I had known the truth, but on TV they tell us people don't die - YouTube][https://www.youtube.com/watch?v=YHQFi7BMZEo]
-----
2 Titelleiste [][Gmail - Posteingang (315) - JohnDoe@gmail.com - Gmail]
4 Bereich [Gmail - Posteingang (315) - JohnDoe@gmail.com - Gmail – JohnDoe][]
4.1.1.3 Text [Gmail - Posteingang (315) - JohnDoe@gmail.com - Gmail][]
4.1.1.5.1.1.1.1.1 Registerkarte [Gmail - Posteingang (315) - JohnDoe@gmail.com - Gmail][]
4.1.1.5.1.1.1.1.1.1 Text [Posteingang (315) - JohnDoe@gmail.com - Gmail][]
4.1.1.5.1.2.1.2 bearbeitbarer Text [Adress- und Suchleiste][mail.google.com/mail/u/0/#inbox]
4.1.1.5.2.2 Dokument [Posteingang (315) - JohnDoe@gmail.com - Gmail][https://mail.google.com/mail/u/0/#inbox]
-----
2 Titelleiste [][Gmail - Soziale Netzwerke (1) - JohnDoe@gmail.com - Gmail]
4 Bereich [Gmail - Soziale Netzwerke (1) - JohnDoe@gmail.com - Gmail – JohnDoe][]
4.1.1.3 Text [Gmail - Soziale Netzwerke (1) - JohnDoe@gmail.com - Gmail][]
4.1.1.5.1.1.1.1.1 Registerkarte [Gmail - Soziale Netzwerke (1) - JohnDoe@gmail.com - Gmail][]
4.1.1.5.1.1.1.1.1.1 Text [Soziale Netzwerke (1) - JohnDoe@gmail.com - Gmail][]
4.1.1.5.1.2.1.2 bearbeitbarer Text [Adress- und Suchleiste][mail.google.com/mail/u/0/#category/social]
4.1.1.5.2.2 Dokument [Soziale Netzwerke (1) - JohnDoe@gmail.com - Gmail][https://mail.google.com/mail/u/0/#category/social]
Re: Differentiate Chrome windows
@BoBo Would you mind posting that script? Thx.
Code: Select all
#NoTrayIcon
GroupAdd, GoogleWorkspace, Gmail - Inbox - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (1) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (2) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (3) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (4) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (5) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (6) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (7) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (8) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (9) - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Inbox (10) - email@example.com - MyOrganisationName
;[b][i]All above are set to function for up to 10 unread emails in my inbox[/i][/b]
GroupAdd, GoogleWorkspace, Gmail - Sent Mail - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - All Mail - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Bin - email@example.com - MyOrganisationName
GroupAdd, GoogleWorkspace, Gmail - Search results - email@example.com - MyOrganisationName
#IfWinActive ahk_group GoogleWorkspace
!f::Send qfrom: ; search from
^2::Send qsubject:
!s::Send gt ; go to send folder
!a::Send ga ; go to All Mail
!1::Send i ; mark as important
!2::Send ua ; select all conversations
!x::
Send x
Sleep 50
Send v
return
Thank you for posting, however, I’m not very familiar with AutoHotKey code.
If you manage to solve it please let me know.
Regards
Last edited by BoBo on 04 May 2022, 03:25, edited 1 time in total.
Re: Differentiate Chrome windows
Looks like dealing with Acc.ahk isn't necessary to handle several Chrome-based "app"-instances...
The following code allowed to trigger a GMail/YouTube app session using the same hotkey (Alt+k), with a different "app related" output/event.
You're able to execute additional instances of such an app (Ctrl+Y/G), and toggle through them (Alt+Y/G).
GroupAdd-settings need to be adjusted/edited according to the apps "window title" language setting.
HTH ![Cool 8-)](./images/smilies/icon_cool.gif)
The following code allowed to trigger a GMail/YouTube app session using the same hotkey (Alt+k), with a different "app related" output/event.
You're able to execute additional instances of such an app (Ctrl+Y/G), and toggle through them (Alt+Y/G).
GroupAdd-settings need to be adjusted/edited according to the apps "window title" language setting.
Code: Select all
; #NoTrayIcon
GroupAdd, GMail, Gmail
GroupAdd, GMail, Gmail -
GroupAdd, GMail, - Gmail
GroupAdd, YouTube, YouTube
GroupAdd, YouTube, YouTube -
GroupAdd, YouTube, - YouTube
#IfWinActive ahk_group GMail ; https://support.google.com/mail/answer/6594?hl=en (Shortcuts for GMail)
^2::Send qsubject:
!a::Send ga ; go to All Mail
!f::Send qfrom: ; search from
!s::Send gt ; go to send folder
!1::Send i ; mark as important
!2::Send ua ; select all conversations
!k::MsgBox GMail
#If
#IfWinActive ahk_group YouTube ; https://support.google.com/youtube/answer/7631406?hl=en (Shortcuts for YouTube)
!k::MsgBox YouTube
#If
^G::GroupActivate, GMail ; activating/toggling GMail app sessions
!G::Run % """C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe"" ; executing Gmail app
. --profile-directory=Default
. --app-id=fmgjjmmmlfnkbppncabfkddbjimcfncm"
^Y::GroupActivate, YouTube ; activating/toggling YT app sessions
!Y::Run % """C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe"" ; executing YT app
. --profile-directory=Default
. --app-id=agimnkijcaahngcdmfeangaknmldooml"
![Cool 8-)](./images/smilies/icon_cool.gif)
Re: Differentiate Chrome windows
I don’t think you’ve understood my point.
Do you see this screenshot?
It's the title while I’m reading the notification for your message in Gmail.
The only way to assign AutoHotKey for Gmail is the title because everything else is the same for every Chrome window. (ahk_class Chrome_WidgetWin_1, ahk_exe chrome.exe, ahk_pid 31188)
The code ---> !s::Send gt ---> goes to send folder.
It won't work from this screen because the title of the screen “Gmail - Topic reply notification - "Differentiate Chrome windows” DOES NOT EXIST in the group.
I’ll have to press first the command “Go to inbox”, which in my case is 1 and then !s.
There is no way for you to understand it unless you make one for yourself.
Make an AutoHotKey for Gmail, assign only one command !s::Send gt and then you’ll understand that you can’t use it from any page with a random title.
Re: Differentiate Chrome windows
It won't work from this screen because the title of the screen “Gmail - Topic reply notification - "Differentiate Chrome windows” DOES NOT EXIST in the group.
GroupAdd
Each use of this command adds a new rule to a group. In other words, a group consists of a set of criteria rather than a fixed list of windows. [...] If a window matches one of the criteria in the group, it is considered a match.
Kinda Google Search, where fewer search items/rules = more hits/options. I've sent myself a mail with the above-mentioned subject line, creating exactly the same windows title you've posted. "Jumping" from that opened mail directly to the "Search Window" (using the Alt+s hotkey) has worked out fine. And from other selected areas within the app as well. And yes, all other hotkeys too.
My current GroupAdd setting is restricting the usage of the hotkeys to the app (even though there were multiple instances of them open) but prevents its usage if used in a Gmail session within the browser that was running in parallel. That gives me the idea that the browser window/Tab titles are missing the leading/trailing 'Gmail - ' string.
As said, everything is working fine (here)
![Eh :eh:](./images/smilies/icon_eh.gif)
Re: Differentiate Chrome windows
From this, I guessed that I could use just one word of the title.Each use of this command adds a new rule to a group. In other words, a group consists of a set of criteria rather than a fixed list of windows. [...] If a window matches one of the criteria in the group, it is considered a match.
And it worked!
Thank you very much.
I thought that I had to use the title as this was given.
I didn’t think that I could use just one keyword in the title.
The word Gmail has been added recently in the title – obviously by an update of Chrome – and it is present in whatever window in Chrome’s Gmail App (sent emails, inbox, All mail, search etc.
I run everything only with this as the title...
That was it...
Thank you very much. I wouldn’t think of it...
Re: Differentiate Chrome windows
@BoBo
It worked in Gmail because the word Gmail was the first word of the long title.
YouTube is great too because YouTube it's also the first word in the title.
It doesn’t work with Chrome...
Google Chrome is all the way to the end of the title and it's not being recognized as a member of the Group...
It worked in Gmail because the word Gmail was the first word of the long title.
YouTube is great too because YouTube it's also the first word in the title.
It doesn’t work with Chrome...
Google Chrome is all the way to the end of the title and it's not being recognized as a member of the Group...
Re: Differentiate Chrome windows Topic is solved
How about using SetTitleMatchMode, 2 : "2 = A window's title can contain WinTitle anywhere inside it to be a match." ?!
Re: Differentiate Chrome windows
GroupAdd
Although SetTitleMatchMode and DetectHiddenWindows do not directly affect the behavior of this command, they do affect the other group commands such as GroupActivate and GroupClose. They also affect the use of ahk_group in any other command's WinTitle.
![Thinking :think:](./images/smilies/icon_think.gif)
Re: Differentiate Chrome windows
@gregster
Can you please give me the line of the code?
Can you please give me the line of the code?
Re: Differentiate Chrome windows
See example #2: https://www.autohotkey.com/docs/commands/GroupAdd.htm#ExOutlook
Despite the line quoted by BoBo, a quick test with Notepad seemed to work fine. And example #2 also seems to support that usage.
Despite the line quoted by BoBo, a quick test with Notepad seemed to work fine. And example #2 also seems to support that usage.
Re: Differentiate Chrome windows
THANK YOU.....gregster wrote: ↑04 May 2022, 16:39See example #2: https://www.autohotkey.com/docs/commands/GroupAdd.htm#ExOutlook
Despite the line quoted by BoBo, a quick test with Notepad seemed to work fine. And example #2 also seems to support that usage.
IT WORKS....
THANK YOU...
I’m having both my hands on my keyboard. I hate the mouse
![Smile :-)](./images/smilies/icon_e_smile.gif)
If someone removes from my computer the AutoHotKey, I won't be able to operate my computer anymore...
Re: Differentiate Chrome windows
@entropy
GroupAdd, Chrome, - Google Chrome That should match if '<hyphen><space>Google<space>Chrome' will be part of the windows title. Correct me if I'm wrong.
The reason why I've done that with Gmail & YouTube as well. Similar to SetTitleMatchMode, 2
I get the idea that you expect that this should work for running instances in a standard "tabbed" browser session as well, not restricted to apps only?
It doesn’t work with Chrome...
Google Chrome is all the way to the end of the title and it's not being recognized as a member of the Group...
GroupAdd, Chrome, - Google Chrome That should match if '<hyphen><space>Google<space>Chrome' will be part of the windows title. Correct me if I'm wrong.
The reason why I've done that with Gmail & YouTube as well. Similar to SetTitleMatchMode, 2
I get the idea that you expect that this should work for running instances in a standard "tabbed" browser session as well, not restricted to apps only?
Re: Differentiate Chrome windows
The solution offered by @gregster is adequate to manipulate even the open tabs in chrome separately.The reason why I've done that with Gmail & YouTube as well. Similar to SetTitleMatchMode, 2
I get the idea that you expect that this should work for running instances in a standard "tabbed" browser session as well, not restricted to apps only?
This means that if a shortcut exists and functions in all Chrome’s tabs, you can still assign the same shortcut with a different command to a specific tab. For example, if you work with Wikipedia, every tab includes the word Wikipedia in its title, and you can assign different shortcuts that override the general shortcuts of the Chrome window.
The solution I’ve found to be adequate for recognizing any window uniquely, except the above, is the ahk_id and this should, to my opinion, be available in window spy.