Click to See Complete Forum and Search --> : SendInput Api


Salsito
January 17th, 2000, 08:45 AM
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

Lothar Haensler
January 17th, 2000, 09:01 AM
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

Salsito
January 18th, 2000, 03:03 AM
You don't now how you helped me with this.

Thousand times ,Thanks.

DJ