Results 1 to 4 of 4

Thread: sendkeys

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    sendkeys

    Hi everyone.
    I have some questions for you.
    I am working on my application which save work from another application using sendkeys:

    SendKeys.Send("^(s)")
    SendKeys.Send("file")
    SendKeys.SendWait("{ENTER}")



    And it works fine,but my problem is that I don't know why sometimes name of the saved file is "file" and sometimes "ile" and sometimes "e".

    Why??

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sendkeys

    My guess would be that focus changes while the key strokes are being sent. SendKeys works just like typing at the keyboard. If focus changes to a different window while you're typing then your keystrokes are sent to that new window.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: sendkeys

    But I set focus on that application.Probably due to the speed at which the keys are sent. Any other opinion??

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sendkeys

    Try adding a delay before SendKeys.Send and see if it works all the time. If it does then you know that it's a focus issue. This is what developers do: they test things to see whether they work as expected.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width