| View previous topic :: View next topic |
| Author |
Message |
jjack Guest
|
Posted: Fri Apr 18, 2008 12:53 am Post subject: #IfWinActive test for multiple windows |
|
|
Is there a way to use a logical OR for #IfWinActive?
For example, something like
#IfWinActive (Foo) OR #ifWinActive (Bar)
;do stuff
#IfWinActive
Haven't been able to come up with the correct syntax. thanks. |
|
| Back to top |
|
 |
pockinator
Joined: 06 Dec 2007 Posts: 33
|
Posted: Fri Apr 18, 2008 2:04 am Post subject: |
|
|
Since you are using the #IfWinActive directive, I'll assume you are using it for hotkeys or hotstrings. In that case, you can either do this:
| Code: | #IfWinActive (Foo) ;I wasn't sure if the ()'s were a part of the window title
^+t::
#IfWinActive (Bar)
^+t::
MsgBox, You pressed the hotkey combination in either (Foo) or (Bar).
Return |
or this:
| Code: | GroupAdd, WinGroup, (Foo)
GroupAdd, WinGroup, (Bar)
#IfWinActive ahk_group WinGroup
^+t::MsgBox, You pressed the hotkey combination in either (Foo) or (Bar). |
Was that what you were looking for? |
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 140
|
Posted: Fri Apr 18, 2008 5:54 am Post subject: |
|
|
| You can either rename each individual window using WinSetTitle or create a variable for each window then add them each to a group via GroupAdd. I prefer using the variable/group method because renaming the window titles isn't as reliable for various reasons. |
|
| Back to top |
|
 |
jjack Guest
|
Posted: Fri Apr 18, 2008 1:19 pm Post subject: |
|
|
This works:
| Code: |
SetTitleMatchMode 2
GroupAdd, WinTest, Notepad
GroupAdd, WinTest, Firefox
#IfWinActive ahk_group WinTest
::t::test
#IfWinActive
|
Is there a way to use the window class instead of the title in this example?
I tried:
| Code: |
GroupAdd, WinTest, Notepad
GroupAdd, WinTest, MozillaUIWindowClass
#IfWinActive ahk_class WinTest
::t::test
#IfWinActive
|
But that doesn't seem to work. Thanks. |
|
| Back to top |
|
 |
jjack Guest
|
Posted: Fri Apr 18, 2008 1:28 pm Post subject: |
|
|
To answer my own question:
| Code: |
GroupAdd, WinTest, ahk_class Notepad
GroupAdd, WinTest, ahk_class MozillaUIWindowClass
#IfWinActive ahk_group WinTest
::t::test
#IfWinActive
|
|
|
| Back to top |
|
 |
|