[VB6] Simulating keystokes and focus issues (virtual game pad for tablet UPC)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: [VB6] Simulating keystokes and focus issues (virtual game pad for tablet UPC)

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Posts
    1

    [VB6] Simulating keystokes and focus issues (virtual game pad for tablet UPC)

    This is the situation.

    I'm working on a virtual game pad to be controlled by a mouse (or more likely a touch screen on a tablet UPC). I started working on it 2 days ago and it is nearing completion and works exactly as I had hoped except for one issue.

    I'm using the keybd_event API to simulate keystrokes on the target application. It does the job rather well, except for the fact that keybd_event requires focus on the target in order for it to work, and with the application I've used for testing (Project64 1.6) and assumedly other applications, the keys that are simulated are lost every time the target application loses focus, which happens quite a lot, in fact every time the virtual pad is clicked to press another button.

    This isn't an issue in most cases, however if a virtual button has been set to hold down (by clicking on it and dragging away), clicking anything else will make that key get released, at least until it resends all of the ones that are supposed to be held down. Even then it isn't always an issue, but for example if I'm using it to play Mario Kart and I want to hold down a banana behind me, as soon as I try to steer or anything else it will be let go.

    So what I'm asking is, does anybody have a possible solution to this problem? E.g. a way to send keys to an application that doesn't have focus (I've tried PostInput to each of the 4 classes in Project64 to no avail, though it was working in Notepad edit...may work with some outside insight), a way to prevent the keystrokes being lost when the target loses focus, a way to prevent the target form from ever losing focus, or to prevent the game pad form from getting focus, but still being able to click the controls on it (even if it means I have to get the status of the mouse with a timer and use its x/y coords and clicking status to create my own click event).

    Source is attached
    I apoligize for the mess that the code and documentation is, I'm far from professional.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center