Python Automation Drawing In Paint Application

In this Python Automation article i want to show you Drawing In Paint Application, basically we are going to write a program that you can Draw to Paint Application. before this we had some articles on Python GUI Automation,  so you can check the articles in the below links. also we are using PyAutoGUI library for this article.

 

1:  How to Automate GUI in Python with PyAutoGUI

2: Python GUI Automation Getting Mouse Position 

 

 

Clicking The Mouse

To send a virtual mouse click to your computer, call the pyautogui.click() method. By default, this click uses the left mouse button and takes place wherever the mouse cursor is currently located. You can pass x- and
y- coordinates of the click as optional first and second arguments if you want it to take place somewhere other than the mouse’s current position. If you want to specify which mouse button to use, include the button keyword argument, with a value of ‘left’, ‘middle’, or ‘right’. For example, pyautogui.click(100, 150, button=’left’) will click the left mouse button at the coordinates (100, 150), while pyautogui.click(200, 250, button=’right’) will perform a right-click at (200, 250).

 

After runing the code in Pycharm IDE you should see the mouse pointer move to near the top-left corner of
your screen and click once. A full “click” is defined as pushing a mouse button down and then releasing it back up without moving the cursor. You can also perform a click by calling pyautogui.mouseDown(), which only pushes
the mouse button down, and pyautogui.mouseUp(), which only releases the button. These functions have the same arguments as click(), and in fact, the click() function is just a convenient wrapper around these two function calls.
As a further convenience, the pyautogui.doubleClick() function will perform two clicks with the left mouse button, while the pyautogui.rightClick() and pyautogui.middleClick() functions will perform a click with the right and
middle mouse buttons, respectively.

 

Dragging the Mouse

Dragging means moving the mouse while holding down one of the mouse buttons. For example, you can move fles between folders by dragging the folder icons, or you can move appointments around in a calendar app.
PyAutoGUI provides the pyautogui.dragTo() and pyautogui.dragRel() functions to drag the mouse cursor to a new location or a location relative to its current one. The arguments for dragTo() and dragRel() are the
same as moveTo() and moveRel(): the x-coordinate/horizontal movement, the y-coordinate/vertical movement, and an optional duration of time. (OS X does not drag correctly when the mouse moves too quickly, so passing a duration keyword argument is recommended.). for drawing iam going to use Paint Application.
so now add these codes in your Pycharm IDE and wait for 5 seconds after that you will see the drawing.

 

So now run the complete code and this will be the result Python Automation Drawing In Paint Application

 

 

 

 

 

Also you can watch the complete video for this article

 

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

2 thoughts on “Python Automation Drawing In Paint Application”

Comments are closed.

Share via
Copy link
Powered by Social Snap
×