Solved

How to send commands to other apps?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 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

19 Experts available now in Live!

Get 1:1 Help Now