CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: SendInput Api

  1. #1
    Join Date
    Jan 2000
    Location
    Belgium
    Posts
    4

    SendInput Api

    Can someone give me an example of how the SendInput Api works?

    I'm not used to work with API's.

    I want to activate the Numlock automatically set enabled on startup of Access-DB.

    Thanks


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: SendInput Api

    this is sample code from MSDN:


    ' Declare Type for API call:
    private Type OSVERSIONINFO
    dwOSVersionInfoSize as Long
    dwMajorVersion as Long
    dwMinorVersion as Long
    dwBuildNumber as Long
    dwPlatformId as Long
    szCSDVersion as string * 128 ' Maintenance string for PSS usage
    End Type

    ' API declarations:

    private Declare Function GetVersionEx Lib "kernel32" _
    Alias "GetVersionExA" _
    (lpVersionInformation as OSVERSIONINFO) as Long

    private Declare Sub keybd_event Lib "user32" _
    (byval bVk as Byte, _
    byval bScan as Byte, _
    byval dwFlags as Long, byval dwExtraInfo as Long)

    private Declare Function GetKeyboardState Lib "user32" _
    (pbKeyState as Byte) as Long

    private Declare Function SetKeyboardState Lib "user32" _
    (lppbKeyState as Byte) as Long

    ' Constant declarations:
    Const VK_NUMLOCK = &H90
    Const VK_SCROLL = &H91
    Const VK_CAPITAL = &H14
    Const KEYEVENTF_EXTENDEDKEY = &H1
    Const KEYEVENTF_KEYUP = &H2
    Const VER_PLATFORM_WIN32_NT = 2
    Const VER_PLATFORM_WIN32_WINDOWS = 1


    private Sub Command1_Click()
    Dim o as OSVERSIONINFO
    Dim NumLockState as Boolean
    Dim ScrollLockState as Boolean
    Dim CapsLockState as Boolean

    o.dwOSVersionInfoSize = len(o)
    GetVersionEx o
    Dim keys(0 to 255) as Byte
    GetKeyboardState keys(0)

    ' NumLock handling:
    NumLockState = keys(VK_NUMLOCK)
    If NumLockState <> true then 'Turn numlock on
    If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then '=== Win95/98

    keys(VK_NUMLOCK) = 1
    SetKeyboardState keys(0)
    ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT then '=== WinNT
    'Simulate Key Press
    keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
    'Simulate Key Release
    keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY _
    Or KEYEVENTF_KEYUP, 0
    End If
    End If






  3. #3
    Join Date
    Jan 2000
    Location
    Belgium
    Posts
    4

    Re: SendInput Api

    You don't now how you helped me with this.

    Thousand times ,Thanks.

    DJ


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

Featured