AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

#IfWinActive test for multiple windows

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jjack
Guest





PostPosted: Fri Apr 18, 2008 12:53 am    Post subject: #IfWinActive test for multiple windows Reply with quote

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

PostPosted: Fri Apr 18, 2008 2:04 am    Post subject: Reply with quote

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
View user's profile Send private message
sinkfaze



Joined: 19 Mar 2008
Posts: 140

PostPosted: Fri Apr 18, 2008 5:54 am    Post subject: Reply with quote

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
View user's profile Send private message
jjack
Guest





PostPosted: Fri Apr 18, 2008 1:19 pm    Post subject: Reply with quote

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





PostPosted: Fri Apr 18, 2008 1:28 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group