Page 1 of 2

PushBullet & AutoHotkey

Posted: 10 Oct 2014, 05:48
by jNizM
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

Re: PushBullet & AutoHotkey

Posted: 10 Oct 2014, 13:11
by joedf
Neat!

Re: PushBullet & AutoHotkey

Posted: 04 Jan 2015, 21:32
by flyingDman
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.

Re: PushBullet & AutoHotkey

Posted: 05 Jan 2015, 17:19
by flyingDman
Unfortunately, I also realized that you can't send multiline messages. Anyway that that can be fixed?

Re: PushBullet & AutoHotkey

Posted: 05 Jan 2015, 17:22
by joedf
Encode the new line characters?

Re: PushBullet & AutoHotkey

Posted: 05 Jan 2015, 17:29
by flyingDman
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)

Re: PushBullet & AutoHotkey

Posted: 05 Jan 2015, 23:23
by tmplinshi
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.

Re: PushBullet & AutoHotkey

Posted: 05 Jan 2015, 23:29
by joedf
@ tmplinshi thx, thats what i meant :P ;)

Re: PushBullet & AutoHotkey

Posted: 05 Jan 2015, 23:32
by tmplinshi
@joedf oh, haven't noticed your comment :P

Re: PushBullet & AutoHotkey

Posted: 06 Jan 2015, 01:36
by joedf
No, i meant thanks for clearing the idea haha ;)

Re: PushBullet & AutoHotkey

Posted: 06 Jan 2015, 01:51
by flyingDman
Thanks guys, but unfortunately that did not work.

Re: PushBullet & AutoHotkey

Posted: 06 Jan 2015, 02:24
by tmplinshi
Just tested in browser, and the "HTTP Debugger Pro" captured:
"body":"line1\nline2\nline 3"
so you know what to do. :)

Re: PushBullet & AutoHotkey

Posted: 06 Jan 2015, 11:22
by flyingDman
Perfect! that works (used an example with join\n). Thanks!

Update the code to support multiline

Posted: 17 May 2015, 04:08
by arunsathiya
Can you please update the original code in this post to support multiline? Thank you.

Re: Update the code to support multiline

Posted: 17 May 2015, 04:58
by arunsathiya
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. :)

Re: PushBullet & AutoHotkey

Posted: 02 Jan 2016, 08:13
by LazyRobot
How about Sending notifications to Autohotkey on my PC from Pushbullet on my phone?

Re: PushBullet & AutoHotkey

Posted: 15 Jan 2016, 19:23
by AllUrBaseRBelong2Us
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

Re: PushBullet & AutoHotkey

Posted: 15 Jan 2016, 19:46
by joedf
:3

Re: PushBullet & AutoHotkey

Posted: 17 Mar 2016, 18:51
by Testicleese
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?

Re: PushBullet & AutoHotkey

Posted: 22 Jun 2017, 06:57
by sebalotek
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: