🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Dubhglas Mon, 05 May 2003 09:49
Click a button on another application
#16673
Author: Dubhglas
Date: Mon, 05 May 2003 09:49
35 lines
2176 bytes
Hello everybody,

Someone bought a software which detects phone calls (used to charge the
appropriate share of costs among several companies in the same building).
Now, I'd like to shut down that PC after, say, a couple of hours after
closing time (just in case someone stays a little later).

Problem is, I don't have access to the programmer who made it, and the
buttons have <no> shortcut (grr...)

I have been able to bring the program into focus, move the mouse over the
button(s) (after checking the resolution being used) and use a mouse_event
etc.
Something like this (details omitted):

HWND Otherwindow;
Otherwindow=FindWindow("Telephone", NULL);
SetForegroundWindow(Otherwindow);
SetFocus();
----

mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, (65535/1240*100),
(65535/1024*200), 0, 0);
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN, (65535/1240*100),
(65535/1024*200), 0, 0);
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTUP, (65535/1240*100),
(65535/1024*200), 0, 0);


However, that's far from an "elegant" solution. Isn't there a way to
"address" a button (not a window) in another application? If there is, and
if I don't ask too much, does anyone also know the syntax to use?

TIA
Re: Click a button on another application
#16677
Author: Timothy H. Buchman
Date: Mon, 05 May 2003 11:48
18 lines
1800 bytes
Dubhglas <info_remove> wrote in message
news:3eb633b0$1@newsgroups.borland.com...
> However, that's far from an "elegant" solution. Isn't there a way to
> "address" a button (not a window) in another application? If there
is, and
> if I don't ask too much, does anyone also know the syntax to use?

Here's a fine comprehensive answer by Gambit:
http://groups.google.com/groups?selm=98obat%24lp8%40bornews.inprise.co
m&output=gplain

(long link-last characters are ..."gplain")
--
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Search .borland message archive on http://www.mers.com/searchsite.html
Re: Click a button on another application
#16538
Author: Dubhglas
Date: Mon, 05 May 2003 16:10
25 lines
1741 bytes
Thanks Timothy!
But - how can I get the handle of that button? As you know, it's in a
third-party application.




> > However, that's far from an "elegant" solution. Isn't there a way to
> > "address" a button (not a window) in another application? If there
> is, and
> > if I don't ask too much, does anyone also know the syntax to use?

>
> Here's a fine comprehensive answer by Gambit:
> http://groups.google.com/groups?selm=98obat%24lp8%40bornews.inprise.co
> m&output=gplain
>
> (long link-last characters are ..."gplain")
> --
> Timothy H. Buchman
> ========================================
> City Center Theater, New York NY
> mail address tbuchmanPLEASE(at sign)REMOVEcitycenter.org
> Search .borland message archive on http://www.mers.com/searchsite.html
>
Re: Click a button on another application
#16533
Author: Remy Lebeau (TeamB)
Date: Mon, 05 May 2003 16:35
17 lines
1745 bytes
"Timothy H. Buchman" <tbuchmanPLEASE(at sign)REMOVEcitycenter.org> wrote in
message news:3eb64fa0$1@newsgroups.borland.com...

> Here's a fine comprehensive answer by Gambit:

Not quite as conprehensive as needed - it doesn't explain how to obtain the
HWND for the button in the first place.  You have to do that first before
you can do anything else with it.  Use FindWindow() to get the HWND for the
main window of the application, and then either EnumChildWindows() or
GetDlgItem() to get the HWND of the particular button on that window.  In
the case of GetDlgItem(), however, you need to know the button's ID first,
which you can obtain beforehand using spy tools likw Borland's WinSight or
Microsoft's Spy++ utilities, and then hard-code that ID into your code.


Gambit
Re: Click a button on another application
#16539
Author: Dubhglas
Date: Tue, 06 May 2003 09:43
34 lines
2096 bytes
Excellent! It works perfectly!
I used GetDlgItem because I am not very familiar with EnumChildWindows.

Thank you so much for your help!





"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3eb6927d$1@newsgroups.borland.com...
>
> "Timothy H. Buchman" <tbuchmanPLEASE(at sign)REMOVEcitycenter.org> wrote
in
> message news:3eb64fa0$1@newsgroups.borland.com...
>
> > Here's a fine comprehensive answer by Gambit:
>
> Not quite as conprehensive as needed - it doesn't explain how to obtain
the
> HWND for the button in the first place.  You have to do that first before
> you can do anything else with it.  Use FindWindow() to get the HWND for
the
> main window of the application, and then either EnumChildWindows() or
> GetDlgItem() to get the HWND of the particular button on that window.  In
> the case of GetDlgItem(), however, you need to know the button's ID first,
> which you can obtain beforehand using spy tools likw Borland's WinSight or
> Microsoft's Spy++ utilities, and then hard-code that ID into your code.
>
>
> Gambit
>
>
Re: Click a button on another application
#16596
Author: Dubhglas
Date: Thu, 08 May 2003 14:53
50 lines
2516 bytes
Well, as a matter of fact, I found HAD to resort to EnumChildWindows()
because the button's ID appears to change every time the program is run...
Anyway, it works!

Thanks again!


"Dubhglas" <info_remove@pixel-gc.com> wrote in message
news:3eb783a9@newsgroups.borland.com...
>
> Excellent! It works perfectly!
> I used GetDlgItem because I am not very familiar with EnumChildWindows.
>
> Thank you so much for your help!
>
>
>
>
>
> "Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
> news:3eb6927d$1@newsgroups.borland.com...
> >
> > "Timothy H. Buchman" <tbuchmanPLEASE(at sign)REMOVEcitycenter.org> wrote
> in
> > message news:3eb64fa0$1@newsgroups.borland.com...
> >
> > > Here's a fine comprehensive answer by Gambit:
> >
> > Not quite as conprehensive as needed - it doesn't explain how to obtain
> the
> > HWND for the button in the first place.  You have to do that first
before
> > you can do anything else with it.  Use FindWindow() to get the HWND for
> the
> > main window of the application, and then either EnumChildWindows() or
> > GetDlgItem() to get the HWND of the particular button on that window.
In
> > the case of GetDlgItem(), however, you need to know the button's ID
first,
> > which you can obtain beforehand using spy tools likw Borland's WinSight
or
> > Microsoft's Spy++ utilities, and then hard-code that ID into your code.
> >
> >
> > Gambit
> >
> >
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads