Hi there, Im a relative C# noob, trying to develop an app that will help me automate some of my everyday processes that are very basic and repetitive, but require me to pass variables between programs etc. Ive been scouring the MSDN pages and http://www.pinvoke.net amongst other places to find out about mouse and key automation, and i have 90% of what I need - how to call functions from Win32 dlls, marshal the data etc, the only thing Im in not sure of is how to actually execute it:
Found this very useful snippet at http://blogs.msdn.com/robgruen/archive/2004/05/10/129221.aspx
Also http://msdn2.microsoft.com/en-us/library/ms646273.aspx
Goes into depth about the actual MOUSEINPUT structure, but I have no idea how i would actually structure a call within the Main() method. Its probably intuitive and Im being stupid.
Found this very useful snippet at http://blogs.msdn.com/robgruen/archive/2004/05/10/129221.aspx
Code:
[DllImport("User32.dll", SetLastError=true)]
public static extern int SendInput(int nInputs, ref INPUT pInputs, int cbSize);
public struct INPUT
{
public int type;
public MOUSEINPUT mi;
}
public struct MOUSEINPUT
{
public int dx;
public int dy;
public int mouseData;
public int dwFlags;
public int time;
public int dwExtraInfo;
}
// Call the API
int resSendInput;
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
if (resSendInput == 0 || Marshal.GetLastWin32Error() != 0)
System.Diagnostics.Debug.WriteLine(Marshal.GetLastWin32Error());
Also http://msdn2.microsoft.com/en-us/library/ms646273.aspx
Goes into depth about the actual MOUSEINPUT structure, but I have no idea how i would actually structure a call within the Main() method. Its probably intuitive and Im being stupid.