How do I WinActivate with multiple criteria? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nutnutwin
Posts: 76
Joined: 28 Aug 2019, 07:25

How do I WinActivate with multiple criteria?

27 Jul 2021, 23:45

Hi, Thank you for your time.

# Situation
I have two windows
- First with Title "AutoHotkey Community - Post a new topic — Mozilla Firefox"
Normal Firefox Window
- Second with Title "Mozilla Firefox (Private Browsing)"
Private Browsing

# My Question
How do I differentiate these two window when calling WinActivate?

- I refer to
https://www.autohotkey.com/docs/misc/WinTitle.htm
and see I can use Regex for this situation?

- wonder if you can give me an example in this case, as I am not very familiar with Regex(sorry...)

- If possible, can I use two criteria for WinActivate?

- for WinActive(Multiple Criteria) I can make an easy workaround

Code: Select all

	WinActive_Multi(User_String*){
		for index,param in User_String{
			If !WinActive(param)
				PopUp(param " Not Active") ; home-made funcs
			Else
				PopUp(param " Active")
		}
		Return Local_Result

	}
# Others...
cannot differentiate chrome/chrome incognito...by title
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: How do I WinActivate with multiple criteria?

28 Jul 2021, 00:13

Code: Select all

SetTitleMatchMode, 2
1::WinActivate, AutoHotkey Community ahk_exe firefox.exe
2::WinActivate, Mozilla Firefox (Private ahk_exe firefox.exe
3::WinActivate, AutoHotkey Community ahk_exe chrome.exe
4::WinActivate, New Tab - Google Chrome ahk_exe chrome.exe
nutnutwin
Posts: 76
Joined: 28 Aug 2019, 07:25

Re: How do I WinActivate with multiple criteria?

28 Jul 2021, 01:02

mikeyww wrote:
28 Jul 2021, 00:13

Code: Select all

SetTitleMatchMode, 2
1::WinActivate, AutoHotkey Community ahk_exe firefox.exe
2::WinActivate, Mozilla Firefox (Private ahk_exe firefox.exe
3::WinActivate, AutoHotkey Community ahk_exe chrome.exe
4::WinActivate, New Tab - Google Chrome ahk_exe chrome.exe
Hi, thank you for your reply.
Sorry I didn't phrase properly

I need to differentiate
- Mozilla Firefox
✦This is the window I am trying to WinActivate
- Mozilla Firefox (Private Browsing)
✦while this window, I would love to ignore(do not WinActivate)

which means, what I am trying to do is WinActivate a window which
- contains "Mozilla Firefox"
- DO NOT contain "Private Browsing"

and that's the reason why I am asking about "multiple criteria".
sorry to be very confusing

--- ✄ -----------------------
I also considered going through all the window/Processes,
but need to write some overly complicated and less elegant codes...
and apparently would be quite slow
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: How do I WinActivate with multiple criteria?  Topic is solved

28 Jul 2021, 06:07

Code: Select all

SetTitleMatchMode, 2
1::WinActivate, (Private Browsing) ahk_exe firefox.exe   ; Private window
2::WinActivate, ahk_exe firefox.exe,, (Private Browsing) ; Non-private window
nutnutwin
Posts: 76
Joined: 28 Aug 2019, 07:25

Re: How do I WinActivate with multiple criteria?

28 Jul 2021, 07:24

mikeyww wrote:
28 Jul 2021, 06:07

Code: Select all

SetTitleMatchMode, 2
1::WinActivate, (Private Browsing) ahk_exe firefox.exe   ; Private window
2::WinActivate, ahk_exe firefox.exe,, (Private Browsing) ; Non-private window
Thank you!!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, mebelantikjaya and 318 guests