Re: Sending Keystrokes to application with known hwnd



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.
>
>


.



Relevant Pages

  • Re: Sending Keystrokes to application with known hwnd
    ... which uses Terminal Services Client. ... SendKeys probably uses an older API function, ... That's why I need to send keys to it because the ... >> Services Client window), but the Terminal Services Client window seems to ...
    (microsoft.public.vb.winapi)
  • Re: Terminal Services Client
    ... My idea was to set the Windows Terminal Services Client as Shell ... If the user want to change the server settings and the autologon flag is ...
    (microsoft.public.windowsxp.embedded)
  • Re: Accessing Windows 2000 server Terminal Services from XP Home Edition
    ... Do you have any purchased TS CALs showing as available on your TS licensing server? ... and Terminal Services client - same message. ... remote computer, running either remote desktop or terminal services ...
    (microsoft.public.windows.terminal_services)
  • Re: huge user.dat related to printers
    ... The printer driverare not compatible with Terminal Services and quite possibly are poor even if they were running on XP on other workstation OS. ... HKEY_USERS\.DEFAULT\Software\SHARP Examples keys: ... on, depending on their session number, a key was created. ... deleting the>100mb ntuser.dats that had been created ...
    (microsoft.public.windows.terminal_services)
  • Re: Question about HKEY_USERS
    ... The others keys are created from these two keys, ... I can see his profile under HKU. ... When you log off and log on with different users during the same Windows session Terminal Services may keep the information and you may see the different user SIDs kept in the HKU branch, although the users have logged off, because of TS these users may be sort of considered to be still logged on. ...
    (microsoft.public.windowsxp.general)