Solved

How to send commands to other apps?

Posted on 1998-06-21
1
144 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now