I am trying to restore( or even maximize ) another application and send input to it from my project. I can do it for certain applications like Notepad
or Skype
, but it doesn't work for other applications such as TeamSpeak
.
Any ideas why and how I can solve the problem ?
Here's my code :
private void winact()
{
IntPtr hWnd; //change this to IntPtr
Process[] processRunning = Process.GetProcesses();
string title, name;
foreach (Process pr in processRunning)
{
title = pr.MainWindowTitle.ToLower();
name = pr.ProcessName.ToLower();
if (title.Contains("teamspeak".ToLower()) || name.Contains("teamspeak".ToLower()))
{
hWnd = pr.MainWindowHandle;
ShowWindow(hWnd, 3);
SetForegroundWindow(hWnd); //set to topmost
break;
}
}
}
I use InputSimulator to send the input.