michaelnoonan/inputsimulator — pull request #4 by Giorgi (2013-06-18 19:32:31+00:00)
Title: Throw Win32Exception with last error code when Sendinput fails 

Throwing Win32Exception exception has an advantage that it won't swallow the error code and it will automatically get the user friendly error message for the error that happened.

See https://blogs.msdn.com/b/adam_nathan/archive/2003/04/25/56643.aspx for details.