Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Grabbing Button Presses

Posted on 1998-06-09
Medium Priority
Last Modified: 2010-04-10
I need to be able to grab/intercept button clicks from a third party application.  So that I can record them & replay the same sequence at a later time.
Question by:DanielJenkins
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 22

Expert Comment

ID: 1165503
answer coming.
LVL 22

Expert Comment

ID: 1165504
You need to use a system hook.  A system hook allows a procedure in a DLL (not EXE) to be notified when various events happen in the system, one of which is mouse clicks (I assume by button you mean mouse button).  

Look at the documentation for SetWindowsHookEx()  This is the function that allows you to create the hook.  If you have any questions after reading the documentation, let me know.

Author Comment

ID: 1165505
I have tired using a system hook, but not enough informaion is returned.
I need to be able to track which button has been click either on a toolbar, the mouse, or Menu items.

ie. If someone clicks on the OK, Cancel, Next, or Previous buttons.
Independent Software Vendors: 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!

LVL 22

Accepted Solution

nietod earned 300 total points
ID: 1165506
You can use WindowFromPoint() to find the window that was under the mouse.
LVL 22

Expert Comment

ID: 1165507
That gives you the window handle to the window that was clicked.  What you'll do next will depend on what you are actually tryng to do.  (I'm not sure what that is)  I can help you with that, probably, but you have to give me some idea of the goal.  All you asked so far was how to get/intercept the button clicks in another application.  Which I answered, but I'm not sure where you want to go with that.

Author Comment

ID: 1165508
I need to be able to record each commands from any application, such as the calculator, and send the commands to another computer and replay the recorded command on the remote computers calculator.
LVL 22

Expert Comment

ID: 1165509
First of all.  You should not accept an answer until you are certain it is complete and going to work.  I remind clients of that often just in case.  But this time I'm saying it because I'm not sure how much more help I can give you.

You are going to have a very hard time "translating" the information from one computer to the other.  You can find out the window handle of the window that was pressed on the local computer, but that can't be used on the remote computer.  There are some possibilities, though.

Do you have any windows that necessarily correspond between the two computers.  Like is there is one paticular application that is being used on both computers and that the information must be translated between, or is this stuff that must work with every window currently present?  (If so what happens when there isn't a corrseponding window?)
Do you know if the windows will be at the same coordinates?  Or what information do you know that is the same between the two computers?

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

670 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