Solved

Simulating Button Click

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
viewing source code from eclipse 13 107
withoutTen challenge 14 122
FizzBuzz challenge 9 81
Line meaning 9 86
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

778 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