PROJECT 4 (automation) : AUTOMATING OFFICE BORING STUFFS
NOTE: I wrote this script based on my PC screen resolution(1366 x 768), so dont run it without using a compatible screen resolution or better still, adjust the code to fit your size.
No doubt, repeating tasks in our office can be monotonous at times, It’s normal as we are humans, and not built to be repetitive This is not the case with bots, they can do our repetitive tasks without getting tired (there may be other reasons but tired is not one of them)
The argument about whether automation will increase unemployment rate is not for debate, however, one thing I know for sure is that;
“The future is automation”.
Automation
What is special about this project is the ease at which I can automate task (less code), as long as I know what is to be done in advance.
PYAUTOGUI is an amazing python library for operating the keyboard and mouse on a PC, and in this project, I use it to automatically open MS Excel.
Python + automation + Graphics user interface = PYAUTOGUI
STEPS
- Install the Library with ‘pip install pyautogui’
- Import library
- Activate safe mode, by setting FailSafe to true. Why? Because Pyautogui operate in relation to the screen size and what is on the screen. Which is why it’s advisable to minimize all software on screen before running the python scripts in the terminal. (so pyautogui.FAILSAFE = True)
- Check the scrrensize with pyautogui.size()
- You can then move the cursor with ‘.moveTo(x, y)’. X means x axis, same with y. E.g pyautogui.moveTo(90, 100)
- Other operations include, ‘.click(x,y), .typewrite(‘hello’), .press(‘Enter’) E.T.C
- You can check my code here for example.
Lest I forget, Pyautogui can also be used with other libraries like Selenium to enhance modern web-scraping on steroid.
Thanks.