Invisible man that push a button

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?
traustiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PalamedesCommented:
Just so I understand,  You want your application to sit in the background and automate the setup process of some other application?
0
traustiAuthor Commented:
Yes , and thank you for understand me
0
bogieman_Commented:
Well, your grammer needs improving, but I think I get the jist - I'll see what I can come up with...
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

PalamedesCommented:
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
PhrAtoRCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PhrAtoRCommented:
PS: if you don't have winsight, let me know. i wrote my own 'small' version -)
0
traustiAuthor Commented:
I have not the Winsight, what is that, can you send me

question@vis.is
0
traustiAuthor Commented:
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
traustiAuthor Commented:
hwnd get 0 in debugging

hwnd:=FindWindowEx(hwnd,0,'TButton','&Next');
0
PhrAtoRCommented:
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
traustiAuthor Commented:
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
PhrAtoRCommented:
if there is no window/button with componentname 'TButton' and Title '&Next' FindWindowEX MUST result 0

0
traustiAuthor Commented:
There is a button with name "next" and the window caption is GetRight Installation the same as parent

what can i do?
0
PhrAtoRCommented:
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
PhrAtoRCommented:
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
PhrAtoRCommented:
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
PhrAtoRCommented:
oops. last comment was posted three times. sorry.
PhrAtoR
0
traustiAuthor Commented:
Where is the program email: emil@vis.is
0
traustiAuthor Commented:
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
PhrAtoRCommented:
just implemant a loop that looks for the next window like this:

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

PhrAtoR
0
PhrAtoRCommented:
don't forget the ; behind the do!
0
traustiAuthor Commented:
What are you meaning?
0
traustiAuthor Commented:
Can you show me some examples with While - DO
0
PhrAtoRCommented:
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
PalamedesCommented:
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
traustiAuthor Commented:
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
PhrAtoRCommented:
i'll test it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.