Category : Python

Launch Your Favorite Game Anytime You Connect To Your Network!

IFTTT Recipe + Python Script + Dropbox =

Launch your favorite game anytime you connect to your home network with your android phone.

Ever been so excited from when you leave work or school to get home and play your favorite computer game ASAP? I know I have and when I get home I want my game opened NOW! Well today I bring to you a recipe I came up with over the holiday break!

Overview:

This recipe monitors your phone or tablet device to see if it is connected or disconnected from your home network.

Requirements:

  • A Smart Device such as Android or IOS
  • IFTTT Account with App installed on your Android or IOS device
  • Created the correct IFTTT recipe
  • Dropbox Installed on your computer
  • Python 2.7 Installed on your computer
  • This Python Script
  • AutoHotKey Installed on your computer (Optional)

The Python Code:

As you can see it’s a fairly small and easy python script the main points in which you’ll want to change/edit is what it does when you either disconnect or connect to your network. Launching an application is as easy as changing this line:
If you are just launching an application that line will be changed to the path of the program that you want to launch. If however, you wanted to say open up a youtube video and turn your volume all the way up, it would probably be easier for non-programmers to use another scripting language called: “AutoHotKey”. While I use any other language over AHK any day and any time, I still love AHK and it has it’s strengths in creating mouse/keyboard macros with relative ease and speed.

Example of an AutoHotKey script to un-mute your sound and open a youtube video:

As you can see it’s a really simple script. You can use it to open up a youtube video when you get home or open your favorite program. I hope you get lots of use out of this script. Feel free to message me things that you have used this python script for.

The IFTTT Recipe:

Now that you understand the main python script, lets take a look into the IFTTT recipe required to get this all working properly. The recipe is as follows:

  • Install IFTTT App onto your phone
  • Create a new IFTTT Recipe
  • IF: Android Phone Connects Or Disconnects from Any Network
  • Then: Create a text file in a Dropbox folder named:¬†Connected to {{SSID}} {{OccurredAt}}
  • Run the python script with dropbox installed onto the machine. Make sure you have the right path in the script to match the location of the text file created by the IFTTT Recipe

[Python 2.X] WordPress Page Creator

Description:

This python script logs into your wordpress, goes to the “Pages” section and creates your starting/foundation pages.

Requirements:

  • Python 2.7
  • BeautifulSoup
  • Mechanize

Setting up the text file:

  1. Create a text file named: “PagesToCreate.txt”
  2. Put “PagesToCreate.txt” in the same folder as the python script.
  3. Each line in the text file represents a new page. The text from each line is then used for the page title and content.

Useful for?

This quick script was designed for me to use when I have a new client that wants a wordpress site. I tend to have a lot of similar pages such as: Contact, About, Meet the Team, FAQ, etc… So to have a script create all my pages when I am creating a brand new wordpress site really helps.

The Python Code: