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
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.
Question by:ppenia
    LVL 5

    Expert Comment

    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

    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.

    Author Comment


     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

    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.

    LVL 5

    Accepted Solution

    Well if it's only returning 1, then you don't have both keyboards plugged in... either that or there is a problem.


    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:
    You just need to sort of "translate it" across to VB.

    Another for C++:

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now