How to change company using sendkeys

txantxagorritxantxagorri Member Posts: 23
Hi experts,

I´ve a problem trying to change of company using sendkeys, I´ve tryed this:

wsscript.SendKeys('{&}{F}{M}{O}{DOWN}{ENTER}');

but it doesn´t change the company, it stops on Open Company window

thanks.

Comments

  • garakgarak Member Posts: 3,263
    edited 2008-08-27
    First:

    Here is a list of all keys
    http://www.mibuso.com/forum/viewtopic.php?t=25712

    second:
    if isclear(WSHShell) then
      create(WSHShell);
    
    WSHShell.SendKeys('%f');
    
    WSHShell.SendKeys('m');
    
    WSHShell.SendKeys('o');
    
    //beep(1203,200); or an another  WSHShell.SendKeys('{DOWN}');
    WSHShell.SendKeys('{DOWN}');
    
    WSHShell.SendKeys('{ENTER}');
    clear(WSHShell);
    

    EDIT:
    the reason why Sendkeys doesn't work: The windows need some time to display. Bute the keys are already send. But there is not window to get the keystroke ;-) so, use beep(Requence,Duration) or split your WSH Code ...

    Regards
    Do you make it right, it works too!
  • kinekine Member Posts: 12,562
    try to send the sequence in two parts divided with sleep (as described in http://www.mibuso.com/forum/viewtopic.php?t=27784). Or you can try to divide the sequence with BEEP function (see http://dynamicsuser.net/blogs/kine/arch ... -beep.aspx).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • fverkelfverkel Member Posts: 66
    Tip: use ShortCutKeys when possible. That reduces problems when using more than one language, or when upgrading to a different version of NAV.
    ShortCut for opening a company: Ctrl+O.
    WSHShell.SendKeys('^o')
    
    Keep It Simple and Stupid (KISS), but never oversimplify.
  • DaveTDaveT Member Posts: 1,039
    Hi,

    you are relying on the companies remaining in the same order - sending the company name and an extra enter is probably safer
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • txantxagorritxantxagorri Member Posts: 23
    the beep function doesn´t work. the problem is that the open company window opens after getting the last sendkey, so it doesn´t execute the sendkey('{ENTER}')
  • nvermanverma Member Posts: 396
    is there a way to have the sendkeys work when enter is pressed all alone.

    CREATE(wscript);
    wscript.SendKeys('{~}');
    wscript.SendKeys('{~}');
    CLEAR(wscript);
    

    This does not seemt to work. I have also tried putting the word "ENTER" instead of "~"...that didnt work aswell.
  • SavatageSavatage Member Posts: 7,142
    edited 2012-04-11
    nverma wrote:
    is there a way to have the sendkeys work when enter is pressed all alone.
    CREATE(wscript);
    wscript.SendKeys('{~}');
    wscript.SendKeys('{~}');
    CLEAR(wscript);
    
    This does not seemt to work. I have also tried putting the word "ENTER" instead of "~"...that didnt work aswell.

    Your question doesn;t make any sence.
    You want the system to send an enter request using send keys when pressing enter?
    If you are pressing enter in the first place then there is no need for sendkeys to send an enter request?

    We use Sendkeys in a few parts of nav right now.
    One is autoopening the Apply Vendor Entries form after entering a vendor number. Instead of having to click Functions->Apply Entries.
    OnAfterValidate() //of "Account No."
    AutoOpenPaymentEntries; //run custom function
    
    AutoOpenPaymentEntries() //custom function
    PurchSetup.GET;
    IF PurchSetup."Auto Open Payment Journal" THEN BEGIN
      CREATE(WshSHell);
      WshSHell.SendKeys('+{f9}');
      CLEAR(WshSHell);
    END;
    

    Can you explain your use for it?
  • nvermanverma Member Posts: 396
    the reason I am trying to do this is because I want the Remaining Balance from my last post to calculate every time the user presses enter.

    This code is under trigger Remaining Balance -- OnAfterValidate ().

    Right now it only updates the remaning balance field if i click on the form itself. I want it to automatically update it. Therefore, i was trying to do it using sendkeys (either when user presses enter or tab).

    Another solution that i have tried was using OnTimer trigger (that wasnt very appealing since it would annoy the user)
  • SavatageSavatage Member Posts: 7,142
    You should review your code & steps.
    On my forms when I enter a value the field update immediately.

    Here's even another example of totaling and updating immedately.
    viewtopic.php?f=23&t=45905

    Did you look at deposits?
Sign In or Register to comment.