Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. [How] Screen reading for automation tasks?

[How] Screen reading for automation tasks?

Scheduled Pinned Locked Moved C#
csharpgraphicstestingtoolsjson
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sbscb
    wrote on last edited by
    #1

    I see many programs do this, they read the screen using bitmap and screencapture and interpret the results. I got the code to capture screen using C#, and have converted to bitmap, but the only usable method is getPixel(int x, int y). For example here is some of my code: Bitmap bt = (Bitmap)image1; //assume image1 is the screen capture output String p = bt.getPixel(50, 100).toString(); which returns a string containing some information in RGB format, now I do a if statement: if(p == "some reference RGB") return true; else return false; Now as you can see this method takes a long time to first capture screen, convert to bitmap, read pixel of bitmap, compare it to reference, and return boolean. I was wondering if there was an easier way using API methods of the GDI32 dll file, that makes this easier and faster or whether its always slow. How do "auto" programs work? I would like some information if anyone can help me please. :-D My source is always free, so support my applications. MAx.

    S 1 Reply Last reply
    0
    • S sbscb

      I see many programs do this, they read the screen using bitmap and screencapture and interpret the results. I got the code to capture screen using C#, and have converted to bitmap, but the only usable method is getPixel(int x, int y). For example here is some of my code: Bitmap bt = (Bitmap)image1; //assume image1 is the screen capture output String p = bt.getPixel(50, 100).toString(); which returns a string containing some information in RGB format, now I do a if statement: if(p == "some reference RGB") return true; else return false; Now as you can see this method takes a long time to first capture screen, convert to bitmap, read pixel of bitmap, compare it to reference, and return boolean. I was wondering if there was an easier way using API methods of the GDI32 dll file, that makes this easier and faster or whether its always slow. How do "auto" programs work? I would like some information if anyone can help me please. :-D My source is always free, so support my applications. MAx.

      S Offline
      S Offline
      Shy Agam
      wrote on last edited by
      #2

      Try using unsafe code to scan the bitmap. There's a series of articls about image processing, written by Christian Graus, here in CodeProject. You can find the first one here[^]. Regards, Shy.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups