sendkeys???

krazy89krazy89 Member Posts: 30
hey everyone...

i've been trying to get a report to go straight into preview with the sendkeys command:


SalesHead.SETFILTER("No.","No.");
PickTicket.SETTABLEVIEW(SalesHead);
PickTicket.RUN;

CREATE(WshShell);
WshShell.SendKeys('%{v}');
CLEAR(WshShell);


this should send the PickTicket report straight into preview mode without user input... but the funny part is... this works on my computer... but when i goto another computer in the local network.. and try it on our test db... it doesn't work... it stops on the report dialog and waits for user input to either print/preview... this is really weird...

one guess is that it might be because of the language option... but his hotkey is 'v' also... same as mine...

so i really don't understand it... if anyone has any idea.. please let me know!!!

Thanks,

KraZy
KraZy

Comments

  • SLF25SLF25 Member Posts: 37
    Why don't you use REPORT.RUN(parameters)?
  • ara3nara3n Member Posts: 9,256
    You are probably running the send key too early.
    Put the code in the onopenform of the sections or wait a few seconds like using the beep function .
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • krazy89krazy89 Member Posts: 30
    hey guys...

    as for the Report.RUN(Parameters); --> that will automatically send the report to the printer.. which is NOT what i want... i only want it previewed... and not printed...

    as for the sending it too soon --> the weird part is.. it works on my computer... but when i goto another computer on the local network, it doesn't work... i don't understand why it has 2 different responses to the same command?!?!?

    KraZy
    KraZy
  • SavatageSavatage Member Posts: 7,142
    ara3n wrote:
    You are probably running the send key too early.
    Put the code in the onopenform of the sections or wait a few seconds like using the beep function .

    See Here:
    http://dynamicsuser.net/blogs/kine/arch ... -beep.aspx
  • krazy89krazy89 Member Posts: 30
    Hey guys....

    i tried putting in a

    BEEP(440,100);

    command before the sendkeys command... but still doesn't work for 1 particular laptop that's connected to the network...

    the laptop is currently using MS Media Centre ver 2002...

    don't know if that makes a difference or not???

    Thanks,

    KraZy
    KraZy
  • kinekine Member Posts: 12,562
    adn the beep sound you hear before the report request form appear or after that?

    And another thing - check the language of the client. May be he is using another language and the hotkey for the Preview button is another...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krazy89krazy89 Member Posts: 30
    hmm.. that's the funny part...

    on his laptop... i don't hear a beep at all... on my desktop... i hear the beep... and everything is good... goes straight to the preview page...

    on another desktop that's on the local network... it also works fine... i hear the beep.. and then straight to preview page...

    only on his laptop that it doesn't work...

    he's also on english.. as his preview hotkey is 'v'.. so that shouldn't be the problem...

    Any other ideas??

    KraZy
    KraZy
  • kinekine Member Posts: 12,562
    Is there difference in used OS? (e.g. Vista)

    Has the notebook some sound card? On some notebooks you can hear the beep from the soundcard, not from the speaker (notebooks do not have one :-)).

    And you can try longer beep time or add sleep command before it...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krazy89krazy89 Member Posts: 30
    hey Kine...

    the laptop does have a sound card.. that shouldn't be the issue...

    as for operating systems... the desktops here use win xp pro... the laptop uses ms media centre ver 2002... (which might be the problem!!??)

    i'll try using the SLEEP command before the beep... but i'm guessing that won't work either... but i'll try it and let you know..

    Thanks,

    KraZy
    KraZy
  • SLF25SLF25 Member Posts: 37
    I guess either the timing is wrong or the sendkey doesn't work like it should on that machine.
    I would write some code with different keys sent to eliminate the latter.
  • jpjesusjpjesus Member Posts: 45
    You should use a Timer in order to make it work and adjust it as needed


    1. The timer interval should be set to a range between 10 - 100 ms

    2. http://msdn2.microsoft.com/en-us/librar ... dkeys.aspx

    The SendKeys class is susceptible to timing issues,
    which some developers have had to work around.
    The updated implementation is still susceptible to timing issues,
    but is slightly faster and may require changes to the workarounds.
    The SendKeys class tries to use the previous implementation first,
    and if that fails, uses the new implementation. As a result, the
    SendKeys class may behave differently on different operating systems.
    Additionally, when the SendKeys class uses the new implementation,
    the SendWait method will not wait for messages to be processed when
    they are sent to another process.


    Take a look at this example code:


    <Control1102053039> - OnPush()
    IF CONFIRM(Text100001,FALSE,"User ID") THEN BEGIN

    IF ISCLEAR(WSH) THEN
    CREATE(WSH);

    IF ISCLEAR(Timer) THEN
    CREATE(Timer);

    Timer.Interval(100);
    Timer.Enabled(TRUE);

    END;

    Timer::Timer(Milliseconds : Integer)
    WSH.SendKeys('%{F4}');



    Hope it helps.
    Cheers
Sign In or Register to comment.