Results 1 to 5 of 5

Thread: Press enter with api?[Solved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2003
    Location
    Greece, Salonica
    Posts
    473

    Press enter with api?[Solved]

    Hi.
    Is there a way i can press the enter button on the keyboard with api?
    I know i can do:
    VB Code:
    1. SendKeys "{ENTER}", True
    but this might not always work...
    So do you know a way to press enter with api?

    Thanks!
    Last edited by mike2; Apr 6th, 2004 at 01:16 AM.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    The keyb_event API... Here's an example :

    VB Code:
    1. Const VK_H = 72
    2. Const VK_E = 69
    3. Const VK_L = 76
    4. Const VK_O = 79
    5. Const KEYEVENTF_EXTENDEDKEY = &H1
    6. Const KEYEVENTF_KEYUP = &H2
    7. Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    8. Private Sub Form_KeyPress(KeyAscii As Integer)
    9.     'Print the key on the form
    10.     Me.Print Chr$(KeyAscii);
    11. End Sub
    12. Private Sub Form_Paint()
    13.     'KPD-Team 2000
    14.     'URL: [url]http://www.allapi.net/[/url]
    15.     'E-Mail: [email][email protected][/email]
    16.     'Clear the form
    17.     Me.Cls
    18.     keybd_event VK_H, 0, 0, 0   ' press H
    19.     keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0   ' release H
    20.     keybd_event VK_E, 0, 0, 0  ' press E
    21.     keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0  ' release E
    22.     keybd_event VK_L, 0, 0, 0  ' press L
    23.     keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0  ' release L
    24.     keybd_event VK_L, 0, 0, 0  ' press L
    25.     keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0  ' release L
    26.     keybd_event VK_O, 0, 0, 0  ' press O
    27.     keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0  ' release O
    28. End Sub

    Now all you need to do is find the constant for "Enter"


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Turns out this works :

    VB Code:
    1. keybd_event vbKeyReturn, 0, 0, 0
    2.     keybd_event vbKeyReturn, 0, KEYEVENTF_KEYUP, 0


    Has someone helped you? Then you can Rate their helpful post.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2003
    Location
    Greece, Salonica
    Posts
    473
    Hmm...
    Thanks.
    This will probably work because the example worked!
    Thanks

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

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