[Lazarus] Detecting the start of a service and simulate a click in the yes button of its window

Michael Van Canneyt michael at freepascal.org
Sat Mar 6 10:46:25 CET 2010



On Sat, 6 Mar 2010, "Arí Ricardo Ody" wrote:

> 
>  
> 
> I would like to know if it's possible to make a program to detect if a service has started in windows. If affirmative this service shows a
> window and I must to simulate a click on the “yes” button of this same window, e.g, the program will think that someone click yes in the
> windows it shows when it starts.
> 
> 
> Is it possible to do a program with Lazarus or FPC that solves this problem? If affirmative may someone send me an example of how to do
> this?

You can use the TServiceManager component to detect whether a service runs.
I have coded this component, it is in active use in commercial projects.

But there is a strange thing about your story: as of Windows Vista, service
applications can no longer display a window on the desktop, Windows no longer
allows that. So probably, the window is displayed by some other program that
comes with the service ?

You can send a keypress to this program's window with the FindWindow call to
get the handle and then use a PostMessage() call to send a click or keypress.

Michael.


More information about the Lazarus mailing list