PushBullet & AutoHotkey

Helpful script writing tricks and HowTo's
User avatar
jNizM
Posts: 2334
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

PushBullet & AutoHotkey

10 Oct 2014, 05:48

Image

1. Visit https://www.pushbullet.com/ and register with your Google-Account
2. Install Pushbullet App (iPhone or Android)
3. Visit https://www.pushbullet.com/account and get Access Token (e.g. G8aldIDL93ldFADFwp9032ADF2klj3ld)
4. Include your Access Token & Run Test Script


Example: Push to a device [Note] (Title & Body)

Code: Select all

PB_Token   := "G8aldIDL93ldFADFwp9032ADF2klj3ld"
PB_Title   := "Test Push (Note)"
PB_Message := "Test Message Pushbullet meets AutoHotkey"

MsgBox % PB_PushNote(PB_Token, PB_Title, PB_Message)

PB_PushNote(PB_Token, PB_Title, PB_Message)
{
	WinHTTP := ComObjCreate("WinHTTP.WinHttpRequest.5.1")
	WinHTTP.SetProxy(0)
	WinHTTP.Open("POST", "https://api.pushbullet.com/v2/pushes", 0)
	WinHTTP.SetCredentials(PB_Token, "", 0)
	WinHTTP.SetRequestHeader("Content-Type", "application/json")
	PB_Body := "{""type"": ""note"", ""title"": """ PB_Title """, ""body"": """ PB_Message """}"
	WinHTTP.Send(PB_Body)
	Result := WinHTTP.ResponseText
	Status := WinHTTP.Status
	return Status
}
Example: Push to a device [Link] (Title, Body & Url)
Spoiler
Example: Push to a device [Checklist] (Title, Items)
Spoiler

Pushbullet APIs:
- /v2/pushes - Push to a device/user or list existing pushes.
- /v2/devices - List or create devices that can be pushed to.
- /v2/contacts - List your Pushbullet contacts.
- /v2/subscriptions - Channels that the user has subscribed to.
- /v2/users/me - Get information about the current user.

HTTP Status Code
- 200 OK - Everything worked as expected.
- 400 Bad Request - Usually this results from missing a required parameter.
- 401 Unauthorized - No valid access token provided.
- 403 Forbidden - The access token is not valid for that request.
- 404 Not Found - The requested item doesn't exist.
- 5XX Server Error - Something went wrong on Pushbullet's side.



Have fun & feel free to add more functions or create a complete class
[AHK] 1.1.30.00 x64 Unicode | [WIN] 10 Pro (Version 1803) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
joedf
Posts: 6619
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: PushBullet & AutoHotkey

10 Oct 2014, 13:11

Neat!
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
flyingDman
Posts: 73
Joined: 29 Sep 2013, 19:01
Location: Burbank, California

Re: PushBullet & AutoHotkey

04 Jan 2015, 21:32

Thanks. Just realized you posted this several months ago. I was using the code provided here: http://www.autohotkey.com/board/topic/1 ... fications/. I use it all the time. Very convenient. Your code simplifies it.
User avatar
flyingDman
Posts: 73
Joined: 29 Sep 2013, 19:01
Location: Burbank, California

Re: PushBullet & AutoHotkey

05 Jan 2015, 17:19

Unfortunately, I also realized that you can't send multiline messages. Anyway that that can be fixed?
User avatar
joedf
Posts: 6619
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: PushBullet & AutoHotkey

05 Jan 2015, 17:22

Encode the new line characters?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
flyingDman
Posts: 73
Joined: 29 Sep 2013, 19:01
Location: Burbank, California

Re: PushBullet & AutoHotkey

05 Jan 2015, 17:29

I want to be able to do PB_Message := clipboard. If the clipboard content includes a `n or `r it throws an error (the other code I referred to does this well)
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: PushBullet & AutoHotkey

05 Jan 2015, 23:23

flyingDman wrote:I want to be able to do PB_Message := clipboard. If the clipboard content includes a `n or `r it throws an error (the other code I referred to does this well)
UriEncode(PB_Message) might work, which will convert `r`n to %0D%0A.
User avatar
joedf
Posts: 6619
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: PushBullet & AutoHotkey

05 Jan 2015, 23:29

@ tmplinshi thx, thats what i meant :P ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: PushBullet & AutoHotkey

05 Jan 2015, 23:32

@joedf oh, haven't noticed your comment :P
User avatar
joedf
Posts: 6619
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: PushBullet & AutoHotkey

06 Jan 2015, 01:36

No, i meant thanks for clearing the idea haha ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
flyingDman
Posts: 73
Joined: 29 Sep 2013, 19:01
Location: Burbank, California

Re: PushBullet & AutoHotkey

06 Jan 2015, 01:51

Thanks guys, but unfortunately that did not work.
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: PushBullet & AutoHotkey

06 Jan 2015, 02:24

Just tested in browser, and the "HTTP Debugger Pro" captured:
"body":"line1\nline2\nline 3"
so you know what to do. :)
User avatar
flyingDman
Posts: 73
Joined: 29 Sep 2013, 19:01
Location: Burbank, California

Re: PushBullet & AutoHotkey

06 Jan 2015, 11:22

Perfect! that works (used an example with join\n). Thanks!
arunsathiya
Posts: 2
Joined: 17 May 2015, 04:04
Google: http://www.google.com/+ArunSathiya

Update the code to support multiline

17 May 2015, 04:08

Can you please update the original code in this post to support multiline? Thank you.
arunsathiya
Posts: 2
Joined: 17 May 2015, 04:04
Google: http://www.google.com/+ArunSathiya

Re: Update the code to support multiline

17 May 2015, 04:58

arunsathiya wrote:Can you please update the original code in this post to support multiline? Thank you.
Quick update. I just added "StringReplace, %output_variable_name%, %input_variable_name%, `r`n, \n, All" without quotes and now, the script supports multiline. :)
LazyRobot

Re: PushBullet & AutoHotkey

02 Jan 2016, 08:13

How about Sending notifications to Autohotkey on my PC from Pushbullet on my phone?
AllUrBaseRBelong2Us
Posts: 35
Joined: 09 Nov 2015, 11:15

Re: PushBullet & AutoHotkey

15 Jan 2016, 19:23

Look at what the Response Body returns when I send invalid params:

Code: Select all

{"error":{"code":"","type":"invalid_request","message":"Failed to decode JSON body.","cat":"(=^‥^=)"}}
I love it when devs sneak in some easter eggs like this. :P
User avatar
joedf
Posts: 6619
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: PushBullet & AutoHotkey

15 Jan 2016, 19:46

:3
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
Testicleese
Posts: 3
Joined: 14 Mar 2016, 21:32
GitHub: Penetros

Re: PushBullet & AutoHotkey

17 Mar 2016, 18:51

Curious if anyone has a solution for this.

I wish to send out an image (that part is easily covered with what's here and the API)

Where I'm lost however is like LazyRobot asked, how would we receive back push notifications with this?
sebalotek
Posts: 3
Joined: 17 Dec 2014, 06:52

Re: PushBullet & AutoHotkey

22 Jun 2017, 06:57

jNizM wrote:Image
Hey jNizM, I'm only 3 years late to this here AHK/Pushbullet partay, but just wanted to say 'thank you!!'

It helped me solve this problem I had 3 years ago -
https://autohotkey.com/boards/viewtopic ... 415#p32415
IMO a Pushbullet Notification is much better than an email for a quick 'flagging up' of something anyway.

I think this combo is very powerful!!

:clap: :dance: :clap:

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 7 guests