コード例 #1
0
        public void AddWindow(IntPtr handle)
        {
            WindowService.GetWindowRect(handle, out var rect);
            WindowRectangle windowRectangle = new WindowRectangle(
                new Point(rect.Left, rect.Y),
                rect.Width - rect.X, rect.Height - rect.Y);

            if (!_windows.ContainsKey(handle))
            {
                _windows.Add(handle, windowRectangle);
            }
            else
            {
                _windows[handle] = windowRectangle;
            }

            if (!_profiles.ContainsKey(handle))
            {
                _profiles.Add(handle, new Profile(_user.ApiKey));
            }
            else
            {
                _profiles[handle] = new Profile(_user.ApiKey);
            }

            if (!_errors.ContainsKey(handle))
            {
                _errors.Add(handle, false);
            }
            else
            {
                _errors[handle] = false;
            }
        }
コード例 #2
0
        private void PerformClick(WindowRectangle window, Click click,
                                  bool needDelay = true)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            if (click == null)
            {
                throw new ArgumentNullException(nameof(click));
            }

            Point point = window.GetScreenPoint(click.Position);

            VirtualMouse.SendLeftClick(point);

            if (needDelay)
            {
                Thread.Sleep(click.Delay);
            }
        }