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

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Basics for Sending Keystrokes with Windows API? (VB API)

    Author
    Topic
    #360961

    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

    Viewing 0 reply threads
    Author
    Replies
    • #545067

      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

      • #545188

        Kevin,

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

        –Llyal

    Viewing 0 reply threads
    Reply To: Basics for Sending Keystrokes with Windows API? (VB API)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: