Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Sending a command click to another application

Posted on 2006-04-20
3
Medium Priority
?
240 Views
Last Modified: 2010-04-04
Hello Guys

I created a system installation with inno, in my system installation I have a pach that is from microsoft, there is no parameter to install the files and replace all files when they are found. When my system installation starts the installation, and this patch is started, it finds some dlls already installed in the system, so the system ask if I want to replace (yes, yes to all, no), I would like to install the system and when the installation stopps I would like to send a command that click the button yes to all, is there any way to do this?

Thanks
0
Comment
Question by:hidrau
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
Scay7 earned 1200 total points
ID: 16500835
Heres how you can send a key to a window...

Procedure sendkey();
var
  window : HWND;
begin
  window := FindWindow('Notepad',nil);
  if window <> 0 then begin
    SendMessage(window,WM_KEYDOWN,wparam(VK_SHIFT),0);
    SendMessage(window,WM_KEYDOWN,wparam('F'),0);
    SendMessage(window,WM_KEYUP,wparam('F'),0);
    SendMessage(window,WM_KEYUP,wparam(VK_SHIFT),0);
  end;
end;

or you can checkup on the following other answers...

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10339527.html?query=send+key&topics=85
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20299749.html?query=send+key&topics=85
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20440279.html?query=send+key&topics=85
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20832101.html?query=send+key&topics=85
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20583169.html?query=send+key&topics=85

Peace Scay7
0
 
LVL 5

Expert Comment

by:Scay7
ID: 16500874
Oh here are other keys(some of em) which you can send anything with VK_ eg VK_Back = a key

(Name:'BKSP'; VKey:VK_BACK),
(Name:'BS'; VKey:VK_BACK),
(Name:'BACKSPACE'; VKey:VK_BACK),
(Name:'BREAK'; VKey:VK_CANCEL),
(Name:'CAPSLOCK'; VKey:VK_CAPITAL),
(Name:'CLEAR'; VKey:VK_CLEAR),
(Name:'DEL'; VKey:VK_DELETE),
(Name:'DELETE'; VKey:VK_DELETE),
(Name:'DOWN'; VKey:VK_DOWN),
(Name:'END'; VKey:VK_END),
(Name:'ENTER'; VKey:VK_RETURN),
(Name:'ESC'; VKey:VK_ESCAPE),
(Name:'ESCAPE'; VKey:VK_ESCAPE),
(Name:'F1'; VKey:VK_F1),
(Name:'F10'; VKey:VK_F10),
(Name:'F11'; VKey:VK_F11),
(Name:'F12'; VKey:VK_F12),
(Name:'F13'; VKey:VK_F13),
(Name:'F14'; VKey:VK_F14),
(Name:'F15'; VKey:VK_F15),
(Name:'F16'; VKey:VK_F16),
(Name:'F2'; VKey:VK_F2),
(Name:'F3'; VKey:VK_F3),
(Name:'F4'; VKey:VK_F4),
(Name:'F5'; VKey:VK_F5),
(Name:'F6'; VKey:VK_F6),
(Name:'F7'; VKey:VK_F7),
(Name:'F8'; VKey:VK_F8),
(Name:'F9'; VKey:VK_F9),
(Name:'HELP'; VKey:VK_HELP),
(Name:'HOME'; VKey:VK_HOME),
(Name:'INS'; VKey:VK_INSERT),
(Name:'LEFT'; VKey:VK_LEFT),
(Name:'NUMLOCK'; VKey:VK_NUMLOCK),
(Name:'PGDN'; VKey:VK_NEXT),
(Name:'PGUP'; VKey:VK_PRIOR),
(Name:'PRTSC'; VKey:VK_PRINT),
(Name:'RIGHT'; VKey:VK_RIGHT),
(Name:'SCROLLLOCK'; VKey:VK_SCROLL),
(Name:'TAB'; VKey:VK_TAB),
(Name:'UP'; VKey:VK_UP)

Peace Scay7
0
 

Assisted Solution

by:carolosf
carolosf earned 800 total points
ID: 16501004
hmmm...
i dont have delphi installed on my system but you can do this by using
windows api to send keyboard messages to the window
when it pops up
//gets the windows name from a window handle
function GetWinName(cmd :Longint) : string;
var x: hwnd;
    a: array [0..255] of char;

begin
FillChar(a,255,0);
GetWindowText(cmd,a,128);
result := a;
end;

//-- var ActiveWin : string;
ActiveWin := GetWinName(GetForegroundWindow());//to get the window name and convert it to a constant later

repeat

Application.ProcessMessages;
  if  (GetWinName(GetForegroundWindow()) = ActiveWin) then
 begin
   keybd_event(VK_TAB,1,0,0); //use this to tab to the correct
   keybd_event(VK_RETURN,1,0,0); //use this to "click" the button
//-var ticks : cardinal;
  ticks := gettickcount() + 5000; //this sets a timeout of 5 seconds
end;
until ((GetWinName(GetForegroundWindow()) <> ActiveWin) and (gettickcount() >= ticks));
 
0

Featured Post

Technology Partners: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

581 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