web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get virtual-keyboard input in AX

(0) ShareShare
ReportReport
Posted on by

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?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Ctrl+N is already used for creating new records. Either that's the action you want, and then simply override create() method on the datasource. Or it's not what you want and you should look for some other combination.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    although Ctrl+N is being used for new records. Yet, you have choice to perform your additional tasks with same command. all you need to do is to override a method on form named as Task()

    The code will be somewhat like following

    public int task(int _taskId)
    {
        int ret;
    
        ret = super(_taskId);
        
        if(_taskId == 2840)
        {
            info("Hi! you are going to create a New record.");
        }
    
        return ret;
    }


     You may capture any taskId based on your needs. you can see list of task inside Macro Task

    AOT >> Macros >> Task

  • Community Member Profile Picture
    on at

    Thanks for replying Martin...Yes I know Ctrl+N is used for creating new records ... But I need to perform a check before a new record is being created and that is why i need to capture the key-stroke combination .  

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Well, I would still say that overriding create() is the best solution.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans