It's not too difficult to interact with other running applications. For example, the following C# program will check to see if MSPaint is already running and, if it is, will force input focus onto it. If MSPaint isn't running, it will launch it and wait until it's ready to receive input.
It will then send it the keystrokes Alt+FO to open a window so that a file can be selected for viewing or editing:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
class Test
{
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
static void Main()
{
Process[] procs = Process.GetProcessesByName("mspaint"); // don't use .exe extension here
if (procs.Length == 0)
{
Console.WriteLine("MSPaint was not currently running but an instance has been started");
Process proc = new Process();
proc.StartInfo.FileName = "mspaint.exe";
proc.Start();
proc.WaitForInputIdle();
}
else
{
IntPtr hWnd = procs[0].MainWindowHandle;
SetForegroundWindow(hWnd);
}
SendKeys.SendWait("%FO");
}
}
However, MSPaint isn't really designed for automation and AFAIK there are no keyboard shortcuts to select a color.
You can send mouse commands to it using either the mouse_event or SendInput() API functions but it's not going to be easy to get the mouse coordinates right to select whichever color you want. However, if you want to try, here are some links and sample code for P/Invoking these functions from C#. The mouse_event function is deprecated in Win32 programming but is far easier to use than its replacement, SendInput:
http://www.pinvoke.net/default.aspx/user32/mouse_event.html
http://www.pinvoke.net/default.aspx/user32/SendInput.html