using System; using System.Drawing; // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Trigger target when run by a Trigger rule // - TitleBar Button owner when run by a TitleBar Button // - Jump List owner when run from a Taskbar Jump List // - Currently focused window if none of these match public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { //change this variable to the path where the outlook exe is located on your machine string outlookPath = @"C:\Program Files (x86)\Microsoft Office\Office15\OUTLOOK.EXE"; //if outlook is running, focus it. otherwise start outlook if(BFS.Application.IsAppRunningByFile(outlookPath)) { //get the handle to the outlook window windowHandle = BFS.Application.GetMainWindowByFile(outlookPath); //focus the window BFS.Window.Focus(windowHandle); } else { //start outlook and grab its process id uint pid = BFS.Application.Start(outlookPath, ""); //wait for outlook to open while(!BFS.Application.IsAppRunningByAppID(pid)) BFS.General.ThreadWait(100); //wait for the splash screen to go away BFS.General.ThreadWait(2000); //grab the handle to its window windowHandle = BFS.Application.GetMainWindowByAppID(pid); //focus the window BFS.Window.Focus(windowHandle); } //send ctrl+2 to outlook BFS.Input.SendKeys("^2"); } }