Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Basics for Sending Keystrokes with Windows API? (VB API)

    Basics for Sending Keystrokes with Windows API?

    I am unclear about sending keystrokes with the windows API; I read Dan Appleman's Win32 API book chapter regarding this and looked at the example app (which did not fully function on Windows 2000), but I scratch my head; Can someone offer me the basics to get me going or maybe show me a web link so I can learn more?

    Thank you!

    --Llyal

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Basics for Sending Keystrokes with Windows API? (VB API)

    Here's are the steps to using the API to press the Print Screen key:

    1) Declare the function (at the top of the module):

    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
    bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

    2) Set any constants you want to their key hex values:

    Private Const VK_SNAPSHOT = &H2C
    Private Const KEYEVENTF_KEYUP = &H2
    Private Const VK_MENU = &H12

    3) Call the function in your code:

    keybd_event VK_SNAPSHOT, 0, 0, 0
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Basics for Sending Keystrokes with Windows API? (VB API)

    Kevin,

    Thanks; once I learned that the keycodes were Hex values, using this API lib became a snap;

    --Llyal

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Basics for Sending Keystrokes with Windows API? (VB API)

    Do you need the virtual-key code list?

    <A target="_blank" HREF=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/vkeys_529f.asp>Try Here</A>
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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