Automate Some Mundane Tasks With Python

bot
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.

bot

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.

Chatbots
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.   🎉 🎉 🎉
Datalators

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:
    gui.click(1962, 289)
    sleep(30)

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.

Datalators

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):
gui.click(b)
print('Attention!')
sleep(25)

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.

34 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. 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.

  4. excellent submit, very informative. I ponder why the other specialists of this
    sector don’t realize this. You must continue your
    writing. I am confident, you have a great readers’ base already!

    games ps4 allenferguson games ps4

  5. Spot on with this write-up, I honestly think this site
    needs much more attention. I’ll probably be returning to read more,
    thanks for the advice! ps4 games 185413490784 ps4 games

  6. Wonderful goods from you, man. I have understand your stuff previous to and you’re just too
    wonderful. I really like what you have acquired here,
    certainly like what you’re saying and the way in which
    you say it. You make it enjoyable and you still care for
    to keep it sensible. I can’t wait to read much more from you.

    This is really a tremendous web site.

  7. W88 Casino Review
    Established in 2013, W88 has been a leading online gaming
    site in Asia for quite a while. During this time, the operator has
    earned a great reputation among players thanks to its wide range of activities, which include casino
    games, sports betting, lottery, live casino
    games and poker.

    The W88 site is well-known for its commitment to customer service, offering players
    the chance to claim generous bonuses regularly. So, it
    while it seems like this casino is packed
    with great games and customer service, let’s find
    out if there’s more to it than this.

  8. My brother recommended I might like this website. He was entirely
    right. This post actually made my day. You can not imagine simply
    how much time I had spent for this info! Thanks!

  9. Today, I went to the beach with my children. I found
    a sea shell and gave it to my 4 year old daughter and
    said “You can hear the ocean if you put this to your ear.”
    She put the shell to her ear and screamed. There
    was a hermit crab inside and it pinched her ear. She never wants to go back!
    LoL I know this is totally off topic but I had to tell someone!

  10. I like the helpful information you provide in your articles.
    I will bookmark your weblog and check again here regularly.
    I’m quite certain I will learn many new stuff right here! Best
    of luck for the next!

  11. Heya i’m for the first time here. I found this board and I
    find It truly useful & it helped me out a lot. I hope to give something back and aid others like you
    aided me.

  12. This is very interesting, You’re an overly professional blogger.
    I’ve joined your feed and look forward to in quest
    of more of your excellent post. Also, I have shared your web site in my social networks

  13. Hello my friend! I wish to say that this article is awesome,
    great written and include approximately all significant infos.
    I’d like to look more posts like this .

  14. I believe what you posted made a bunch of sense. However, what about this?
    what if you were to write a killer post title? I ain’t suggesting
    your content isn’t good., but what if you added a post title that grabbed
    folk’s attention? I mean Automate Some Mundane Tasks With Python – Datalators Blog is kinda boring.
    You ought to glance at Yahoo’s home page and note how they create article headlines to grab viewers to click.

    You might add a video or a related pic or two to get people interested about what you’ve
    written. In my opinion, it might make your posts a little livelier.

  15. scoliosis
    I’m truly enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a designer to create your theme?
    Exceptional work! scoliosis

  16. Thank you, I’ve recently been looking for info about this subject for ages and yours is the best I’ve discovered
    so far. But, what about the conclusion? Are you positive about the
    supply?

  17. Heya i am for the first time here. I came across this board and I in finding It really helpful & it
    helped me out a lot. I’m hoping to offer something back and help others like
    you helped me.

  18. Howdy! This article couldn’t be written much better! Going through this article reminds me of my previous roommate!
    He continually kept preaching about this. I most
    certainly will send this post to him. Pretty sure he’ll have a great read.

    Thank you for sharing!

  19. Hello There. I discovered your weblog using msn. That is an extremely well written article.
    I will make sure to bookmark it and come back to read extra of your helpful
    information. Thanks for the post. I will certainly comeback.

  20. Hey there would you mind letting me know which hosting company you’re
    using? I’ve loaded your blog in 3 completely
    different browsers and I must say this blog loads a lot faster then most.

    Can you recommend a good web hosting provider at a fair price?
    Many thanks, I appreciate it!

  21. Hi there! Would you mind if I share your blog with my myspace group?

    There’s a lot of folks that I think would really enjoy your content.

    Please let me know. Thank you

  22. Hello there, I found your web site by way of
    Google even as searching for a similar matter, your site got here up, it seems great.
    I have bookmarked it in my google bookmarks.
    Hello there, simply changed into alert to your blog thru Google, and located that
    it’s truly informative. I’m going to watch out for brussels.
    I’ll be grateful should you proceed this in future.
    Numerous other folks shall be benefited from your writing.

    Cheers!

Leave a Comment

Your email address will not be published.