Anbei ein kleines Snippet um einen Prozess in den Vordergrund zu holen (wie z.B. EPLAN –> “W3u”).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
using System.Runtime.InteropServices;
using System.Diagnostics;  
 
        private void SetProcessActive(string processName)
        {
            System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName(processName);
            if (p.Length > 0)
            {
                SetForegroundWindow(p[0].MainWindowHandle);
            }
        }
        // Fenster Vordergrund
        [DllImport("user32.dll")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);