| | |
Sending keys to active window.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Use PostMessage() . It will add your message to the the recieving windows message que.
(SendMessage is to be used only within the same thread).
Also, check out SendThreadMessage considering that PostMessage returns immediately so you can't get the return code from the message.
You may need the window's HWND as a parameter. To get the target process HWND try FindWindow or module walk through a list of process id's then get the HWND from the id.
If the recieving window is already active, you can do the following using keybd_event:
keybd_event( 'A', 0, 0, 0 );
keybd_event( 'A', 0, KEYEVENTF_KEYUP, 0 );
If you have the target process HWND, then you can set the window acive then use keybd_event (however it is better to use PostMessage if you have the hwnd -- that way if focus is somehow interupted it will not cause any problem)
For information on function prototypes reference msdn.com and search for the function name or keyword (i.e. PostMessage, keybd_event, module walking, etc)
(SendMessage is to be used only within the same thread).
Also, check out SendThreadMessage considering that PostMessage returns immediately so you can't get the return code from the message.
You may need the window's HWND as a parameter. To get the target process HWND try FindWindow or module walk through a list of process id's then get the HWND from the id.
If the recieving window is already active, you can do the following using keybd_event:
keybd_event( 'A', 0, 0, 0 );
keybd_event( 'A', 0, KEYEVENTF_KEYUP, 0 );
If you have the target process HWND, then you can set the window acive then use keybd_event (however it is better to use PostMessage if you have the hwnd -- that way if focus is somehow interupted it will not cause any problem)
For information on function prototypes reference msdn.com and search for the function name or keyword (i.e. PostMessage, keybd_event, module walking, etc)
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
![]() |
Similar Threads
- Using HID Input (C)
- on-screen keyboard (Pascal and Delphi)
- problem with Sendkeys (Visual Basic 4 / 5 / 6)
- Help! Got external program to open from VB6 but now?? (Visual Basic 4 / 5 / 6)
- How to make a window an active window(focussed window) (C++)
- How do you get the address of the Active Window if it is not part of your App? (Visual Basic 4 / 5 / 6)
- Set Accessibility Features for People Who are Blind or Who Have Low Vision in WinXP (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: Binary Code
- Next Thread: copy constructors
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class code coding compile console conversion count data database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





