[VB6] SendKey Pressing ENter?-VBForums
Results 1 to 11 of 11

Thread: [VB6] SendKey Pressing ENter?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    56

    [VB6] SendKey Pressing ENter?

    Im using
    Code:
    Sub Sendkey(text$, Optional wait As Boolean = False)
    
        'wrapper for Sendkeys which does not crash in the IDE under Windows Vista
        Set WshShell = CreateObject("WScript.Shell")
        WshShell.SendKeys text, wait
        Set WshShell = Nothing
    
    End Sub
    and
    Code:
    Sendkey Text1.text
    and so far, it's working. All I want to know, is by using the code provided, how is it possible to send the 'return' key... AKA the 'enter' key.
    Ive tried "{RETURN}", but got an error... Any idea's?
    Thanks.

    EDIT: Thanks anyway guys, but ive got it, and for future reference, it's
    Code:
    Sendkey "~"

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: [VB6] SendKey Pressing ENter?

    You can also use

    Code:
    Sendkeys "{Enter}"

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  3. #3
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [VB6] SendKey Pressing ENter?

    Or:
    Code:
    Sendkeys vbCrLf
    Works most of the time.

  4. #4
    Member
    Join Date
    Aug 2008
    Posts
    39

    Re: [VB6] SendKey Pressing ENter?

    Hi. I didn't get this to work and I really want it to work! Help?
    I saw this program on youtube, but the person who made it did it in a text document! I want to make it in VB6 but the commands he used don't seem to work. I have also tried the things in this thread but they don't seem to work either.

    I have a text box that changes X:
    Code:
    X = text1.text
    Code:
    for i = 1 to X
       sendkey text2.text
       sendkey "{enter}"
    next i
    What am I doing wrong? Do I need all those "wshshell.blabla" for it to work? If so how do I get it working?
    Please give me the full code so that I can copy and paste, thanks.

  5. #5
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [VB6] SendKey Pressing ENter?

    Code:
    x = Val(Text2.Text)
    
    Text2.SelStart = Len(Text2.Text)
    For i = 1 To x
        SendKeys "{enter}"
    Next

  6. #6
    Addicted Member
    Join Date
    May 2007
    Location
    Belgium
    Posts
    156

    Re: [VB6] SendKey Pressing ENter?

    As far as I know you only need the wrapper things in Vista.

  7. #7
    Member
    Join Date
    Aug 2008
    Posts
    39

    Re: [VB6] SendKey Pressing ENter?

    It's okay I got it working on my own.

    Code:
    for i = 1 to text1.text
    Sendkeys text2.text and "{enter}"
    next i

  8. #8
    Member
    Join Date
    Aug 2008
    Posts
    39

    Re: [VB6] SendKey Pressing ENter?

    Okay now I need to know how to make it push "Windows" and "E" at the same time.
    You know, the little picture of the Flag in between CTRL and ALT.

    If you hold the flag and push ""E, "My Computer" will open.

    Please give me the Sendkeys command for pushing Windows and "E" at the same time.

    Thanks

    EDIT:
    How about typing all the names for these buttons: (Or a link to a place where I can find this)

    Windows flag?
    Control?
    Alt?
    F1 - F12?
    Tab?
    Shift?
    Arrow keys?
    Last edited by Divran; Oct 7th, 2008 at 08:19 AM.

  9. #9
    Fanatic Member
    Join Date
    Oct 2007
    Posts
    544

    Re: [VB6] SendKey Pressing ENter?

    how to send alt tab

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,996

    Re: [VB6] SendKey Pressing ENter?

    from msdn
    To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:

    Key Code
    SHIFT +
    CTRL ^
    ALT %


    To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+EC".

    To specify repeating keys, use the form {key number}. You must put a space between key and number. For example, {LEFT 42} means press the LEFT ARROW key 42 times; {h 10} means press H 10 times.

    TAB {TAB}
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  11. #11
    Fanatic Member
    Join Date
    Oct 2007
    Posts
    544

    Re: [VB6] SendKey Pressing ENter?

    Okay.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.