Solved

How to send commands to other apps?

Posted on 1998-06-21
1
150 Views
Last Modified: 2010-04-04
Hi, what i mean is i.e i open telnet client with winexec
how i send it parameters like login and password and host.
I want make a program that you write host, password & login. It will connect to it automaticly.
If you can help me do it for 50pts. please thanks.
0
Comment
Question by:dima_sherman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
pjdb earned 50 total points
ID: 1354824
If the apps have the keyboard focus, use the following SendKeys function. However If you use ShellExecute instead of WinExec you have the handle of the windows and then use it for the handle (hw) instead of hw:=GetFocus.

Function SendKeys(keys:String):Boolean;
Var
      hw:Hwnd;
      i:Byte;
Begin
      Result:=False;
      If Length(keys)>0 Then
            hw:=GetFocus;
            If hw<>0 Then
            Begin
                  For i:=1 to length(keys) do
                        Case keys[i] Of
                        #9:      {tab}
                              Begin
                                    KeyBD_event(vk_Tab, $45, KeyEventf_ExtendedKey Or 0, 0);
                                    KeyBD_event(vk_Tab, $45, KeyEventf_ExtendedKey Or KeyEventf_KeyUp, 0);
                        end;
                        #13:      {return}
                              Begin
                                    KeyBD_event(vk_Return, $45, KeyEventf_ExtendedKey Or 0, 0);
                                    KeyBD_event(vk_Return, $45, KeyEventf_ExtendedKey Or KeyEventf_KeyUp, 0);
                              End;
                        #27:      {escape}
                              Begin
                                    KeyBD_event(vk_Escape, $45, KeyEventf_ExtendedKey Or 0, 0);
                                    KeyBD_event(vk_Escape, $45, KeyEventf_ExtendedKey Or KeyEventf_KeyUp, 0);
                              End;
                        Else      {any other key}
                              PostMessage(hw, wm_char, word(keys[i]), 1);
                  End;
                  Result:=True;
            End;
End;      {SendKeys}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question