dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

SendInput/struct INPUT doesn't work on x64 #309

Closed rlabrecque closed 7 years ago

rlabrecque commented 7 years ago

The FieldOffset for the union must be 8 instead of 4 on x64.

https://github.com/AArnott/pinvoke/blob/3ed1db34699c1d836f4db735f13c7dfe4617c900/src/User32.Desktop/User32%2BINPUT.cs

Other sources/explanations: http://www.pinvoke.net/default.aspx/Structures/INPUT.html https://social.msdn.microsoft.com/Forums/en-US/69e5529e-372b-4d70-bb94-556507a2358e/sendinput-vs-windows-7-x64-rc-build-7000-not-working?forum=Vsexpressvb

AArnott commented 7 years ago

Wow. The MSDN docs make it look so much like it's always at 4 bytes offset. Very insightful that observation about memory alignment.