Jump to content

Problem with WinExists and WinTitleMatchMode = 3


Recommended Posts

Hi,

I'm trying to build a simple script to shutdown my computer after doing a long copy files task using Total Commander.

My script...

Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("TrayIconDebug", 1)

While WinExists("Total Commander")
    Sleep(5000)
WEnd
 
$ret = MsgBox(1,"Warning","Windows will shutdown in 20 seconds",20)
If $ret = 1 Or $ret 0 -1 Then
   Shutdown(8 + 4) 
EndIf

Now my problem. When Total Commander is running the Windows title is "Total Commander 7.04a - NOT REGISTERED" (i'm running the trial version), after start the copy operation it opens a new windows with the title "Total Commander".

Running the above code the script pauses when i have only the main TC window open and without the "Total Commander" window.

From the help file with WinTitleMatchMode = 3:

Mode 3

Exact title match.

In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad"

Is this a bug on the title match or i'm doing something wrong.

Tanks for any help.

Link to comment
Share on other sites

  • Moderators

rpaz,

I have had problems like this with title matching. I found that one way to get round it is to use the unique Windows handles. Use WinList to get the open windows BEFORE you start the copy operation - that will give you the titles and handles of the exisiting windows at that point. Then check again AFTER you have started the copy operation and you can find the title and handle of the new dialog by comparing the 2 arrays. Now you have a handle for the dialog and can track its disappearance by looping until it is no more. Pseudo-code:

$Array1 = WinList("Total Commander")
; Start the copy operation
$Array2 = WinList("Total Commander")
; Compare arrays to find the new window handle
While 1
    $Array3 = WinList("Total Commander")
; Search the array for the handle with _ArraySearch
    If $Handle not found ExitLoop
WEnd

There are no doubt more elegant ways to do it - but the important thing is that it works.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi Melba,

Tanks for your suggestion. Seems to me that the match isn't correctly done.

I have found a workaround if i do the test including some text from the window like this

While WinExists("Total Commander", "&Background")

___

Rui Paz

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...