Page 1 of 1

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

Posted: 09 Jun 2018, 22:21
by fenchai

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"

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

Posted: 09 Jun 2018, 22:49
by brutus_skywalker
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

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

Posted: 10 Jun 2018, 09:57
by fenchai
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

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

Posted: 10 Jun 2018, 10:34
by swagfag
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"

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

Posted: 10 Jun 2018, 11:50
by brutus_skywalker
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...