How to perform a sketch on MSPAINT using UiPath

uiautomation
studio
sketch
imageautomation
mspaint

#1

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)


#2

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!!

Regards,
Gunjan


#3

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


#4

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


#5

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


#6

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


#7

Yes.


#8

Hi @PragmaticProgrammer,

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

Regards,
Gunjan Bhogal


#9

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