|
-
April 1st, 1999, 04:07 AM
#1
howto send keyboard input to the active application??
How can I 'feed' the active application (the active window) with virtual keyboard input from an background task?
thanks for your halp
K.
-
April 1st, 1999, 04:19 AM
#2
Re: howto send keyboard input to the active application??
Surely if the background app is sending the appropriate messages, you can retrieve them within the active app in the normal way.
Simon P.
-
April 1st, 1999, 04:38 AM
#3
Re: howto send keyboard input to the active application??
Try using ::SendMessage(hWndActive,WM_CHAR,nCharCode,nData);
If nData is between 1 and 15, it is the number of repeats of the character
(see the help on WM_CHAR for the other values).
-
April 1st, 1999, 08:03 AM
#4
Yes, but ...
Yes, but how do I get the HWND of the active application?
And..
.. can I send it to the main window, or do I have to send it th the active window?
Thanks
K.
-
April 1st, 1999, 09:37 AM
#5
Re: Yes, but ...
It really depends on exactly what you want to do. To get the active window, try using GetForegroundWindow(), to find a specific application window, try using FindWindow(...)
-
April 1st, 1999, 12:47 PM
#6
Does't work ...
I tried it, but it doesn't work.
Here ist the code:
HWND hW;
hW=::GetForegroundWindow ();
m_nResult=::SendMessage (hW,WM_CHAR,'X',1);
So why does't it work???
-
April 1st, 1999, 03:38 PM
#7
Re: howto send keyboard input to the active application??
You should use the keybd_event API call. This function
sends the specified keystroke to the window that currently has
the input focus.
The keybd_event API call has four parameters:
BYTE VKeyCode, BYTE ScanCode, DWORD flags, DWORD ExtraInfo
I just used the first two parameters, and it seemed to work fine...
-
April 1st, 1999, 03:38 PM
#8
Re: howto send keyboard input to the active application??
You should use the keybd_event API call. This function
sends the specified keystroke to the window that currently has
the input focus.
The keybd_event API call has four parameters:
BYTE VKeyCode, BYTE ScanCode, DWORD flags, DWORD ExtraInfo
I just used the first two parameters, and it seemed to work fine...
-
April 2nd, 1999, 04:30 AM
#9
Re: howto send keyboard input to the active application??
Hi Rob,
I tried it and it seems to work fine.
But all output is in lower case.
And for what do I need the 'ScanCode'?
-
April 2nd, 1999, 09:22 AM
#10
Re: howto send keyboard input to the active application??
The scan code is for the "OEM-dependent hardware scan code". Most applications don't use this scan code. The documentation says that the system converts this guy to a virtual key code anyway.
As far as case goes, you have to send a different virtual key code to specify case. For example:
f - 102
F - 70
Hope this helps
-
April 2nd, 1999, 09:22 AM
#11
Re: howto send keyboard input to the active application??
The scan code is for the "OEM-dependent hardware scan code". Most applications don't use this scan code. The documentation says that the system converts this guy to a virtual key code anyway.
As far as case goes, you have to send a different virtual key code to specify case. For example:
f - 102
F - 70
Hope this helps
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
|