?
Solved

Very nice question... I have 2 keyboards connected to a computer like distinguishing a key pressed in each one in VB6?

Posted on 2006-06-02
4
Medium Priority
?
291 Views
Last Modified: 2006-11-18

     one keyboard is connected in the ps2 port, and other keyboard in the usb port, because this... good this is for receive the survey of one customer.

   Some can give me one tip of how make this. ??

 Thank you before hand.
0
Comment
Question by:ppenia
  • 2
3 Comments
 
LVL 5

Expert Comment

by:burningmace
ID: 16819013
I would suspect that DirectInput could be used.

You could add the DirectX 7 for VB reference to your project, then define the following:

Dim DX As New DirectX7
Dim DI As DirectInput
Dim DEnum As DirectInputEnumDevices

Then enumerate the keyboards:

Set DI = DX.DirectInputCreate
Set DEnum = DI.GetDIEnumDevices(DIDEVTYPE_KEYBOARD, DIEDFL_ATTACHEDONLY)

You can use DEnum.GetItem(i) to retrieve info on a keyboard, then use DirectX Events to retrieve the keypresses. When the keys are pressed, the GUID passed by the event should be checked against the return value of GetGUIDInstance for each item in DEnum.
0
 

Author Comment

by:ppenia
ID: 16819788

 Thanks burningmace.

   I tried this solution but i have some problems, i type this code..

Dim DX As New DirectX
Dim DI As DirectInput
Dim DEnum As DirectInputEnumDevices

Private Sub Command1_Click()

     MsgBox DEnum.GetCount  ' this return 1 is correct ?????

End Sub

Private Sub Form_Load()

Set DI = DX.DirectInputCreate
Set DEnum = DI.GetDIEnumDevices(DIDEVTYPE_KEYBOARD, DIEDFL_ATTACHEDONLY)


End Sub


  How can evaluate the keypresses in each keyboard with Events DirectX ?
  You can post  one source code more explicit please ?

 Thank you for you assitance and time.

0
 
LVL 5

Accepted Solution

by:
burningmace earned 1500 total points
ID: 16823127
Well if it's only returning 1, then you don't have both keyboards plugged in... either that or there is a problem.

Try switching DIEDFL_ATTACHEDONLY for DIEDFL_ALLDEVICES.

As for doing keyboard events in VB using DirectX, I've not done it before, so I'm not sure.

There's a good lot of code for C++ here: http://www.eastcoastgames.com/directx/intro.html
You just need to sort of "translate it" across to VB.

Another for C++: http://www.experts-exchange.com/Programming/Game_Development/Q_20447173.html

Unfortunately, not many people want to do DirectInput for VB. I can't spot anything decent.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question