Link to home
Start Free TrialLog in
Avatar of GoldStone32767
GoldStone32767

asked on

Send Mouse Click to DirectX app

Im trying to send a mouse click to a certain area in a directx game. Generating a mouse click in any other app (not DX) works fine with this code:

 Call PostMessage(CLng(param(1)), WM_LBUTTONDOWN, 1, CLng(param(2)) + CLng(param(3)) * &H10000)
            Call PostMessage(CLng(param(1)), WM_LBUTTONUP, 1, CLng(param(2)) + CLng(param(3)) * &H10000)

I even used Spy++ and the MouseClicks do not register. MouseMove and KeyPress all come through, but mouse clicks dont.

Any idea how i can generate a mouseclick on a DX app. thx
Avatar of MaxPol
MaxPol

The issue is how the mouse click event is handled by the DX application.
If it is via the DIRECTINPUT device, that the event will not be got and thus handled.

Bye,

Max
Public objDX As New DirectX8
Public objDI As DirectInput8
Set objDIDev = objDI.CreateDevice("guid_SysMouse")
Call objDIDev.SetCommonDataFormat(DIFORMAT_MOUSE)
Call objDIDev.SetCooperativeLevel(frmCanvas.hwnd, _
        DISCL_FOREGROUND Or DISCL_EXCLUSIVE)
You need DIRECTINPUT Class Functions to handle mouse events in your game.
ASKER CERTIFIED SOLUTION
Avatar of amp072397
amp072397

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial