Solved

Simulating Button Click

Posted on 1998-12-30
2
659 Views
Last Modified: 2013-11-20
Is there any way to simulate a button click on a button of a dialog box without waiting for user's input from keyboard.
In other words an automatic button push on a particular button of a dialog box. How does one get the information about each button(handles,identifiers etc)
0
Comment
Question by:NatasBoy
2 Comments
 

Accepted Solution

by:
gatkinso earned 30 total points
ID: 1327000
Use the SendDlgItemMessage function.

SendDlgItemMessage(
     int nID,                              //button id
     UINT message,                  //message to send in this case BM_SETSTATE
     WPARAM wParam = 0,      //TRUE for pressed, FALSE for release
     LPARAM lParam = 0 );       //must be zero

You should know the ID of each button, assuming you wrote the dialog.  However you possibly could use the ::EnumChildWindows  API function to gather info about the control in the dialog
0
 

Author Comment

by:NatasBoy
ID: 1327001
Thanks for putting me on the right track!! I just altered the message to BM_CLICK which simulates a button click. I have also assumed the button id to be IDYES which is the most common for the Save prompt dialog box on exiting an application containing unsaved data. But please tell me how to find the button id in a dialog box which matches a particular string such as 'Yes' or 'Ok'. Also, please explain the EnumChildWindows API you suggested to achieve the above purpose.
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

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
lucky13 challenge 11 158
tripleUp challenge 7 93
Annoying "thing" blocks my view 4 133
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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