.NET

Reply
Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 1 of 5 (344 Views)
Accepted Solution

Listen for escape pressed

344 Views, 4 Replies
01-04-2013 02:57 AM

Hi

Is there a way to add a listener so I am told when escape(cancel command) is pressed? I want to create a cancel pressed event.

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)

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 );

 

Moderator
Alexander.Rivilis
Posts: 1,446
Registered: ‎04-09-2008
Message 2 of 5 (321 Views)

Re: Listen for escape pressed

01-04-2013 08:24 AM in reply to: Fredrik.Larsen

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)


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 3 of 5 (274 Views)

Re: Listen for escape pressed

01-07-2013 12:58 AM in reply to: Alexander.Rivilis

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.

Moderator
Alexander.Rivilis
Posts: 1,446
Registered: ‎04-09-2008
Message 4 of 5 (263 Views)

Re: Listen for escape pressed

01-07-2013 02:36 AM in reply to: Fredrik.Larsen

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 );

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 5 of 5 (257 Views)

Re: Listen for escape pressed

01-07-2013 03:11 AM in reply to: Alexander.Rivilis

Thank you very much.

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!