How do I use GroupAdd for two seperate applications having same ahk_class name Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
drak
Posts: 3
Joined: 13 Aug 2018, 08:58

How do I use GroupAdd for two seperate applications having same ahk_class name

13 Aug 2018, 09:13

Hi !

I have been trying to add shortcuts to Photoshop & Illustrator.

Both of these applications have floating windows which are named ' ahk_class OWL.DocumentWindow ' in WindowSpy.

I am currently using the following code to make shortcuts work in both applications with AHK.

GroupAdd,ai,ahk_exe Illustrator.exe
GroupAdd,ai,ahk_class OWL.DocumentWindow

GroupAdd,ps,ahk_exe Photoshop.exe
GroupAdd,ps,ahk_class OWL.DocumentWindow

However, as both applications have the same ahk_class (OWL.DocumentWindow), the shortcuts don't work for the application that's mentioned second.
If one application is closed, the shortcuts work perfectly.

other things i have tried, but in vain:

GroupAdd,ai,ahk_exe Illustrator.exe
GroupAdd,ai,ahk_class OWL.DocumentWindow
return

GroupAdd,ps,ahk_exe Photoshop.exe
GroupAdd,ps,ahk_class OWL.DocumentWindow
return

Is there a way to let AHK know that these two classes are different & not the same?

(#IfWinActive ahk_group ps & #IfWinActive ahk_group ai are mentioned above each set of shortcuts.
Using AHK v1.1.22.07, win10 )


Please help. Thanks!
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How do I use GroupAdd for two seperate applications having same ahk_class name  Topic is solved

13 Aug 2018, 10:42

I would probably not use GroupAdd for this, and instead, at the appropriate places:

Code: Select all

;not: the OWL.DocumentWindow line would have to appear above the more generic line
#IfWinActive, ahk_class OWL.DocumentWindow ahk_exe Illustrator.exe

#IfWinActive, ahk_exe Illustrator.exe

#IfWinActive, ahk_class OWL.DocumentWindow ahk_exe Photoshop.exe

#IfWinActive, ahk_exe Photoshop.exe
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
drak
Posts: 3
Joined: 13 Aug 2018, 08:58

Re: How do I use GroupAdd for two seperate applications having same ahk_class name

13 Aug 2018, 22:50

jeeswg wrote:I would probably not use GroupAdd for this, and instead, at the appropriate places:

Code: Select all

;not: the OWL.DocumentWindow line would have to appear above the more generic line
#IfWinActive, ahk_class OWL.DocumentWindow ahk_exe Illustrator.exe

#IfWinActive, ahk_exe Illustrator.exe

#IfWinActive, ahk_class OWL.DocumentWindow ahk_exe Photoshop.exe

#IfWinActive, ahk_exe Photoshop.exe
Thank you for the suggestion jeeswg! Shall try it out & keep you posted.
drak
Posts: 3
Joined: 13 Aug 2018, 08:58

Re: How do I use GroupAdd for two seperate applications having same ahk_class name

15 Aug 2018, 23:34

jeeswg wrote:I would probably not use GroupAdd for this, and instead, at the appropriate places:

Code: Select all

;not: the OWL.DocumentWindow line would have to appear above the more generic line
#IfWinActive, ahk_class OWL.DocumentWindow ahk_exe Illustrator.exe

#IfWinActive, ahk_exe Illustrator.exe

#IfWinActive, ahk_class OWL.DocumentWindow ahk_exe Photoshop.exe

#IfWinActive, ahk_exe Photoshop.exe

This worked as expected..which is fantastic :) Thank you jeeswg!

If possible , could you kindly guide me to the documentation of this specific code explained in the AHK help docs? I'd like to learn more about AHK.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How do I use GroupAdd for two seperate applications having same ahk_class name

15 Aug 2018, 23:48

Here's the key point. Cheers.
#IfWinActive / #IfWinExist - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/_IfWinActive.htm
If more than one variant is eligible to fire, only the one closest to the top of the script will fire. The exception to this is the global variant (the one with no #IfWin criteria): It always has the lowest precedence; therefore, it will fire only if no other variant is eligible (this exception does not apply to hotstrings).

Code: Select all

#IfWinActive ahk_class Notepad ;checked 1st
q::MsgBox, % "Notepad"
#IfWinActive ahk_class WordPadClass ;checked 2nd
q::MsgBox, % "WordPad"
#IfWinActive ;checked 3rd
q::MsgBox, % "other"

#IfWinActive ;checked 3rd
w::MsgBox, % "other"
#IfWinActive ahk_class Notepad ;checked 1st
w::MsgBox, % "Notepad"
#IfWinActive ahk_class WordPadClass ;checked 2nd
w::MsgBox, % "WordPad"
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, gsxr1300, mikeyww and 296 guests