C# (WinForms) - Find Colour of Cursor -


my aim:

  • i'd have ability retrieve colour on screen including cursor, coordinates.
  • in other words, suppose i'd retrieve colour of cursor (or @ least, point/pixel on cursor).

my difficulty:

  • i have code retrieve colour on screen coordinates, believe not include cursor. believe because method i'm using takes screenshot (without cursor), , reads colour that.

my current code:

    public static color retrievecolour(point coordinates)     {         //use 'image' create graphics class.         using (graphics destination = graphics.fromimage(screenpixel))         {              //creates graphic specified handler window.              //in case, uses handler has been initialised zero.              using (graphics source = graphics.fromhwnd(intptr.zero))              {                  //handler source device context.                  intptr handlersourcedc = source.gethdc();                  //handler destination device context.                  intptr handlerdc = destination.gethdc();                  //bitblt responsible doing copying.                  //returns non-zero value upon success.                  int retval = bitblt(handlerdc, 0, 0, 1, 1, handlersourcedc, coordinates.x, coordinates.y, (int)copypixeloperation.sourcecopy);                  //release handlers.                  destination.releasehdc();                  source.releasehdc();              }         }         //retrieve colour of pixel @ specified coordinates.         return screenpixel.getpixel(0, 0);     } 

i should add, should work non-windows cursors. mean custom cursors other applications (if has bearing on future answers).

as far aware, way you'd able if create custom driver can act intermediary between user.

i haven't read of it, might want project http://www.codeproject.com/kb/cs/desktopcapturewithmouse.aspx?display=print

previously posted here: c# - capturing mouse cursor image


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -