Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Diagnostics;
- namespace WinFormsApp1;
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- var button = new Button()
- {
- Text = "@",
- Width = 50, Height = 2 * 24,
- };
- button.Font = new Font("Arial", 24, FontStyle.Bold);
- Controls.Add(button);
- // var graphics = button.CreateGraphics();
- // var image = Image.FromHbitmap(graphics.GetHdc());
- _ = Task.Delay(1000 * 3).ContinueWith(_ =>
- {
- // #
- var bitmap = new Bitmap(button.Width, button.Height);
- var graphics = Graphics.FromImage(bitmap);
- var rectangle = button.RectangleToScreen(button.ClientRectangle); // client (app) => screen (monitor)
- // var rectangle2 = button.RectangleToClient(button.ClientRectangle); // screen (monitor) => client (app)
- graphics.CopyFromScreen(rectangle.Location, Point.Empty, button.Size);
- // bitmap.Save("image.bmp");
- // Process.Start("image.bmp");
- for (int i = 0; i < bitmap.Width; i++)
- {
- for (int j = 0; j < bitmap.Height; j++)
- {
- var pixel = bitmap.GetPixel(i, j);
- if (pixel.R == button.ForeColor.R &&
- pixel.G == button.ForeColor.G &&
- pixel.B == button.ForeColor.B)
- {
- // NOTE: TEXT HAS BEEN FOUND BUTTON - OTHER SIZE TRY ANOTHER FONT
- Debugger.Break();
- }
- }
- }
- }, TaskScheduler.FromCurrentSynchronizationContext());
- }
- }
- // https://www.youtube.com/watch?v=x-tMlZ3LTw8
- // https://github.com/SubtitleEdit/subtitleedit/issues/8427
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement