private void StartClicking(object sender, KeyPressEventArgs keyEventArguments) { if (keyEventArguments.KeyChar == 'p' && !IsClickingEnabled) { IColourPicker colourPicker = new ColourPicker(); IVideoDisplay display = new WindowsScreen(); IVideoDisplay currentWindow = WindowsApplication.GetForeground(); ICursor cursor = new WindowsCursor(); Color colour = colourPicker.GetFromDisplayPosition(display, cursor.GetPosition()); IPixelFinder pixelFinder = new PixelFinder(); IClicker clicker = new Clicker(); Thread clickingThread = new Thread(() => { IsClickingEnabled = true; while (IsClickingEnabled) { var clickedPosition = pixelFinder.FindPixelPosition(currentWindow, colour); if (clickedPosition.HasValue) { clicker.Click((int)currentWindow.Handle, clickedPosition.Value); } Thread.Sleep(TimeSpan.FromSeconds(1)); } }); clickingThread.Start(); } }
public Point?FindPixelPosition(IVideoDisplay videoDisplay, Color pixelColour) { pixelColour = Color.FromArgb(0, pixelColour); Bitmap screenshot = videoDisplay.GetAsImage(); screenshot.Save(@"E:\test.bmp"); Point?pixelPosition = null; for (int widthIndex = 0; widthIndex < screenshot.Width && pixelPosition == null; widthIndex++) { for (int heightIndex = 0; heightIndex < screenshot.Height && pixelPosition == null; heightIndex++) { Color pixel = screenshot.GetPixel(widthIndex, heightIndex); pixel = Color.FromArgb(0, pixel); bool isPixelMatch = pixel.Equals(pixelColour); if (isPixelMatch) { pixelPosition = new Point(widthIndex, heightIndex); } } } return(pixelPosition); }
public NowPlayingContents() { VisibleWindow = false; Child = table = new Table(1, 1, false) { Visible = true }; table.NoShowAll = true; CreateVideoDisplay(); IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { ivideo_display.IdleStateChanged += OnVideoDisplayIdleStateChanged; } table.Attach(video_display, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); track_info_display = new NowPlayingTrackInfoDisplay(); table.Attach(track_info_display, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); }
private void CheckIdle() { IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { video_display.Visible = !ivideo_display.IsIdle; track_info_display.Visible = ivideo_display.IsIdle; } }
private void CheckIdle() { IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { video_display.Visible = !ivideo_display.IsIdle; } track_info_display.Visible = false; (substitute_audio_display ?? track_info_display).Visible = ivideo_display.IsIdle; }
public override void Dispose() { IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { ivideo_display.IdleStateChanged -= OnVideoDisplayIdleStateChanged; } if (video_display != null) { video_display = null; } base.Dispose(); }
public NowPlayingContents() : base(1, 1, false) { NoShowAll = true; CreateVideoDisplay(); video_event = new EventBox(); video_event.VisibleWindow = false; video_event.CanFocus = true; video_event.AboveChild = true; video_event.Add(video_display); video_event.Events |= Gdk.EventMask.PointerMotionMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonMotionMask | Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask; //TODO stop tracking mouse when no more in menu video_event.ButtonPressEvent += OnButtonPress; video_event.ButtonReleaseEvent += OnButtonRelease; video_event.MotionNotifyEvent += OnMouseMove; video_event.KeyPressEvent += OnKeyPress; IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { ivideo_display.IdleStateChanged += OnVideoDisplayIdleStateChanged; } Attach(video_event, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); track_info_display = new NowPlayingTrackInfoDisplay(); Attach(track_info_display, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); video_event.ShowAll(); }
public override void Dispose() { video_event.ButtonPressEvent -= OnButtonPress; video_event.ButtonReleaseEvent -= OnButtonRelease; video_event.MotionNotifyEvent -= OnMouseMove; video_event.KeyPressEvent -= OnKeyPress; IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { ivideo_display.IdleStateChanged -= OnVideoDisplayIdleStateChanged; } if (video_display != null) { video_display = null; } base.Dispose(); }
public NowPlayingContents() : base(1, 1, false) { NoShowAll = true; video_display = new XOverlayVideoDisplay(); IVideoDisplay ivideo_display = video_display as IVideoDisplay; if (ivideo_display != null) { ivideo_display.IdleStateChanged += OnVideoDisplayIdleStateChanged; } Attach(video_display, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); track_info_display = new NowPlayingTrackInfoDisplay(); Attach(track_info_display, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); }
public Color GetFromDisplayPosition(IVideoDisplay display, Point position) { Color pixel = display.GetPixel(position); return(pixel); }