Sendkeys in Navision

code-dynamics

With SendKeys you simulate user keystrokes – which mean it is possible to start applications, enter information, choose menus, buttons etc.

SendKeys is a part of Windows Script Host.

Currently I am using this functionality to take over a second Navision Client, to start an export of objects without any user interventions.


In Navision SendKeys are found in the automation Windows Script Host Object Model class WshShell.

The first thing to do is to create the automation:

 cside |  copy code |? 
                                                                                     
IF ISCLEAR(WshShell) THEN
  CREATE(WshShell);
                                                                                     

Activate the application which has to behandled:

 cside |  copy code |? 
                                             
WshShell.AppActivate(AppName);
                                                                                     

And then send the keys:

 cside |  copy code |? 
                                                                                     
WaitForKeys := TRUE;
WshShell.SendKeys('{ESC 2}',WaitForKeys);
WshShell.SendKeys('{DOWN}',WaitForKeys);
WshShell.SendKeys('{LEFT}',WaitForKeys);
WshShell.SendKeys('Ver{ENTER}',WaitForKeys);
                                                                                     

When you are finished sending keys then stop the automation by clearing it:

 cside |  copy code |? 
                                                                                           
CLEAR(WshShell);
                                                                                     

Pretty simple – right :-)

You can leave a response, or trackback from your own site.

Leave a Reply


9 + = sixteen