
Today I learned how to make my life easier
My thoughts were always that automation was for Linux, Windows folks had to either use the Powershell terminal or they were pluck out of luck. Pyautogui says no. With this really cool tool you can make your Windows experience a whole lot easier. Tired of going in [insert browser here] and opening the same sites after a reboot? OK, create a script with pyautogui to launch [insert browser here] and open your sites and set it to auto-run on bootup. Fixed!
This is very cool.
Getting set up
The only dependency the pyautogui library has is Python so you can do a quick
pip install pyautogui
and you're done
: 0
What I did with this groovy tool
I decided to create a quick script that launches specific apps and browser tabs based on my mood. It was easy-peasy because the pyautogui wiki had all the necessary information on how to get started, not to mention the really intuitive function names like click and send
I'm sure you'd be able to pick it up really easily too
Secret sauce
Ok, OK I heard the clamoring so I'll get right to it, the code is right below
import pyautogui from time import sleep pyautogui.FAILSAFE = False class browser(object): def __init__(self,browser): self.browser = browser def openBrowser(self): pyautogui.press("win") pyautogui.typewrite(self.browser) pyautogui.press("enter") def openSite(self,websites): for website in websites: if website == websites[0]: sleep(2) pyautogui.hotkey("ctrl", "e") pyautogui.press("backspace", 2) pyautogui.typewrite(website) pyautogui.press("enter") else: self.newTab(website) def newTab(self,website): sleep(2) pyautogui.hotkey("ctrl", "t") sleep(0.2) pyautogui.typewrite(website) pyautogui.press("enter") def typeSomething(message): pyautogui.typewrite(message) def openProgram(program): sleep(2) pyautogui.hotkey("win", "d") pyautogui.press("win") pyautogui.typewrite(program) pyautogui.press("enter") def mood_select(): print (" What mood are you in today?") mood = input(""" Networking 1 Gaming 2 Youtube 3 Netflix 4 """) edge = browser("Edge") edge.openBrowser() if int(mood) == 1: websites = ["www.packetpushers.net", "www.reddit.com/r/networking"] edge.openSite(websites) openProgram("GNS3") if int(mood) == 2: websites = ["gaming.youtube.com", "www.reddit.com/r/gaming"] edge.openSite(websites) openProgram("Steam") if int(mood) == 3: websites = ["www.youtube.com/tv"] edge.openSite(websites) if int(mood) == 4: websites = ["www.netflix.com"] edge.openSite(websites) mood_select()
In Action

Phew that was easy, huh?
Yeah, I know this library is really easy to get an understanding of, and I'm happy I could learn about it and share it. Thanks for giving me a read!
Github link: https://github.com/jordan-barrett-jm/Windows-GUI-Automation
; )
Woah, this is super cool!