10 Amazing Python Hacks (PART-2)

14+
The main purpose of this article is to learn(or automate) a few basic things with the help of python. Python is fun when it comes to automating the boring stuff. It enables us to perform tasks with just a few lines of code. This article is in series with my last article on Python hacks.

1.  Keyboard automation

Sometimes we work on something where we are required to type some words very frequently. Wouldn’t it be interesting if we could automate our keyboard to write those frequently used words with just abbreviation? Yes, it is and we can make it possible with python. You can set different abbreviations to their respective words. So, when you type these abbreviations with the keyboard, automatically the whole word gets typed. 

To install the library :

pip install keyboard

Code :

2. Screenshot 

Screenshots are  important in order to take a quick glance at something. We often get confused about which software to install inorder to take screenshots, as all the keyboards or OS do not support quick screenshot function. We can do this with the python library pyautogui. 

To install the library :

pip install pyautogui

Code :

3. Mouse Automation

We all are familiar with the fact that our laptop/desktop automatically goes into sleep mode after a particular duration. But this thing can sometimes create trouble for us, when we want to be away from the system but still want the screen to be on. This can be done by automating the mouse so that the cursor on the screen moves for some seconds repeatedly. In this way, our system can be on for an unlimited duration for time.

To install the library :

pip install pyautogui

Code :

4. Desktop Notifier

When we are working on our system, we might forget certain important things, which we can remember by seeing a simple notification on our system. With the help of python, we can create personalized notifications and can schedule them for a particular time. In my case, when I am focused on my work, I often forget to drink water, so I just schedule the notification, which displays on my screen every hour. 

To install the library :

pip install win10toast, schedule

Code :

5. Text File to PDF

We all have observed that most of our notes and online available books are in the form of pdf. It is because pdf can store the content in the same manner irrespective of platform or device. So, if we have text files, we can convert them into PDF files with the help of the python library fpdf. Let’s see how we can do this.

To install the library :

pip install fpdf

Code :

6. Creating the Audiobook

Are you excited about the idea of Audiobooks? Who wouldn’t be? It’s time to create your own Audiobook. Now you can simply convert your book(pdf)  to an Audiobook, which you can hear endlessly. If you are a lazy person like me, who always gets bored by reading books then this trick might be very interesting and useful for you.

To install the library :

pip install PyPDF2, pyttsx3

Code:

7. Image to sketch 

Most of us are fond of black and white sketches. But the fact is creating a human face sketch is time-consuming and a skillful task. But with Python, we can do this task simply in just 2 minutes. Isn’t it cool to imagine? Let’s see how we can do this with few lines of code. We are required to install an open cv library,  to work with image files. 

To install the library :

pip install opencv-python

Code :

8. Convert video to GIF

There is a new craze for GIFs in recent years. Most popular social media platforms such as WhatsApp,Instagram, and Snapchat provide a variety of GIFS for users to express their thoughts in a more meaningful and understood manner. With the help of python, we can create personalized GIFs with our videos. 

To install the library :

pip install moviepy

Code :

9. Display wifi passwords

Dealing with wifi passwords is not at all easy. We often forget the passwords of wifi. Here is a trick by which we can enlist all the devices and their password, to which our system is connected to. Cool, now we can carelessly connect and disconnect to wifi-devices, as we don’t need not to ask the password from the wifi owner again and again.

To install the library :

No need, standard built-in library is used

Code :

10. IP address of local system

Last but not the least here is a python trick to get the IP address of your system. This can be done with the help of a socket library. 

To install the library :

No need, standard built-in library is used

Code :

Conclusion

I guess you would have enjoyed these cool python hacks. Try these techniques, you can even create a GUI app based on these so that you can use it quickly whenever you need it. So, This was all for this article. If you enjoyed the article, do upvote it. 

Thanks for reading!

close
14+

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

DMCA.com Protection Status