Automate Some Mundane Tasks With Python


My dear Python enthusiasts over there! Today I brought a little hack for making your life a little less boring. You can use this idea to build very complex algorithms.


Getting the libraries:

I assume you have Python installed on your computer. If not and you still want to follow this instruction, please install python any version will do.

Today we will show you how can you automate some tasks automated just using a few functions from pyautogui library.
Most probably your python comes with this library, if not go ahead and pip install it.

command: pip install pyautogui.

Or using anaconda.

command: conda install -c conda-forge pyautogui

Clicking with Python:

Let me tell you first what will we do today. We will use the auto click function from the GUI library and make our program click where we want.

Let’s say we want to click on the close button to quit the window. So the question is where will our program click. to find out the coordinate position of the close button let’s open python in the command prompt or anaconda prompt or any of your terminal.

Then import the required library.

import pyautogui as gui

then type the command
gui position() (don’t press enter)
hover your mouse on the close button ( just hover, don’t click anywhere).
then press Enter you will see the script has detected the position of the close button (or wherever you were hovering the mouse pointer).
Now we found the coordinates of the button we want to click let’s simulate the click using click function. Click method requires two arguments. X and Y coordinate of the position.


 gui click(1895, 22)
 The program successfully clicked the button. If not make sure you did everything right. If it worked then play with more functions comes with pyautogui.   🎉 🎉 🎉

Now let us make our program more useful.
Let’s think of something we need to automate. I have joined Fiverr recently and for a beginner, there isn’t a lot of posts to bid!
So refreshing the Buyer Requests page might be a good idea for me.
so let us find the position of the active button where the active jobs will be reloaded.
and now using the program click!

Looping and using Time:

So we want our program to click this button and check if there is any job every 30 seconds.
To do that we can run the program in a while True loop and use the time library.

 while True:, 289)

so our program will loop over time and click the active button every after 30 seconds.

Now let us check if there is a new job!
we can detect the color of any given position to see if there is a job. Like if there is a job there will be this green send-offer button.


for that, we will first find the position coordinate and then use the pixel method which takes the position arguments. which will check the color of the position. if there is no job this place will be light grey. (#RGB 247,247,247). But if there is a job there will be a send-offer button which is green.

gui.pixel(3058,453)        #then let us add condition


if c != (247,247,247):

This code will check if the button is not grey then click the button for us and print Attention on the terminal.

Let us say we want the program beep as well to notify us.

let’s import another library which will play output sound. And use the Beep class to play the sound when there is the green button. Beep class will take two arguments, frequency of the beep and duration. 

we added extra 60 second to let us write a proposal if there is a job.

Now to not be disappointed we need to expect uncertainty!

i will keep track how many times did our program loop.

Download or fork the code on GitHub: Github Python

I hope you are familiar now with python automation. Use the idea to build complex algorithms.

You can use pyinstaller to make a exe file from the python file. And create sharable bots.

Thank you for staying with datalators. Subscribe our newsletter to make sure you don’t miss any post.

8 thoughts on “Automate Some Mundane Tasks With Python”

  1. Hello there! This is kind of off topic but I need some guidance from an established
    blog. Is it hard to set up your own blog? I’m not very techincal but I
    can figure things out pretty fast. I’m thinking about creating my own but I’m not
    sure where to start. Do you have any points or suggestions?

    Appreciate it

  2. Whats up are using WordPress for your site platform?

    I’m new to the blog world but I’m trying to get started and
    set up my own. Do you need any html coding expertise to make your own blog?
    Any help would be greatly appreciated!

  3. My brother recommended I might like this web site. He was entirely right.
    This submit actually made my day. You cann’t believe simply how a
    lot time I had spent for this info! Thanks!

  4. Hmm is anyone else encountering problems with the pictures
    on this blog loading? I’m trying to figure
    out if its a problem on my end or if it’s the blog.
    Any feed-back would be greatly appreciated.

Leave a Comment

Your email address will not be published.