Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

typing in an opened external file (Exe) Delphi 4

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
JustinDashney
Asked:
JustinDashney
  • 2
1 Solution
 
mquirozCommented:
0
 
JustinDashneyAuthor Commented:
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
 
mquirozCommented:
try this code samples (the "sendkeys" ones), and to execute another exe on synchronous way try using ShellExecuteEx API
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now