如何将鼠标事件发布到进程? [英] How to post mouse events to a process?

查看:125
本文介绍了如何将鼠标事件发布到进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将鼠标事件发送给进程,如
mouseEvent(leftDown,x,y);

我的目的是将事件发布到应用程序主循环中(甚至不更改光标位置),这样我就可以继续使用鼠标和键盘来做其他事情.

在Windows上是否存在执行此操作的方法?

PS:对不起,我的英语.

Hi, I need to send to a process mouse events like
mouseEvent(leftDown,x,y);

My purpose is to post events to the app main loop (without even changing the cursor position) so I can keep using mouse and keyboard for doing other things.

Does exist a way to do that on Windows?

PS: sorry for my English.

推荐答案

首先,您需要目标应用程序主窗口的句柄.如果您的应用程序内部启动目标应用程序(使用Process对象),则实现起来要容易得多.获取窗口句柄后,可以将所需的任何Windows消息发送给窗口.


顺便说一句,如果您的应用程序没有启动目标应用程序,您仍然可以通过枚举正在运行的进程来获取窗口句柄.

Google是您的朋友.
First, you need a handle to the target application''s main window. This is much easier to achieve if your application launches the target application interally (using the Process object). After you get the window handle, you can send the window any Windows message that you wish.


BTW, if your app doesn''t launch the target app, you can still get the window handle by enumerating the running processes.

Google is your friend.


首先使用findwindow获取HWND

然后sendmessage(...)

那好吧

对不起,我的英语不好.
first use findwindow get the HWND

then sendmessage(...)

then ok

my English is not well,sorry,I want to say I can not express


这篇关于如何将鼠标事件发布到进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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