コード例 #1
0
ファイル: Program.cs プロジェクト: Bert-Proesmans/SC-Buddy
        static async Task Run()
        {
            var hook       = await MouseHook.Singleton;
            var automation = new UIAutomation();

            _ = hook.Stream.Subscribe(automation.Ingress);
            _ = automation.Egress.Subscribe(x => Console.WriteLine($"{x}"));

            while (true)
            {
                var key = Console.ReadKey();
                if ((key.Key & ConsoleKey.C) == ConsoleKey.C &&
                    (key.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control)
                {
                    break;
                }
            }
        }
コード例 #2
0
        private IHTMLDocument2 GetDocument()
        {
            AutomationElement ieSrvFrame = null;
            DateTime          start      = DateTime.Now;

            while (ieSrvFrame == null && (DateTime.Now - start).TotalMilliseconds <= 1000)
            {
                try
                {
                    IntPtr shellEmbedHwnd = _group._smProcess.Memory.Read <IntPtr>(
                        new IntPtr(NativeControlAddr + SM17Natives.TControl.HandleOffset)
                        );

                    ieSrvFrame = UIAutomation.FromHandle(shellEmbedHwnd).FindFirstDescendant(c => c.ByClassName("Internet Explorer_Server"));
                }
                catch (Exception ex)
                    when(ex is ElementNotAvailableException ||
                         ex is TimeoutException ||
                         ex is Win32Exception)
                    {
                        Thread.Sleep(50);
                    }
            }