I am trying to perform an action against the new command "Ctrl+N". I need to trigger my code when user press this combination while the form is opened.
I do know that the virtual key code for Ctrl is =>0x11 and fir N=>0x4E.
I have also read about the WM_KEYDOWN and WM_CHAR , and that iParam and wParam are the parameters. But I am just not able to capture the key-strokes.
I have also gone through the link : http://www.agermark.com/2011/04/create-your-own-shortcuts-in-ax-forms.html
But MS Dynamics AX 2012 gives error that "WinApi" is obsolete now.
I have tried to write the code:
void capture()
{
DLL winApiDLL = new DLL('USER32');
DLLFunction getKeyState = new DLLFunction(winApiDLL, 'GetAsyncKeyState');
int result;
getKeyState.returns(ExtTypes::WORD);
getKeyState.arg(ExtTypes::DWORD);
result = getKeyState.call(0x4E); //0x4E == N
if ((result & 0x8000) == 0x8000)
{
info("You have pressed the letter N!");
}
return;
}
But it is not working. Can someone please help me..!
Also please guide me where to put this code...If I am not wrong do we have to put it in the run() method of the Form?