Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding windows handles

96 views
Skip to first unread message

Andre

unread,
Mar 14, 2017, 2:10:43 AM3/14/17
to
Dear All,

How to know active window handle titles in the tcl?

Cheers,

tbgr...@gmail.com

unread,
Mar 14, 2017, 6:31:34 AM3/14/17
to
Dear Andre,

May be the manual page is useful for you:
https://www.tcl.tk/man/tcl8.6/TkCmd/wm.htm

without knowing details I recommend to look at "wm title" and "wm stackorder"

Best,
Detlef

Andre

unread,
Mar 15, 2017, 10:58:42 PM3/15/17
to
Hi,

I still can't solve this problem. I want to make sure the apps has run it. I want to say by "hWnd" the name or title of the window.

if {![wm title "hWnd"]} {
puts "not found"
} else {
puts "found"
}

Thanks for advice

tbgr...@gmail.com

unread,
Mar 16, 2017, 3:52:27 AM3/16/17
to
Hi Andre,

I see we must start a little bit earlier:

hWnd is just a window handle variable taken as an example placeholder.

Here is a working example.
Just put one window above the other and move the mouse over the labels.

package require Tk

proc checkWhoIsTop {} {
if { [wm stackorder . isabove .t2] } {
puts "Ontop is: [wm title .]"
} else {
puts "Ontop is: [wm title .t2]"

}
}

toplevel .t2
pack [label .t2.l2 -text "enter me l2"]
pack [label .l1 -text "enter me l1"]

wm title . "main toplevel"
wm title .t2 "other toplevel"

bind .t2.l2 <Enter> { checkWhoIsTop }
bind .l1 <Enter> { checkWhoIsTop }

Hope this helps to start.

Best,
Detlef

Andre

unread,
Mar 16, 2017, 1:54:48 PM3/16/17
to
Hi,

Just lets you know that if write in the vbscript like this

'Example VBScript
If Oshell.AppActivate("MyProgramTitle") Then
Wscript.Echo "FOUND"
Elseif Wscript.Echo "NOT FOUND"

I dont need tk, I just need a simple script for puts found or not found.

#Please suggestions below TCL script
if {![wm title "MyProgramTitle"]} {
puts "Not Found"
} else {
puts "Found"
}

Thanks for advice.

Eric

unread,
Mar 17, 2017, 4:00:01 AM3/17/17
to
Hi,

> Hi,
>
> Just lets you know that if write in the vbscript like this
>
> 'Example VBScript
> If Oshell.AppActivate("MyProgramTitle") Then
> Wscript.Echo "FOUND"
> Elseif Wscript.Echo "NOT FOUND"
>
> I dont need tk, I just need a simple script for puts found or not found.

The twapi package will give you all you need:

http://twapi.sourceforge.net/v4.1/ui.html

Look at find_windows.

Eric
0 new messages