At the top of your class put
using System.Runtime.InteropServices;
...
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
const int CAPSLOCK = 0x14;
const int NUMLOCK = 0x90;
const int SCROLLLOCK = 0x91;
Then to use it ..
keybd_event(CAPSLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(CAPSLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,(UIntPtr)0);
I think this function has been superceded now so you might want to do a bit of googling and improve on this (I'm using quite an old version of Visual Studio at the moment).
Full list of key codes is at
http://msdn.microsoft.com/en-gb/library/windows/desktop/dd375731(v=vs.85).aspx[
^]