Introduction: Laptop Power Push Notification

Picture of Laptop Power Push Notification

I bet you came here because of your love of technology and automation? You want all your devices to be connected with each other as much as possible, and love the idea of them speaking together! So let me start with a quote from a blog post I stumbled upon the other day:

When your laptop is sitting on a table and you're doing some other
stuff in the meanwhile, it might quietly be running out of battery. In that case, you likely want to be nudged to find it a power outlet before it has to shut down or hibernate.
Wouldn't it be nice to get a push message on your phone (or even smartwatch, because hey, it's 2015)?
Quote from Dammit.nl

I personally thought this would be extremely useful, but was sad to see that this handy tip only applied to Linux users. So I decided on making a small script which does exactly the same for my Windows based laptop. The script will push a notification to all of your smart devices every 5 minutes, if your laptop power goes below 20%. Of course, these variables are quite easy to change in case you want more or less frequent notifications, a higher/lower power threshold or only want notifications on a single device.

In the following chapters, I will guide you through the setup on compiling and installing this simple tool, so that you can receive a notification on ANY device when your Windows laptop is running low on battery.

Step 1: Requirements

Picture of Requirements

In the following step, I will guide you on setting up the necessary tools and platforms. But first let us have a look at what is actually required for this this build.

  • A laptop with Windows OS (I have not tested this with Windows 10 yet. But in my experience, this type of script runs perfectly fine on any Windows operating system).
  • At least one 'smart' device (be it a smartphone, tablet or even a smartwatch - you can set it up on them all!)
  • A PushBullet account.
  • The AutoIT scripting platform.
  • My AutoIT script: http://pastebin.com/NnEAe8HE
  • A fair love of technology and automation.

That is basically all you need - it may seem complicated at first glance, but it is actually more easy than you can imagine. Now let us discuss how you set these things up properly.

Step 2: Pushbullet and Your Smart Devices

Picture of Pushbullet and Your Smart Devices

Here we will discuss how to setup your PushBullet account and how to add those devices which you want notifications on. This process will only take a few minutes to complete, but will require you to download the PushBullet application for your phone, tablet or smartwatch.

Take a look at the images above if you need visual assistance with any of the steps.

Sign up

The first step is to sign up to PushBullet from your computer. You can choose to sign up using a Gmail or a Facebook account. I suggest you to use your Gmail account if you are using Android smart devices - keeping things within the Google environment is by far the easiest solution.

After signing in, you will notice that you do not have any registered devices. Let us go ahead and register the devices you want to receive notifications on.

Register your devices

This is the step where you download the PushBullet app for your phone, tablet or even your smartwatch.

For iOS and Android, you simply visit the marketplace for apps and search "Pushbullet". It will appear as the first entry and will take only seconds to download. Keep in mind that this application is absolutely free!

For Windows Phone and BlackBerry, you need to visit https://pushbullet.com/apps, scroll down and download one of the community made applications. There is no official support for these platforms yet.

Once you have downloaded the application, you must open it and login with the same account as you did in the previous step. After doing so, you will notice your device appearing on the PushBullet website.

Repeat this step for every device you want to connect.

Step 3: Installing and Configuring the AutoIT Script

Picture of Installing and Configuring the AutoIT Script

This step guides you on how to install the AutoIT scripting language and how to edit my script to work with your devices. This step is much easier than it might sound, and I will guide you through each bit carefully.

Download & Install AutoIT

First you need to download the AutoIT install file. Go to http://autoitscript.com and visit their download page. Please note that AutoIT only runs on Windows machines.

Alternatively, you can download it using this direct link.

Now follow these 5 steps to install AutoIT on your computer.

  1. Launch the install file and you will be met with a classic installation wizard. Click next and agree with their Terms & Conditions for using this program.
  2. After this, you get to choose whether you want it to use native 32bit or 64bit tools by default. Choose x86 (32bit) which is recommended for compatibilty with this script. Click next.
  3. On the next page, be sure to select "Edit the script", so that it does not try and run the script when you double click on your AutoIT files. Click next.
  4. Choose the full instalation which is suggested by default. Click next.
  5. Choose a directory for installing AutoIT. The default one will do just fine. Click install.

Contratulations! You have now succesfully installed AutoIT on your computer and will be ready to move on to the next step.

Create the script

Now that you have installed AutoIT on your computer, create a new folder called "Laptop Power Notification". I suggest you to create the folder on your main directory in the "Programs" folder. Usually you will open "This Computer", go to "Local Disc (C:) and open the folder called "Programs". However, you can create this folder in any place you like.

Now, open this new folder and right click anywhere inside it and choose "New->AutoIt v3 Script". This will create a file for entering the script. Name it "Laptop Power Notification".

Right click your new AutoIt file and select "Edit". This will open your script editor. Delete everything that the file contains and save it.

Now go to http://pastebin.com/NnEAe8HE, scroll down to "RAW Paste Data" and copy the entire script. Then paste it into your AutoIt file and hit save.

Configure the script

This is the fun part! Now you have to configure the script to connect with your smart device(s). Do not worry if you have no programming experience, it is super easy and I will guide you through it.

Scroll down the script and look for "change these variables". Alternatively, you can press CTRL+F and do a search to find it a bit easier. These are the variables which you will have to change. The first variable is your PushBullet Access Token.

This is a random string of letters and numbers which you will find on your PushBullet account page: http://pushbullet.com/account

Copy this code and place it instead of "ACCESS TOKEN" - remember to keep the quotes.

The second variable is the timer between each battery check and notification. I recommend you to keep it at 300 seconds (5 minutes), but you can change this to whatever you want.

The third variable is the percentage of power the battery should reach before pushing the notification. I think 20% is a good number which gives you more than enough time to locate your laptop and plug in the power chord.

The last two variables are optional. If you want to only receive notifications on one device, then change the variable $vSendToAll to False and enter the DeviceID for that particular device. In order to find your DeviceID, you must open the PushBullet website, login and click on the device in the left column. Now you will find the ID as part of the current URL. Check the image above to see how it could look.

Creating the executable

First I would ask you to test the script to see if it works as it should. You can easily do this by changing the percentage of power to 100, so that the script will send you a notification even if your battery is fully charged. Unplug the power chord from your laptop and wait a few seconds. Then press F5 on your keyboard or choose "Tools->Go" from the menu.

You should now receive a notification on all of your connected devices!

If this is not the case, then go back to the previous step and make sure that your Access Token is correct. (As well as your DeviceID in case you only send notifications to one device). Feel free to comment with any questions if it does not work properly at this stage.

Now that you have succesfully received the notification(s), be sure to change your percentage variable back to the original amount. Now press F7 on your keyboard or select "Tools-Build" in the menu. This will create your executable.

That's it! You have succesfully create a Lapop Battery Notification tool. Now you simply run this program whenever you want to monitor your laptop battery.

But wait, how about we make this tool run automatically whenever your computer starts? Read below for an easy, optional guide on doing so.

Step 4: (Optional) Automatically Run Your Script on Startup

There is an easy solution if you want to run this program whenever you turn on your computer, and I will guide you through it in a few steps.

Right click the executable file and select "Create Shortcut". This will make a shortcut to your executable which we will move in a second.

Now go to this particular folder: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

If you are unable to find it, go to the Start Menu and enter the directory location in the search menu.

Finally, you simply copy the shortcut into this folder and it will automatically run whenever you turn on your computer. Fancy huh? :)

Step 5: Final Thoughts

Well that it! At this stage, you should have succesfully create the script and will start to receive notifications whenever your laptop is running low on battery.

Feel free to comment with any suggestions you might have or simply to let me know if you managed to follow this instructable. You can also post any questions in case you are unable to make it work properly, and I will do my best to help you out.

Thank you for reading my instructable and have fun with this new setup!

Comments

Edbed (author)2015-06-08

Neat idea!

Amruthan (author)Edbed2015-06-22

It was a nice one!
how do u get the notification beep
instead of just as a message

Amruthan (author)Amruthan2015-06-22

how to get the beep

MiCavaleri (author)Amruthan2015-06-25

In the PushBullet application on your phone, go to settings and select a notification sound. Then you will be able to choose what sound should play on notifications :)

About This Instructable

865views

13favorites

License:

Bio: I learned most of what I do by doing, but I also get a lot of inspiration from other Instructables and generally surfing on the ... More »
More by MiCavaleri:Laptop Power Push NotificationEasy keyboard fridge magnetsBitcoin Price Ticker (almost) from scratch using Arduino as ISP
Add instructable to: