PlatformInvoke SendInput method - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


PlatformInvoke SendInput method

ZeekfordZeekford Posts: 1Member

For my bachelor project I need a simple PlatformInvoke on the SendInput function, from the Windows API. The problem is, I don't know if I did it correctly, since all other PlatformInvokes work, but this one returns 0 (error). The only thing I need it for is to simulate the scroll-wheel on the mouse...If there's another way, plz let me know...

This is what I've got at this point:

unsafe internal static extern uint SendInput(uint nInputs, IntPtr inputs, int cbSize);

internal struct INPUT {
public ulong type;

// Union
public MOUSEINPUT mi;
public KEYBDINPUT ki;

internal struct MOUSEINPUT {
public long dx;
public long dy;
public ulong mouseData;
public ulong dwFlags;
public ulong time;
public ulong dwExtraInfo;

I tried this with an array instead of an IntPtr too, but that also didn't work. The union thing is the other thing I am not sure I implemented correctly.

Thanks in advance for ANY help on this subject...
Sign In or Register to comment.