Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to send commands to other apps?

Posted on 1998-06-21
1
Medium Priority
?
156 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 100 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 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