WinExist exact name - v2 Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
w64bit
Posts: 16
Joined: 08 Aug 2018, 08:30

WinExist exact name - v2

05 Mar 2021, 09:00

Hi,
Can someone please help me to "bring this code to order" in AH v2?
I want to find+activate only the window with this exact name in the title = Calc. Nothing more, nothing less.
Tried with this code but it opens every time another instance of Calc.

Code: Select all

#SingleInstance Force
Insert::
{
If WinExist("Calc",,," ")
    WinActivate "Calc",,," "
Else
    Run "D:\Calc.exe"
}
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: WinExist exact name - v2  Topic is solved

05 Mar 2021, 14:23

u need to change the default(2) title match mode to match exactly(3) by calling SetTitleMatchMode() or assigning to A_TitleMatchMode:

Code: Select all

#SingleInstance Force
Insert::
{
	SetTitleMatchMode(3)
	; A_TitleMatchMode := 3
If WinExist("Calc",,," ")
    WinActivate()
Else
    Run "D:\Calc.exe"
}
also, u dont need to specify wintitle parameters for follow-up functions

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Draken and 60 guests