处理主窗口。 [英] Handle to main window.

查看:63
本文介绍了处理主窗口。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


是否有办法获取应用程序主窗口的窗口句柄

或进程?

例如,如果某人打开了Microsoft Word,他会得到一个窗口,这样他/她就可以写b / b
$ Spy ++给出了这个窗口叫_Wwg。


我们如何处理这个窗口,假设我们事先不知道
过程的名称,

我们只是想找到每个应用程序主窗口的句柄?

(或者当前有焦点/插入符号的窗口)。


是这可能吗?


非常感谢您的帮助,


objectref

Hi to all,

is there a way to get the window handle of the main window of an application
or process ?
For example, if someone opens Microsoft Word, he gets a window so he/she can
write text.
Spy++ gives that this window is called _Wwg.

How we can get a handle to this window assuming that we do not know
beforehand the name of the process,
we just want to find the handle of every application''s main window ?
(or the window that currently has the focus/caret).

Is this possible ??

Thanks a lot for any help,

objectref

推荐答案

你好objectref,


..NET并没有提供windwos的启发。但是你可以随时使用

PInvoke并调用其中一个windows枚举API。


你能用.NET类做的唯一事情就是调用

Process.GetProcesses()方法获取当前所有进程的数组

在机器上启动。然后对于每个过程,您可以阅读

MainWindowHandle属性。


但是,通过这种方式,您可以阅读其中一个过程''顶层窗口。 />
进程可能有多个主窗口。例如,查看Windows和

Internet Explorer应用程序。对于每个GUI,它们只有一个进程和一个单独的

线程。对于这些应用程序,您只能获得一个主要的

窗口。另一个例子可能是.NET应用程序,它运行多个一个

应用程序域,其中有自己的GUI。


-


Stoitcho Goutsev(100)[C#MVP]

" objectref" < OB ******* @ mediatrel.com>在消息中写道

新闻:%2 *************** @ TK2MSFTNGP11.phx.gbl ...
Hi objectref,

..NET doesn''t provide enumaration of windwos. However you can always use
PInvoke and call one of the windows enumeration APIs.

The only thing that you can do with .NET classes is to call
Process.GetProcesses() method to get array of all processes currently
started on the machine. Then for each process you can read the
MainWindowHandle property.

However, in this way you can read one of the process'' toplevel windows.
Process may have more then one main windows. For example look at Windows and
Internet Explorer application. They have only one process and a separate
thread for each GUI. For these application you''ll get only one of the main
windows. Another example could be .NET application that runs more then one
application domains, which of which has its own GUI.

--

Stoitcho Goutsev (100) [C# MVP]
"objectref" <ob*******@mediatrel.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
大家好,

有没有办法获得
应用程序或进程的主窗口的窗口句柄?
例如,如果有人打开Microsoft Word,他会得到一个窗口,所以他/她
可以写文本。
间谍++给出了这个窗口叫做_Wwg。

我们怎么能得到这个窗口的句柄,假设我们不知道事先的过程名称,
我们只想找到每个应用程序主窗口的句柄?
(或当前有焦点/插入符号的窗口)。
<这是可能的吗?

非常感谢你的帮助,

objectref
Hi to all,

is there a way to get the window handle of the main window of an application or process ?
For example, if someone opens Microsoft Word, he gets a window so he/she can write text.
Spy++ gives that this window is called _Wwg.

How we can get a handle to this window assuming that we do not know
beforehand the name of the process,
we just want to find the handle of every application''s main window ?
(or the window that currently has the focus/caret).

Is this possible ??

Thanks a lot for any help,

objectref



您好Stoitcho,


i知道这一切,这就是为什么我根据每个进程的

MainWindowHandle调用EnumChildWindows。

问题是我想调用PostMessage和在

中发送一些当时具有焦点的窗口,即应用程序的活动

窗口。


你知道某种方式吗?


非常感谢你的回答,


objectref

Stoitcho Goutsev(100)[C#MVP]" < 10*@100.com>在消息中写道

news:eU ************* @ TK2MSFTNGP11.phx.gbl ...
Hi Stoitcho,

i know all this and that''s why i am calling EnumChildWindows based on the
MainWindowHandle of each process.
The problem is that i want to call PostMessage and send some characters in
the window that have the focus at that time, ie, the application''s active
window.

Do you know some way of doing that ??

Thanks a lot for your answer,

objectref
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:eU*************@TK2MSFTNGP11.phx.gbl...
objectref,
.NET并没有提供windwos的强大功能。但是你可以随时使用PInvoke并调用其中一个windows枚举API。

你可以用.NET类做的唯一事情是调用
Process.GetProcesses()获取当前在机器上启动的所有进程的数组的方法。然后,对于每个过程,您都可以阅读
MainWindowHandle属性。

然而,通过这种方式,您可以阅读其中一个进程''顶层窗口。
进程可能有多个主窗户。例如,查看Windows
和Internet Explorer应用程序。对于每个GUI,它们只有一个进程和一个单独的
线程。对于这些应用程序,您将只获得一个主要的窗口。另一个例子可能是运行多个应用程序域的.NET应用程序,其中有自己的GUI。



Stoitcho Goutsev(100) [C#MVP]

" objectref" < OB ******* @ mediatrel.com>在消息中写道
新闻:%2 *************** @ TK2MSFTNGP11.phx.gbl ...
Hi objectref,

.NET doesn''t provide enumaration of windwos. However you can always use
PInvoke and call one of the windows enumeration APIs.

The only thing that you can do with .NET classes is to call
Process.GetProcesses() method to get array of all processes currently
started on the machine. Then for each process you can read the
MainWindowHandle property.

However, in this way you can read one of the process'' toplevel windows.
Process may have more then one main windows. For example look at Windows and Internet Explorer application. They have only one process and a separate
thread for each GUI. For these application you''ll get only one of the main
windows. Another example could be .NET application that runs more then one
application domains, which of which has its own GUI.

--

Stoitcho Goutsev (100) [C# MVP]
"objectref" <ob*******@mediatrel.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
大家好,

有没有办法获取
Hi to all,

is there a way to get the window handle of the main window of an


应用程序


application

或进程的主窗口的窗口句柄?
例如,如果有人打开Microsoft Word,他得到一个窗口,所以他/她
or process ?
For example, if someone opens Microsoft Word, he gets a window so he/she


可以

写文本。
Spy ++给出了这个窗口叫做_Wwg。
我们只是想找到每个应用程序主窗口的句柄? />(或当前有焦点/插入符号的窗口)。

这可能吗?

非常感谢您的帮助,

> objectref
write text.
Spy++ gives that this window is called _Wwg.

How we can get a handle to this window assuming that we do not know
beforehand the name of the process,
we just want to find the handle of every application''s main window ?
(or the window that currently has the focus/caret).

Is this possible ??

Thanks a lot for any help,

objectref




您必须使用PInvoke调用Win32 API来调用PostMessage。请参阅:
http://www.pinvoke.net/


-

Adam Clauss
ca ***** @ tamu.edu


" objectref" < OB ******* @ mediatrel.com>在留言新闻中写道:%2 **************** @ TK2MSFTNGP11.phx.gbl ...
You will have to make calls to the Win32 API using PInvoke to call PostMessage. See:
http://www.pinvoke.net/

--
Adam Clauss
ca*****@tamu.edu

"objectref" <ob*******@mediatrel.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
嗨Stoitcho,
我知道所有这一切,这就是为什么我根据每个进程的MainWindowHandle调用EnumChildWindows。
问题是我想调用PostMessage并发送一些字符
那个时候有焦点的窗口,即应用程序的活动窗口。

你知道某种方式吗?

谢谢很多你的答案,

objectref

Stoitcho Goutsev(100)[C#MVP]" < 10*@100.com>在消息中写道
新闻:eU ************* @ TK2MSFTNGP11.phx.gbl ...
Hi Stoitcho,

i know all this and that''s why i am calling EnumChildWindows based on the
MainWindowHandle of each process.
The problem is that i want to call PostMessage and send some characters in
the window that have the focus at that time, ie, the application''s active
window.

Do you know some way of doing that ??

Thanks a lot for your answer,

objectref
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:eU*************@TK2MSFTNGP11.phx.gbl...
你好objectref,

.NET并没有提供windwos的强大功能。但是你可以随时使用PInvoke并调用其中一个windows枚举API。

你可以用.NET类做的唯一事情是调用
Process.GetProcesses()获取当前在机器上启动的所有进程的数组的方法。然后,对于每个过程,您都可以阅读
MainWindowHandle属性。

然而,通过这种方式,您可以阅读其中一个进程''顶层窗口。
进程可能有多个主窗户。例如,查看Windows
Hi objectref,

.NET doesn''t provide enumaration of windwos. However you can always use
PInvoke and call one of the windows enumeration APIs.

The only thing that you can do with .NET classes is to call
Process.GetProcesses() method to get array of all processes currently
started on the machine. Then for each process you can read the
MainWindowHandle property.

However, in this way you can read one of the process'' toplevel windows.
Process may have more then one main windows. For example look at Windows


Internet Explorer应用程序。对于每个GUI,它们只有一个进程和一个单独的
线程。对于这些应用程序,您将只获得一个主要的窗口。另一个例子可能是运行多个应用程序域的.NET应用程序,其中有自己的GUI。



Stoitcho Goutsev(100) [C#MVP]

" objectref" < OB ******* @ mediatrel.com>在消息中写道
新闻:%2 *************** @ TK2MSFTNGP11.phx.gbl ...
Internet Explorer application. They have only one process and a separate
thread for each GUI. For these application you''ll get only one of the main
windows. Another example could be .NET application that runs more then one
application domains, which of which has its own GUI.

--

Stoitcho Goutsev (100) [C# MVP]
"objectref" <ob*******@mediatrel.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
大家好,

有没有办法获取
Hi to all,

is there a way to get the window handle of the main window of an


应用程序


application

或进程的主窗口的窗口句柄?
例如,如果有人打开Microsoft Word,他得到一个窗口,所以他/她
or process ?
For example, if someone opens Microsoft Word, he gets a window so he/she


可以

写文本。
Spy ++给出了这个窗口叫做_Wwg。
我们只是想找到每个应用程序主窗口的句柄? />(或当前有焦点/插入符号的窗口)。

这可能吗?

非常感谢您的帮助,

> objectref
write text.
Spy++ gives that this window is called _Wwg.

How we can get a handle to this window assuming that we do not know
beforehand the name of the process,
we just want to find the handle of every application''s main window ?
(or the window that currently has the focus/caret).

Is this possible ??

Thanks a lot for any help,

objectref





这篇关于处理主窗口。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆