Dirk_M Posted September 2, 2024 Posted September 2, 2024 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
Andreik Posted September 2, 2024 Posted September 2, 2024 Being such a generic name it might be another window with a similar name. Use WinGetTitle() with the returned handle and check if it's the expected window.
Dirk_M Posted September 2, 2024 Author Posted September 2, 2024 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.
Solution pixelsearch Posted September 2, 2024 Solution Posted September 2, 2024 (edited) 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... ... 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 : 2) If the "AutoIt Help (v3.3.16.1)" window is retrieved first... Then the AutoIt help file will be activated 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 September 13, 2024 by pixelsearch Precision : the AutoIt hidden window is always created, no matter the script is compiled or not. ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
Dirk_M Posted September 3, 2024 Author Posted September 3, 2024 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now