This way can help you:How to implement a Windows Hook using acedRegisterFilterWinMsg in .NET
In WindowHookProc event handler you can check msg.Msg == WM_KEYDOWN (0x0100) and msg.WParam == VK_ESCAPE (0x1B)
Thanks, that seems to work, but how do you unregister the listener? When escape is pressed I want to do something and then unregister the listener.
In order to unregister this event handler use function acedRemoveFilterWinMsg:
BOOL acedRemoveFilterWinMsg( const AcedFilterWinMsgFn pfn );
In C# it is look like:
// For AutoCAD 2013 64 bit // On previous versions, import from acad.exe (instead accore.dll) [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acedRemoveFilterWinMsg@@YAHQ6AHPEAUtagMSG@@@Z@Z"
)] private static extern int acedRemoveFilterWinMsg( WindowHookProc callBackFunc );
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register