I have the code below:
namespace WindowMover
{
using System.Windows.Forms;
static class Logic
{
[DllImport(\"user32.dll\", EntryPoint =
Played with this. See if it helps.
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ConsoleTestApp
{
class Program
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
static void Main(string[] args)
{
Process[] processes = Process.GetProcesses();
foreach (var process in processes)
{
Console.WriteLine("Process Name: {0} ", process.ProcessName);
if (process.ProcessName == "WINWORD")
{
IntPtr handle = process.MainWindowHandle;
bool topMost = SetForegroundWindow(handle);
}
}
}
}