How to perform a sketch on MSPAINT using UiPath

Hi all,

Those who want to know how to do a sketch on MSPAINT using UiPath, following are the steps:

  1. Take any .bmp image file and store it into a Bitmap variable.

  2. Store the height and weight of the above image into Int32 variables.

  3. Loop through the image pixels using the height and width and check the RGB value at each pixel. (color = image.getPixel(x,y))

  4. Check if the RGB value corresponds to black color. (color.R < 100 and color.G < 100 and color. B < 100)

  5. If it corresponds to black, store the x,y co-ordinates into a collection. (e.g. a list)

  6. Loop through the collection and perform Click into Paint window using the Click activity and setting the OffsetX and OffsetY attributes.

Also attaching the code for more insight.

Main.xaml (73.5 KB)


Hi @PragmaticProgrammer,

I appreciate your efforts, it really helped me!!

The only issue I’m facing is that after Paint gets opened the cursor doesn’t move or really draw anything, and after debugging I got the conclusion that the problem is with “Click Activity”. But when I copied and pasted your Click Activity in my workflow it works fine. I even checked and compared all the properties of Click Activity, everything is same.

I would be really grateful if you help me figure this out!!


@gunjanbhogal Did you check the Cursor Position property with offsetX and offsetY attributes?

I am facing an issue: -

After opening Paint, mouse is not moving and just throwing an error

Click ‘Afx:00007FF63D840000:8’ : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Can you pls help

Can you please check if “SendWindowMessages” property of Click is enabled?

It’s not enabled. Do I need to enable it?


Hi @PragmaticProgrammer,

Thanks for letting me know about offsetX and offsetY attributes. It’s working absolutely fine now. Thank you again :slight_smile:

Gunjan Bhogal

Check out the video to create sketch robot using uipath in a simple fashion!!

Hi All,

Thanks to @PragmaticProgrammer for providing the xaml file.

I am facing the issues in using this file.

When I am executing this file alone, then it is working well.

But when I invoke it and run from master flow, then it got failed at first Assign activity named “Get new image”, where we are assigning the image.

Please help me in resolving this issue, maybe I am missing something.