示例#1
0
 private static void DoInject(string injectJs, int chromeDevHwnd, ChatDesk desk, Func <bool> isConnectOk)
 {
     for (int i = 0; i < 4; i++)
     {
         WinApi.BringTopAndDoAction(chromeDevHwnd, () =>
         {
             DispatcherEx.xInvoke(() =>
             {
                 WinApi.PressEsc();
             });
         }, 2);
         if (i == 0)
         {
             Thread.Sleep(4000);
         }
         else
         {
             Thread.Sleep(4000);
         }
         ExcuteJsInner(injectJs, chromeDevHwnd);
         Thread.Sleep(100);
         if (isConnectOk())
         {
             break;
         }
     }
     if (desk.IsForeground)
     {
         desk.BringTop();
     }
 }
示例#2
0
 internal static void ActiveChromeDev(ChatDesk desk)
 {
     try
     {
         bool isForeground  = desk.IsForeground;
         int  chromeDevHwnd = GetExistChromeDevTools(desk);
         Util.Assert(chromeDevHwnd != 0);
         isForeground = (isForeground || desk.IsForeground);
         for (int i = 0; i < 5; i++)
         {
             if (i > 0)
             {
                 Thread.Sleep(30);
             }
             WinApi.BringTopAndDoAction(chromeDevHwnd, () =>
             {
                 WinApi.PressEsc();
             }, 2);
         }
         if (isForeground)
         {
             desk.BringTop();
         }
     }
     catch (Exception ex)
     {
         Log.Error("ocr2," + ex.Message);
     }
 }
示例#3
0
 private static void ExcuteJsInner(string injectJs, int chromeDevHwnd)
 {
     ClipboardEx.UseClipboardWithAutoRestore(() =>
     {
         DispatcherEx.xInvoke(() =>
         {
             ClipboardEx.SetTextSafe(injectJs);
             WinApi.BringTopAndDoAction(chromeDevHwnd, () =>
             {
                 WinApi.PressCtrlV();
                 Thread.Sleep(500);
                 WinApi.PressEnterKey();
             }, 4);
         });
     });
 }
示例#4
0
        private static int OpenNewChromeDevTools(ChatDesk desk)
        {
            var debugHwnd = 0;

            AssertSingleChatChromeVisible(desk);
            if (!WinApi.BringTopAndDoAction(desk.Hwnd.Handle, () =>
            {
                var chatRecordChromeHwnd = desk.Automator.ChatRecordChromeHwnd;
                WinApi.ClickPointBySendMessage(chatRecordChromeHwnd, 5, 5);
                WinApi.PressF12();
                Thread.Sleep(100);
                OpenChromeDevTools(desk.AliappProcessId);
                debugHwnd = GetExistChromeDevTools(desk.AliappProcessId, 5);
                AssertSingleChatChrome(debugHwnd);
                HideChromeDebugWindow = debugHwnd > 0;
                HideChromeDevDebugWindow(debugHwnd);
            }, 5))
            {
                throw new Exception("Can't bring chat desk to top");
            }
            return(debugHwnd);
        }
示例#5
0
 public void FocusItem(int idx)
 {
     _wnd.BringTop();
     if (idx >= tvMain.Items.Count)
     {
         idx = tvMain.Items.Count - 1;
     }
     if (idx < 0)
     {
         idx = 0;
     }
     WinApi.BringTopAndDoAction(_wnd.Handle, () => {
         tvMain.Focus();
         if (idx < tvMain.Items.Count)
         {
             var it = tvMain.Items[idx] as TreeViewItem;
             if (it != null)
             {
                 it.IsSelected = true;
             }
         }
     });
 }