Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Finding windows handles

瀏覽次數:96 次
跳到第一則未讀訊息

Andre

未讀,
2017年3月14日 凌晨2:10:432017/3/14
收件者:
Dear All,

How to know active window handle titles in the tcl?

Cheers,

tbgr...@gmail.com

未讀,
2017年3月14日 清晨6:31:342017/3/14
收件者:
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

未讀,
2017年3月15日 晚上10:58:422017/3/15
收件者:
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

未讀,
2017年3月16日 凌晨3:52:272017/3/16
收件者:
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

未讀,
2017年3月16日 下午1:54:482017/3/16
收件者:
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

未讀,
2017年3月17日 凌晨4:00:012017/3/17
收件者:
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 則新訊息