Jump to content

WinActivate() with "WinTitleMatchMode: 2" not Working when the "title" beginns with the first letters of the window title


Go to solution Solved by pixelsearch,

Recommended Posts

Example with "AutoIt Help"- Window

First case

Opt("WinTitleMatchMode",2)

$WinHandle = WinGetHandle("Auto")

WinExists($WinHandle)      ; Window is found

WinActivate($WinHandle)   ; Windows is NOT activated

Second case

Opt("WinTitleMatchMode",2)

$WinHandle = WinGetHandle("Help")

WinExists($WinHandle)      ; Window is found

WinActivate($WinHandle)   ; Windows is activated

Second case

Opt("WinTitleMatchMode",2)

$WinHandle = WinGetHandle("It He")

WinExists($WinHandle)      ; Window is found

WinActivate($WinHandle)   ; Windows is activated

 

Link to comment
Share on other sites

That's not the case; the first case with "Auto" works fine, when I change WinTitleMatchMode to 1 (default = Start of WinTitle)

The problem occurred with other parameters and I tried WinGetTitle() to be sure that the correct window ist selected.

The example was done to show the problem in a simple and easily reproducible way.

Link to comment
Share on other sites

  • Solution
On 9/2/2024 at 10:19 PM, Dirk_M said:

That's not the case; the first case with "Auto" works fine, when I change WinTitleMatchMode to 1 (default = Start of WinTitle)

But it will not always be like this.

@Dirk_M when you run an AutoIt script (compiled or not), there is an AutoIt hidden window that is immediately created and its title is "AutoIt v3" , then this hidden window is closed as soon as the script ends. It means that when you run your script (with the AutoIt help file already opened), you're facing 2 windows whose names start with "AutoIt", which are :

"AutoIt v3"
"AutoIt Help (v3.3.16.1)"

If we work on your script (the 1st case), two possibilities may happen now :

#include <Array.au3>

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

$sTitle = "AutoIt"

$WinHandle = WinGetHandle($sTitle)
ConsoleWrite("$WinHandle = " & $WinHandle & @crlf)

WinExists($WinHandle) ; Window is found... yes but which one, the hidden "AutoIt v3" or "AutoIt Help (v3.3.16.1)" ?
ConsoleWrite("WinExists($WinHandle) : "& WinExists($WinHandle) & @crlf)

_ArrayDisplay(WinList($sTitle))

WinActivate($WinHandle) ; Window "AutoIt Help (v3.3.16.1)" will show only if it was detected before "AutoIt v3"
ConsoleWrite("WinActivate($WinHandle) "& WinActivate($WinHandle) & @crlf)

MsgBox(0, "", "")

1) If the hidden "AutoIt v3" window is retrieved first...

ArrayDisplay1.png.6333d78bd9d29de6478c97a9d753879f.png

... then during the time _ArrayDisplay is active, I use a utility to change the status of the "AutoIt v3" window, from hidden to visible, just to show you what the final display looks like :

AutoItv3.png.141886de8fcc67e826591a11fe0094d3.png

2) If the "AutoIt Help (v3.3.16.1)" window is retrieved first...

ArrayDisplay2.png.7f91d1fd09cb72971a4c6d14e0d31525.png

Then the AutoIt help file will be activated

AutoItHelp(v3.3_16.1).png.773e3ce75c129ec93aad676426dbd7cb.png

Handles displayed in the Console confirm that they correspond to "AutoIt v3" or "AutoIt Help (v3.3.16.1)" , depending on the window which was retrieved first.

Edited by pixelsearch
Precision : the AutoIt hidden window is always created, no matter the script is compiled or not.
Link to comment
Share on other sites

9 hours ago, pixelsearch said:

Handles displayed in the Console confirm that they correspond to "AutoIt v3" or "AutoIt Help (v3.3.16.1)" , depending on the window which was retrieved first.

It's exactly as you describe.

The original problem was with another windows on another computer. There is also a hidden window in the background.

@pixelsearch Thank you very much for the help and the detailed description!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...