R
Richard A. Lowe
I'm successfully using SendInput to emulate mouse events
for a legacy app, delcared like so:
[DllImport("User32.dll")]
public extern static int SendInput( int theCount, ref
INPUT pInputs, int theSize );
From the MSDN docs, SendInput appears to take an array of
inputs:
"pInputs
[in] Pointer to an array of INPUT structures. Each
structure represents an event to be inserted into the
keyboard or mouse input stream."
However I'm not sure how to pass it in managed C#. I
recklessly made an attempt by simply changing the
declaration to an array (as below). And as I suspected it
does *not* work when I pass in a valid array of INPUT
structs.
[DllImport("User32.dll")]
public extern static int SendInput( int theCount, ref INPUT
[] pInputs, int theSize );
I'm wondering:
a) How to declare the external function correctly
b) How to create and pass my INPUT structs array.
c) I'd like to know the why of the internals? I.E. Does it
not work because .NET is also marshalling the 4 bytes of
length info at the begining of the array?
Thanks
for a legacy app, delcared like so:
[DllImport("User32.dll")]
public extern static int SendInput( int theCount, ref
INPUT pInputs, int theSize );
From the MSDN docs, SendInput appears to take an array of
inputs:
"pInputs
[in] Pointer to an array of INPUT structures. Each
structure represents an event to be inserted into the
keyboard or mouse input stream."
However I'm not sure how to pass it in managed C#. I
recklessly made an attempt by simply changing the
declaration to an array (as below). And as I suspected it
does *not* work when I pass in a valid array of INPUT
structs.
[DllImport("User32.dll")]
public extern static int SendInput( int theCount, ref INPUT
[] pInputs, int theSize );
I'm wondering:
a) How to declare the external function correctly
b) How to create and pass my INPUT structs array.
c) I'd like to know the why of the internals? I.E. Does it
not work because .NET is also marshalling the 4 bytes of
length info at the begining of the array?
Thanks