[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Invisible man that push a button

Posted on 1999-12-14
27
Medium Priority
?
630 Views
Last Modified: 2008-03-17
Hello!!!

I want my Delphi app to run a setup file and when the setup file is finish to load i have to push "next" and may be again "next" , i want my Delphi app to listen if this window is running use FindWindowEx(Findwindow('notepad', nil), 0, 'edit', nil); or something like that. and when this window is upp and running i will let my Delphi program to hit automatically the left mouse button and more, "that's needs to the setup" with API Postmessage - WM_LBUTTONDOWN and UP

Is this Possible?
0
Comment
Question by:trausti
  • 12
  • 11
  • 3
  • +1
27 Comments
 
LVL 4

Expert Comment

by:Palamedes
ID: 2280270
Just so I understand,  You want your application to sit in the background and automate the setup process of some other application?
0
 

Author Comment

by:trausti
ID: 2280286
Yes , and thank you for understand me
0
 
LVL 1

Expert Comment

by:bogieman_
ID: 2280352
Well, your grammer needs improving, but I think I get the jist - I'll see what I can come up with...
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Expert Comment

by:Palamedes
ID: 2280393
Hmmm This would be subclassing a window I think.  I have no idea how to do this in Delphi.  Going to have to look into it.

-Pal
0
 

Accepted Solution

by:
PhrAtoR earned 300 total points
ID: 2280695
Hi!

First you should use Winsight to get the Classname and Buttonname of the Button you want to push and its parent window.
Then you can can use Findwindow to get the handle of the parentwindow and the button.

var
  hwnd : longint;
  h    : longint;
begin
  hwnd:=FindWindow('TMainwindow',NIL);
  if hwnd<>0 then begin
    h:=hwnd;
    hwnd:=FindWindowEx(hwnd,0,'TButton','&Next');
    if hwnd<>0 then begin
      SendMessage(h,WM_KEYDOWN,13,0);
      SendMessage(h,WM_KEYUP,13,0);
    end;
  end;
end;

insteat of sendind WM_KEYDOWN/UP you can send WM_LBUTTONDOWN / UP

I didn't run the sample, but i think it will work.

kind regards
PhrAtoR
0
 

Expert Comment

by:PhrAtoR
ID: 2280698
PS: if you don't have winsight, let me know. i wrote my own 'small' version -)
0
 

Author Comment

by:trausti
ID: 2280732
I have not the Winsight, what is that, can you send me

question@vis.is
0
 

Author Comment

by:trausti
ID: 2280782
This won't work

hwnd:=FindWindowEx(hwnd,0,'TButton','&Next');

What is 0,TButton,&Next ?

I'm trying to install "Getright" and push &next And ?
0
 

Author Comment

by:trausti
ID: 2280807
hwnd get 0 in debugging

hwnd:=FindWindowEx(hwnd,0,'TButton','&Next');
0
 

Expert Comment

by:PhrAtoR
ID: 2280824
Winspy is included in delphi professionell and c/s, so i can't send it (would be illegal).
I'll send you my small prog.

hwnd:=FindWindowEx(hwnd,0,'TButton','&Next');

0  =  handle to a childwindow. 0 because there is no.
'TButton'  = Name of a component (like Tform or TButton, TEdit,...)
'&Next'  = Title of the window or button.

PhrAtoR

0
 

Author Comment

by:trausti
ID: 2280839
This won't work, here is the code

var
hwnd : THandle;
h    : THandle;
begin
hwnd := FindWindow(NIL,'Cool Edit 96 Installation');
if hwnd<>0 then begin
//h:=hwnd;
SetForeGroundWindow(hwnd);
Sleep(1000);
h := FindWindowEx(hwnd,0,'Welcome!','&OK');
SetForeGroundWindow(h);
//hwnd:=FindWindowEx(h,0,'Welcome!','Next');
//if hwnd<>0 then begin
SendMessage(hwnd,WM_KEYDOWN,13,0);
SendMessage(hwnd,WM_KEYUP,13,0);
end;
end;
//end;
0
 

Expert Comment

by:PhrAtoR
ID: 2280927
if there is no window/button with componentname 'TButton' and Title '&Next' FindWindowEX MUST result 0

0
 

Author Comment

by:trausti
ID: 2280947
There is a button with name "next" and the window caption is GetRight Installation the same as parent

what can i do?
0
 

Expert Comment

by:PhrAtoR
ID: 2280956
Thats right. This code won't work.
in your code hwnd is the handle of the window 'Cool Edit 96 Installation'.

you have to send the messages to the button, so you need the handle of the button.
hwnd:=FindWindow('Cool Edit 96 Installation',NIL);
if hwnd<>0 then begin
    h:=hwnd;
    hwnd:=FindWindowEx(hwnd,0,[COMPONENTNAME],'OK');
  if hwnd<>0 then begin
      SendMessage(h,WM_KEYDOWN,13,0);
      SendMessage(h,WM_KEYUP,13,0);
    end;

You have to replace [COMPONENTNAME] by the name of the Button's component. Use my program to get its name.
it's the string in the brackets ().
If one letter in 'OK' is underlined then put a & in front of it.
0
 

Expert Comment

by:PhrAtoR
ID: 2280966
Thats right. This code won't work.
in your code hwnd is the handle of the window 'Cool Edit 96 Installation'.

you have to send the messages to the button, so you need the handle of the button.
hwnd:=FindWindow('Cool Edit 96 Installation',NIL);
if hwnd<>0 then begin
    h:=hwnd;
    hwnd:=FindWindowEx(hwnd,0,[COMPONENTNAME],'OK');
  if hwnd<>0 then begin
      SendMessage(h,WM_KEYDOWN,13,0);
      SendMessage(h,WM_KEYUP,13,0);
    end;

You have to replace [COMPONENTNAME] by the name of the Button's component. Use my program to get its name.
it's the string in the brackets ().
If one letter in 'OK' is underlined then put a & in front of it.
0
 

Expert Comment

by:PhrAtoR
ID: 2280967
Thats right. This code won't work.
in your code hwnd is the handle of the window 'Cool Edit 96 Installation'.

you have to send the messages to the button, so you need the handle of the button.
hwnd:=FindWindow('Cool Edit 96 Installation',NIL);
if hwnd<>0 then begin
    h:=hwnd;
    hwnd:=FindWindowEx(hwnd,0,[COMPONENTNAME],'OK');
  if hwnd<>0 then begin
      SendMessage(h,WM_KEYDOWN,13,0);
      SendMessage(h,WM_KEYUP,13,0);
    end;

You have to replace [COMPONENTNAME] by the name of the Button's component. Use my program to get its name.
it's the string in the brackets ().
If one letter in 'OK' is underlined then put a & in front of it.
0
 

Expert Comment

by:PhrAtoR
ID: 2280970
oops. last comment was posted three times. sorry.
PhrAtoR
0
 

Author Comment

by:trausti
ID: 2281069
Where is the program email: emil@vis.is
0
 

Author Comment

by:trausti
ID: 2281072
Alright this works,

When i have click one "&next" i have to wait for extract , before i can click the &next button. How can i wait for the next window?
0
 

Expert Comment

by:PhrAtoR
ID: 2281100
just implemant a loop that looks for the next window like this:

while findwindow('NameOfSecondWindow',Nil)= 0 do;
handleof2ndwindow:=findwindow('NameOfSecondWindow',Nil)

PhrAtoR
0
 

Expert Comment

by:PhrAtoR
ID: 2281103
don't forget the ; behind the do!
0
 

Author Comment

by:trausti
ID: 2281263
What are you meaning?
0
 

Author Comment

by:trausti
ID: 2281274
Can you show me some examples with While - DO
0
 

Expert Comment

by:PhrAtoR
ID: 2281600
Examples? What kind of examples?

do; means do nothing

so
while findwindow('NameOfSecondWindow',Nil)= 0 do;
means: while there is no window with the title 'NameOfSecondWindow' do nothing. When there is a window -> finish the loop and continue with the program.

PhrAtoR
0
 
LVL 4

Expert Comment

by:Palamedes
ID: 2281635
The problem with that is, what if a window NEVER opens with that name.. suddenly you have an application running waiting for something that will never happen..

-Pal
0
 

Author Comment

by:trausti
ID: 2282598
Let's say i'm installing Acrobat Reader 4.0, this setup opens tvo windows Main and Child, i just want to control the Childe window and send WM_KEYDOWN - WM_KEYUP thats all. You can test this if you have Acrobat Reader 4.0

Thanks
Trausti
0
 

Expert Comment

by:PhrAtoR
ID: 2284459
i'll test it.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

640 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