Intercept button click in another application
-
wrote on 30 Jul 2014, 17:08 last edited by
Hi,
The task is: run my code when some button was clicked in another application, let it be calculator.exe
Programming language: Qt 5, but Delphi/C/C++ examples will be ok (because of possible using WinAPI).
OS: WindowsAfter some thinking I have two decisions:
-
Install global dll hook on mouse button click events in calculator window. Create rectangular area that contains necessary button. When mouse button is clicked, check if we get into this area and then run code.
-
Find necessary button (I don't know how yet), substitute window procedure to my own (subclassing), make dll injection (VirtualAllocEx, CreateRemoteThread) with my code that will run if button was clicked.
First way is rough, of course. But window size doesn't change, that's why we need only consider possible window position. Second one is more accurate, but after using Google I have mess in my head about WinAPi, dll, etc. and I don't understand right sequence of actions.
What could you recommend (and maybe another decisions)?
Thanks.
-
-
Hi,
From the looks of it, you are writing a spyware. What is your exact purpose ?
-
wrote on 31 Jul 2014, 09:32 last edited by
[quote author="SGaist" date="1406754781"]Hi,
From the looks of it, you are writing a spyware. What is your exact purpose ?[/quote]
Well, my customer wants to run external applications (scanning, printing, calculator and others) directly from Microsoft Word (at that 2003 version). VBA and macros aren't allowed to use. It's possible to add custom menus to Word, but I don't exactly know how can I intercept mouse click on this menu. I tried WinSpy++ and similar apps, they could find handles for menubars, but not for separate buttons.
1/3