Solved

typing in an opened external file (Exe) Delphi 4

Posted on 2004-04-14
5
267 Views
Last Modified: 2013-11-13
Using Delphi 4
I am making a program that will open an already existing exe, it does that, now i need it to type what you would usually input with a keyboard, I found the procedure keypress but am unsure of what to type to get the code working. I have this so far and don't know how to fix it:

keypress: procedure (var key : char);

What needs to go where in order for this to work and can i get a list from somewhere to know all keys?

Another easy question:

When using:
ShellExecute(Handle, 'open', PChar('http://www.whatever.com'), nil, nil, SW_SHOW);

What needs to be added to uses it was something like shellopen api or something like that i forget now

I want Delphi to type the keys i tell it to into the exe i had it open, when delphi opens the other exe the cursor is already placed in the correct editbox all i need is for delphi to do the keys for me and hit return, thanks in advance.
                                                                                     Justin Dashney
0
Comment
Question by:JustinDashney
  • 2
5 Comments
 
LVL 7

Expert Comment

by:mquiroz
ID: 10833168
0
 

Author Comment

by:JustinDashney
ID: 10839171
Helped a bit but using keys besides deleted and f9.... don't work Example: VK_J VK_9
and for some reason the key entries are not sent to my program i am using this:

procedure SendKey;
begin
  keybd_event(7, 0, KEYEVENTF_EXTENDEDKEY, 0);        // does not work
  keybd_event(7, 0, KEYEVENTF_KEYUP, 0);                   // does not work
//  keybd_event(VK_F9, 0, KEYEVENTF_EXTENDEDKEY, 0);
//  keybd_event(VK_F9, 0, KEYEVENTF_KEYUP, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShellExecute(Handle, 'open', PChar('c:\Program Files\the 4th coming\wrapper.exe'), nil, nil, SW_SHOW);
  Sleep (100000);   //My external program takes 5-10 seconds to load. any suggestion?
  SendKey;
end;

The key does not end up in the program, it may be becaue i have not used correct format at
keybd_event(7, 0, KEYEVENTF_EXTENDEDKEY, 0);        
or the sleep or i don't really know, any help is appreciated, feel free to email me JustinDashney@hotmail.com but please use the title of this post as subject, thank you
0
 
LVL 7

Accepted Solution

by:
mquiroz earned 125 total points
ID: 10842587
try this code samples (the "sendkeys" ones), and to execute another exe on synchronous way try using ShellExecuteEx API
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

762 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