Trying to make Title only work on exact title instead of contain

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Trying to make Title only work on exact title instead of contain

09 Jun 2018, 22:21

Code: Select all

	PauseOnTarget() {
		for i, v in Array("State of Decay 2", "ApplicationFrameHost.exe", "program3.exe") {
			;~ if(WinActive("ahk_exe " . v)) {
			if(WinActive(v)) {	
				Suspend, On
				return
			}
		}
		Suspend, Off
	}
This is the code for the settimer loop.

I need to find a way to make it only work on exact title instead of it working on every title that contains one of these titles.

for example, make it only work on "State of Decay 2" instead of "State of Decay 2 - YouTube"
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Trying to make Title only work on exact title instead of contain

09 Jun 2018, 22:49

https://autohotkey.com/docs/commands/Se ... chMode.htm

SetTitleMatchMode, 3

One of the following digits or the word RegEx:

1: A window's title must start with the specified WinTitle to be a match.
2: A window's title can contain WinTitle anywhere inside it to be a match.
3: A window's title must exactly match WinTitle to be a match
Outsourcing Clicks & Presses Since 2004.
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: Trying to make Title only work on exact title instead of contain

10 Jun 2018, 09:57

brutus_skywalker wrote:https://autohotkey.com/docs/commands/Se ... chMode.htm

SetTitleMatchMode, 3

One of the following digits or the word RegEx:

1: A window's title must start with the specified WinTitle to be a match.
2: A window's title can contain WinTitle anywhere inside it to be a match.
3: A window's title must exactly match WinTitle to be a match

I know, but I was wondering if I set the match mode inside, will it affect my other match modes? But I think I have figured it out :D thanks
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Trying to make Title only work on exact title instead of contain

10 Jun 2018, 10:34

that depends:
"Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section"
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Trying to make Title only work on exact title instead of contain

10 Jun 2018, 11:50

You probably figured it out, but you can switch match modes for to subsequent commands, so as to set different rules across your script, any command works as such, except directives prefixed with #. *For anyone else asking this question...
Outsourcing Clicks & Presses Since 2004.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Rohwedder, slowwd and 220 guests