logical not in WinTitle parameter

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ufunk
Posts: 54
Joined: 17 Jan 2020, 13:45

logical not in WinTitle parameter

Post by ufunk » 31 Jan 2021, 17:17

Hi,

I looked at the WinTitle docs: https://www.autohotkey.com/docs/misc/WinTitle.htm#Matching
I am sorry if this question has been asked before, I just can't find something similar now.

I am not sure how to use the logical not (!) for the WinTitle parameter?
I would like to use a hotkey if wintitle is not "Dokument1 - Word" and if ahk_class is "OpusApp". Is that possible?
Something like that:

Code: Select all

#IfWinActive, !Dokument1 - Word ahk_class OpusApp
F5::
Send, {ENTER}
Return

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: logical not in WinTitle parameter

Post by mikeyww » 31 Jan 2021, 17:41

Code: Select all

#If !WinActive("Dokument1 - Word") && WinActive("ahk_class OpusApp")
F5::Send {Enter}
#If

WatsonEnterprises
Posts: 19
Joined: 25 May 2020, 23:04

Re: logical not in WinTitle parameter

Post by WatsonEnterprises » 01 Feb 2021, 16:05

In this case, you could use WinActive's ExcludeTitle parameter.

Code: Select all

;WinTitle = "ahk_class OpusApp",   ExcludeTitle = "Dokument1 - Word"
#If (WinActive("ahk_class OpusApp", , "Dokument1 - Word"))
	F5::msgbox hi
#If

You could also accomplish it using ahk_group, since GroupAdd supports ExcludeTitle.

Code: Select all

GroupAdd, groupForSomethingAboutWord, % "ahk_class OpusApp", , , % "Dokument1 - Word",

#IfWinActive, ahk_group groupForSomethingAboutWord
	F5::msgbox hi
#IfWinActive

ufunk
Posts: 54
Joined: 17 Jan 2020, 13:45

Re: logical not in WinTitle parameter

Post by ufunk » 04 Feb 2021, 06:09

Thank you very much for you help. This is awesome, appreciate that.
Especially, the idea with GroupAdd is great.

Post Reply

Return to “Ask for Help (v1)”