Solved

Capture All Windows messages

Posted on 1998-10-28
4
823 Views
Last Modified: 2010-04-03
How can I catch all Windows messages?
For example , my active window is Microsoft Word
and when I click on it I want to catch this message
with my DELPHI program, which is not active in this moment.
0
Comment
Question by:jpenev1
  • 2
4 Comments
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
jpenev1

you can use the SetWindowsHook and SetWindowsHookEx to trap the messages, check the win32.hlp file....

Later
BoRiS
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 30 total points
Comment Utility
You should use Hooking.
Download this example on hooking keyboard messages, and try to conclude from this on all messages:     ftp://delphiexchange.com/pub/offers/keyhook.zip

0
 
LVL 1

Expert Comment

by:AndersWP
Comment Utility
You could do this with the SetWindowsHookEx API function. SetWindowsHookEx takes 4 parameters:
idHook: Should be set to WH_CALLWNDPROC
hkprc: Address of function to be called when a message is caught (callback function).
hMod: This should be set to the value of the hInstance variable of your Delphi Application
dwThreadID: ID of the thread you want to hook messages for. Setting this to 0 lets you hook ALL messages.
The function returns a hook handle that you will need when you remove the hook with the
UnhookWindowsHookEx function.

The callback function should be declared like this:

Function MyCallbackFunc(nCode: Integer; wParam, lParam: DWord): Integer;

Remember in your callback function to:
a: return 0 as the function result
b: Call CallNextHookEx to give other hooks a chance to look at the message.

I hope this will help you,
AndersWP
0
 
LVL 1

Expert Comment

by:AndersWP
Comment Utility
I forgot to say that your callback function must be declared with the StdCall directive, and that it must be a global function (not an object method, not a local function declared within another function).

AndersWP
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

10 Experts available now in Live!

Get 1:1 Help Now