Solved

Simulating Button Click

Posted on 1998-12-30
2
654 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 65
fizzArray2 challenge 1 72
Fibonacci challenge 11 108
mapAB Challlenge 35 123
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now