You can use keybd_event
For example (remove the space at Sl eep (editor bug...):
IntPtr hWnd = FindWindow("TscShellContainerClass", null);
if (hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, SW_SHOWNORMAL);
SwitchToThisWindow(hWnd, true);
System.Threading.Thread.Sl eep(200);
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_LEFT, 0, 0, 0);
keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
Declarations :
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("User32.dll", SetLastError = true)]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
public const int KEYEVENTF_EXTENDEDKEY = 0x0001;
public const int KEYEVENTF_KEYUP = 0x0002;
public const int KEYEVENTF_UNICODE = 0x0004;
public const int KEYEVENTF_SCANCODE = 0x0008;
public const int VK_LWIN = 0x5B;
public const int VK_LEFT = 0x25;
public const int VK_UP = 0x26;
public const int VK_RIGHT = 0x27;
public const int VK_DOWN = 0x28;
[DllImport("User32.dll", SetLastError = true)]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public const int SW_HIDE = 0;
public const int SW_SHOWNORMAL = 1;
public const int SW_SHOWMINIMIZED = 2;
public const int SW_SHOWMAXIMIZED = 3;
public const int SW_RESTORE = 9;
[DllImport("User32.dll", SetLastError = true)]
public static extern bool SwitchToThisWindow(IntPtr hWnd, bool fAltTab);