VB6 - USBHID. Reading Data from USB HID Keyboard Device.
- From: Yasabu <Yasabu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 22 Aug 2008 08:37:39 -0700
Allo!
I am attempting to view data sent to my computer via my keyboard (To control
the extra multimedia functions [e.g. volume control] because it doesn't seem
to do anything. [Not the reason for this question])
Ho'kay, I'm am using Visual Basic 6.0 on a Windows Vista PC.
Basically, what I will try to end up doing, is when I use the functions,
it'll control Winamp, I already have code for controlling Winamp though, but
can't quite seem to get the keyboard data.
My current code, goes thusly;
* Module1
1 Public Type SECURITY_ATTRIBUTES
2 nLength As Long
3 lpSecurityDescriptor As Long
4 bInheritHandle As Long
5 End Type
6
7 Public Type OVERLAPPED
8 Internal As Long
9 InternalHigh As Long
10 offset As Long
11 OffsetHigh As Long
12 hEvent As Long
13 End Type
14
15 Public Const GENERIC_READ = &H80000000
16 Public Const GENERIC_WRITE = &H
17 Public Const OPEN_EXISTING = 340000000
* Form1
1 Dim longbuffer As Long
2 Dim HidName$
3 Dim result
4 Dim OverLap As OVERLAPPED
5
6 Private Sub Form_Load()
7 Dim Security As SECURITY_ATTRIBUTES
8 Security.nLength = 12&
9 Security.lpSecurityDescriptor = 0&
10 Security.bInheritHandle = False
11 Text1.Text = ""
12 Timer1.Interval = 1
13 HidName$ =
"\\?\hid#vid_413c&pid_2010&mi_01&col03#8&1b0ad425&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}"
14 result = CreateFile( _
15 HidName$, _
16 GENERIC_READ, _
17 0, _
18 Security, _
19 OPEN_EXISTING, _
20 0, _
21 0)
22 End Sub
23
24 Private Sub Timer1_Timer()
25 Dim feedme As String
26 feedme = ReadFile(result, 1, 1, 0, OverLap)
27 If feedme <> 0 Then Text1.Text = Text1.Text & feedme
28 End Sub
I think I got the 'HidName$' variable right, I've never attempted this before.
Hope someone can help me with this and I thank you all in advance!
.
- Follow-Ups:
- Re: VB6 - USBHID. Reading Data from USB HID Keyboard Device.
- From: Mike Williams
- Re: VB6 - USBHID. Reading Data from USB HID Keyboard Device.
- Prev by Date: Re: Multiple Threads
- Next by Date: Re: VB6 and Beyond
- Previous by thread: Cartier Calisson Diamond 18kt White Gold Ladies Watch WJ303050
- Next by thread: Re: VB6 - USBHID. Reading Data from USB HID Keyboard Device.
- Index(es):
Relevant Pages
|