|
-
December 4th, 2002, 10:18 AM
#1
Windows messaging
OK. I Want to send Windows messages using the PostMessage Method. The Messages I send are Standard windows Messages (like WM_KEYUP ...) and I want to inject them into the System.
To accomplish that I tried to call PostMessage with WH_BROADCAST as window Handle, but the Messages I send only reach my own Window.
What do I have to do, to have my messages reach every Window?
-
December 4th, 2002, 10:46 AM
#2
if you are trying to dump characters into the keyboard, you need to send both WM_KEYDOWN and WM_KEYUP messages
-
December 4th, 2002, 10:46 AM
#3
Those Windows wont get the messages that you are sending unless you point your messages to those windows, i.e If you are using
CWnd::PostMessage then it will be invoked on the your current window. For your messages to reach the other windows one way of doing it can be to get the Handle to that window by using FindWindow then convert it to CWnd by using CWnd::FromHandle then invoking the PostMessage function on the retrieved CWnd Object.
Or an easierway could be
Code:
::PostMessage(::FindWindow("WindowClass", "WindowName"), WM_QUIT, 0, 0);
Hope This Helps,
Regards,
Usman.
Last edited by usman999_1; December 4th, 2002 at 10:48 AM.
-
December 6th, 2002, 03:16 AM
#4
The problem is: I dont know nothing about the window that shall receive the message.
I got my keyUps & Dows and and need whatever window has Focus to think the User pressed this keys (or moved Mouse or whatever)
-
December 6th, 2002, 06:22 AM
#5
This API will tell you which window has currently the focus IF according to MSDN "The window is attached to the calling thread's message queue.". So this will get you the HWND to the window which has the focus. Then you can use that handle to send whatever message you want to send to the window. Or you can use
Code:
GetForegroundWindow
.
Or you can enumerate b/w windows by using
Code:
FindWindow/FindWindowEx
combination to find your desired window/s.
But normally i guess the window that has the focus should be responsible for the window messages.
Hope This Helps,
Regards,
Usman.
-
December 11th, 2002, 10:17 AM
#6
Hmm...
I tried to get around with one of theese... but:
My Window is not atached to the calling threads message quene -no 'getFocus().
FindWindow/FindWindowEx require me to know, which window usually received the messages. - but I don't-
Using 'GetForegroundWindow()' I get some Window Handle, but posting a message to that handle results in an error.
But even if this worked it would not solve my problem at all, because later on I want to send also mouse events.
I guess I have to inject my messages somewhere earlyer, so that 'Windows' decides where to pass theese messages.
but how to ???
-
December 11th, 2002, 06:09 PM
#7
Try SetWindowsHookEx() to catch all or special Window-Events.
Mikey
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|