Exemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            IntPtr loginWnd = User32Api.FindWindow(null, "Login");

            if (loginWnd != IntPtr.Zero)
            {
                User32Api.SetForegroundWindow(loginWnd);
                Current.Shutdown();
                return;
            }

            IntPtr parenthWnd = User32Api.FindWindow(null, "密云直播云课堂");

            if (parenthWnd != IntPtr.Zero)
            {
                User32Api.SetForegroundWindow(parenthWnd);
                Current.Shutdown();
                return;
            }

            base.OnStartup(e);
            string startupPatams = string.Empty;

            if (e.Args.Length > 0)
            {
                startupPatams = e.Args[0];
            }
            Bootstrapper bootstrapper = new Bootstrapper(startupPatams);

            bootstrapper.Run();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查找窗口
        /// </summary>
        /// <param name="lpClassName"></param>
        /// <param name="lpWindowName"></param>
        /// <returns></returns>
        public static WindowModel FindWindow(string lpClassName, string lpWindowName, bool IsSelfProcessId = true)
        {
            WindowModel wm = WindowModel.Empty;
            var         ip = User32Api.FindWindow(lpClassName, lpWindowName);

            if (ip != IntPtr.Zero)
            {
                wm = new WindowModel(ip);
                if (IsSelfProcessId && wm.ProcessId != ProcessId)
                {
                    wm = WindowModel.Empty;
                }
            }
            return(wm);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Get the AppLauncher
        /// </summary>
        /// <returns>IInteropWindow</returns>
        public static IInteropWindow GetAppLauncher()
        {
            // Works only if Windows 8 (or higher)
            if (IsLauncherVisible)
            {
                return(null);
            }
            var appLauncher = User32Api.FindWindow(ApplauncherClass, null);

            if (appLauncher != IntPtr.Zero)
            {
                return(InteropWindowFactory.CreateFor(appLauncher));
            }
            return(null);
        }
Exemplo n.º 4
0
 private IntPtr GetWindowHandle(string windowTitle)
 {
     return(User32Api.FindWindow(null, windowTitle));
 }