Results 1 to 8 of 8

Thread: [RESOLVED] Sendkeys error

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Sendkeys error

    This code:
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     If KeyAscii = vbKeyReturn Then
    3.         KeyAscii = 0
    4.         SendKeys "{TAB}"
    5.     End If
    6. End Sub
    works perfectly under Windows XP but produces the error in the attached image when I run the app (in the IDE) under Windows 7. Any ideas why?
    Attached Images Attached Images  
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Sendkeys error

    In the FAQ section, there is a topic regarding SendKeys and Vista (should apply to Win7 also)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Sendkeys error

    Quote Originally Posted by LaVolpe View Post
    In the FAQ section, there is a topic regarding SendKeys and Vista (should apply to Win7 also)
    All right, it says "replace Sendkeys" by API code. Can you remember the appropriate function call required?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Sendkeys error

    Quote Originally Posted by krtxmrtz View Post
    All right, it says "replace Sendkeys" by API code. Can you remember the appropriate function call required?
    There are two that I know of: 1) keybd_event 2) SendInput
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    New Member
    Join Date
    Feb 2012
    Location
    SK, Canada
    Posts
    10

    Re: Sendkeys error

    Try the code at http://vb.mvps.org/samples/ , about 1/2 way down the page called SendInput.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Sendkeys error

    Interestingly this was supposedly "fixed" by a patch to the VB6 runtime. It still fails in the IDE, but should work in a compiled EXE.

    However... an EXE compiled using Sendkeys on my machine is flagged as a virus by AVG, as soon as I compile it.

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Sendkeys error

    Quote Originally Posted by LaVolpe View Post
    There are two that I know of: 1) keybd_event 2) SendInput
    I've tried them both and they work fine. Thanks.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  8. #8

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Sendkeys error

    Quote Originally Posted by dac999 View Post
    Try the code at http://vb.mvps.org/samples/ , about 1/2 way down the page called SendInput.
    Thank you, I used the module included there and works perfect. However I think I'd rather use keyb_event, it just requires 3 extra lines -function declaration plus 2 constants.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

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