PushBullet & AutoHotkey

Helpful script writing tricks and HowTo's
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
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] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: PushBullet & AutoHotkey

10 Oct 2014, 13:11

Neat!
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

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.
14.3 & 1.3.7
User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

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?
14.3 & 1.3.7
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
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, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

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)
14.3 & 1.3.7
tmplinshi
Posts: 1604
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: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
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, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
tmplinshi
Posts: 1604
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: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
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, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

Re: PushBullet & AutoHotkey

06 Jan 2015, 01:51

Thanks guys, but unfortunately that did not work.
14.3 & 1.3.7
tmplinshi
Posts: 1604
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: 2776
Joined: 29 Sep 2013, 19:01

Re: PushBullet & AutoHotkey

06 Jan 2015, 11:22

Perfect! that works (used an example with join\n). Thanks!
14.3 & 1.3.7
arunsathiya
Posts: 2
Joined: 17 May 2015, 04:04

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

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: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: PushBullet & AutoHotkey

15 Jan 2016, 19:46

:3
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Testicleese
Posts: 3
Joined: 14 Mar 2016, 21:32
Contact:

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 (v1)”

Who is online

Users browsing this forum: No registered users and 36 guests