Basic Python scripting to open apps and websites

Introduction

On my journey I realized i get distracted when I turn on my PC, because I can easily do whatever I want. So i thought why not make my code editor,note taking app and the tutorial/course I'm watching open automatically when i login.

This brought me to python scripting so today I'm gonna show how i learned to use python scripting to open apps and websites on login.

For this we'll need a few libraries:-

  • AppOpener

  • webbrowser

  • Selenium

AppOpener

  • We can install AppOpener using the following command
pip install AppOpener

For further information you can use the AppOpener documentation -

from AppOpener import open
  • Now we simply have to give the name of the app to be opened as an argument for open
open("Visual Studio Code")
open("Obsidian")
  • This should open VS CODE and Obsidian when the script is run

Webbrowser

  • The webbrowser library comes with python so we don't have to install it again.

  • We have to first import the library into our script

import webbrowser
  • I then store the url to be opened in a variable and give it as an arguement for webbrowser.open()
url = "https://www.udemy.com/"
webbrowser.open(url)

Open on boot (Windows)

  • Yaay, now our scripts work BUT you dont expect me to manually run the script everytime right?

  • So let's automate it to run on login, there are many ways to do it here I'll be doing it using the startup folder.

  • Click windows+R to open up the run dialog box and type in the following

shell:startup
  • Now, we can place the python scripts in this folder.

  • Note: Make the default app used to open .py files the default python IDE

  • After this, when we login the python scripts run and do what their supposed to do.

  • This will cause the command prompt to open very briefly.

  • To stop the cmd opening we can change the extension of the script from .py to .pyw

Conclusion

  • So we made a script to open your favorite course and set up your workspace.

  • We even made these scripts run on boot.

  • Any suggestions and criticism is welcomed , As i still have a long way to go before i perfect the art of python scripting.