Re: Sending Keystrokes to application with known hwnd
- From: "Amir" <agamy@xxxxxxxxxxxx>
- Date: Sun, 25 Sep 2005 02:29:56 +0200
Hi,
The problem is that I am trying to control an emulation (Terminal Serviced
Client) to another computer, so I can't really control that external
computer. That's why I need to send keys to it because the external computer
is not even in my LAN (unless you could think of another way of doing that).
It goes like this:
My Computer -> Terminal Services Client (Emulation) -> External Computer ->
The external computer's COM port -> Another computer (Not a PC) ->
Application running on the non-PC computer.
I've succeded in sending keys to applications running on my machine (Windows
2000), but failed in doing so with the Terminal Services Client.
I've been trying sending keys using the Windows Scripting Host SendKeys
command and also by using keybd (I've tried to send it to the Terminal
Services Client window), but the Terminal Services Client window seems to
ignore these functions! It's weird because when I physically press my
keyboard when the Terminal Services Client window has focus, the terminal
services program do react to my key presses.
(I didn't forget to bring the Terminal Services Client window to the front
before sending keys to it..)
I will try solving that using William's solution (putting the key strokes
sequence in the memory, then calling SendInput).
I hope this will solve that problem. Anyway, this is a bit strange, I mean
what's the difference between calling SendKeys as opposed to putting the
keys sequence in memory then calling SendInput, and what's the difference
between these 2 methods and the method of using keybd to do the same action?
I will be happy if you have any explanation for that, or ideas of other
solutions to that problem.
I very appreciate your trying to help me by far.
Kind Regards,
Amir.
"Sam Hobbs" <samuel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:uqwlvkTsFHA.3216@xxxxxxxxxxxxxxxxxxxxxxx
> "Amir" <agamy@xxxxxxxxxxxx> wrote in message
> news:ezAj6YMsFHA.4044@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> 1. Why don't just use the following code:
>> Private Const VK_F1 = &H70
>> Private Const KEYEVENTF_EXTENDEDKEY = &H1
>> Private Const KEYEVENTF_KEYUP = &H2
>> Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte,
>> ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
>> Sub SendF1KeyStroke()
>> keybd_event VK_F1, 0, 0, 0 ' press F1
>>
>> keybd_event VK_F1, 0, KEYEVENTF_KEYUP, 0 ' release F1
>> End Sub
>
> The problems you stated in your original question are good examples of the
> problems with doing it that way. The way you want to do it is not the way
> that Windows is designed to be used. Sending keystrokes should be avoided
> whever possible.
>
> In your original question you said "if the application loses focus for
> some reason, keys will be sent to the wrong application" and you said
> "using it's hwnd instead of just shooting the keystrokes without knowing
> to which application" and you said "wait for the application to process
> the action so that it won't be 'too fast' ". All those problems are solved
> if you use Windows the way it is designed to be used.
>
>> 2. When I tried to use the following code to send the key combination
>> Ctrl+H it didn't work. Do you have any idea why is that?
>
> The code uses keybd_event and I am not familiar with it; sorry.
>
>
.
- References:
- Re: Sending Keystrokes to application with known hwnd
- From: Amir
- Re: Sending Keystrokes to application with known hwnd
- From: Sam Hobbs
- Re: Sending Keystrokes to application with known hwnd
- Prev by Date: Re: dll function viewer help
- Next by Date: Re: Convert PDF to TIFF
- Previous by thread: Re: Sending Keystrokes to application with known hwnd
- Next by thread: Re: Sending Keystrokes to application with known hwnd
- Index(es):
Relevant Pages
|