Solved

typing in an opened external file (Exe) Delphi 4

Posted on 2004-04-14
5
272 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

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

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

22 Experts available now in Live!

Get 1:1 Help Now