Windows: send Mouse/Keyboard event to background window?

别等时光非礼了梦想. 提交于 2019-12-06 12:17:47

问题


My application is a fullscreen window which is rendering a designated other window (from dwm), for example Google Chrome. I would like to know if it's possible to send events (such as mouse keyboard events) to the specified window.

Of course the designated window has to stay in background, and my current application on the foreground.

My application is written in C++. I'm working on Windows 7/8.


回答1:


Just to put it into an answer.

Based on this question Does any program/language/library that interacts with windows do it via the WIN32 API? you should be able to use the windows API to send a windows message to any window. All you need to get is that windows handle, or you could do a broadcast to all windows.

The specific function http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx

Though that function will block until the windows responds and processes the message, this could hurt GUI performance. If you notice issues try implementing http://msdn.microsoft.com/en-us/library/windows/desktop/ms644951(v=vs.85).aspx instead.



来源:https://stackoverflow.com/questions/25245607/windows-send-mouse-keyboard-event-to-background-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!