如何鼠标点击事件发送到隐藏的窗口? [英] How to send a mouse click event to a hidden window?

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

问题描述

认识到可能需要互操作的一点,我怎么送鼠标点击事件当前没有显示的窗口?我有一个是作为服务运行和摆弄与隐藏窗口,需要鼠标点击事件发送到其中的一个,尽管它实际上并不能显示该窗口的应用程序。

Recognising that a bit of interop may be required, how do I send a mouse click event to a window that is currently not being displayed? I have an application that is running as a service and fiddling about with hidden windows and needs to send a mouse click event to one of them, even though it can't actually display the window.

正常的方式,我会做是简单地点击发送到屏幕在适当的位置,但很明显,这种方法不会在这种情况下工作。想法?

The normal way I would do it is to simply send a click to the screen in the appropriate location, but obviously that method won't work in this case. Ideas?

推荐答案

如果你能得到窗口的HWND,这是很容易。
使用 PostMessage的()与 。WM_LBUTTONDOWN为左击

If you can get the HWND of the window, it's pretty easy. Use PostMessage() with WM_LBUTTONDOWN for a left click.

例如:点击位置10,10(未经测试,C)

Example: click on position 10,10 (untested, C)

HWND hWnd = (hwnd of window)
WORD mouseX = 10;
WORD mouseY = 10;
PostMessage(hWnd,WM_LBUTTONDOWN,0,MAKELPARAM(mouseX,mouseY));

这篇关于如何鼠标点击事件发送到隐藏的窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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