PushBullet & AutoHotkey

Helpful script writing tricks and HowTo's
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: PushBullet & AutoHotkey

Post by Delta Pythagorean » 26 Aug 2017, 18:28

Alright, it's clearly established that this function can send a message, what about reading a message that was sent from another user?

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: PushBullet & AutoHotkey

Post by Delta Pythagorean » 26 Aug 2017, 18:46

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)
Sending a message with a new line can simply be done by switching out the `n to \n.
Similarly, you can do this to most (Not tested) other escape messages.
Hope this helps!

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


User avatar
flyingDman
Posts: 3072
Joined: 29 Sep 2013, 19:01

Re: PushBullet & AutoHotkey

Post by flyingDman » 12 Sep 2017, 13:48

Thanks. That seems to be the same solution as tmplinshi provided.

It seems that you have an interest for Pushbullet. Have you (or anybody else) found how to push a file?
14.3 & 1.3.7

User avatar
joedf
Posts: 9161
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: PushBullet & AutoHotkey

Post by joedf » 12 Sep 2017, 16:41

API seems pretty straight forward
For a file (see lower on the page):
https://docs.pushbullet.com/#create-push
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
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Using PushBullet & AutoHotkey to send a file

Post by Blackholyman » 14 Sep 2017, 07:30

Example of Pushing a file

Code: Select all

#Include CreateFormData.ahk ; https://gist.github.com/tmplinshi/8428a280bba58d25ef0b
#Include BinArr.ahk ; https://gist.github.com/tmplinshi/a97d9a99b9aa5a65fd20
#Include JSON.ahk ; https://github.com/cocobelgica/AutoHotkey-JSON/blob/master/JSON.ahk

image_path := "C:\Blue Cube.png"

PB_Token   := "...Pease enter your own..."
PB_Image_Name   := "Blue Cube.png"

JSON_Response := PB_PushUpload_request(PB_Token, PB_Image_Name)

JSON_Response_object := JSON.load( JSON_Response )

objParam := { "file": [image_path]}
CreateFormData(postData, hdr_ContentType, objParam)

Status := PB_PushUpload_formData(JSON_Response_object.upload_url, postData, hdr_ContentType)
if (Status != 204)
{
	msgbox % "Upload Error!"
	return
}

msgbox % PB_PushFile(PB_Token, "This is an image test", JSON_Response_object.file_name, JSON_Response_object.file_type, JSON_Response_object.file_url)
return

PB_PushUpload_request(PB_Token, PB_Image_Name)
{
	WinHTTP := ComObjCreate("WinHTTP.WinHttpRequest.5.1")
	WinHTTP.SetProxy(0)
	WinHTTP.Open("POST", "https://api.pushbullet.com/v2/upload-request", 0)
	WinHTTP.SetCredentials(PB_Token, "", 0)
	WinHTTP.SetRequestHeader("Content-Type", "application/json")
	PB_Body := "{""file_name"": """ PB_Image_Name """, ""file_type"": ""image/png""}"
	WinHTTP.Send(PB_Body)
	Result := WinHTTP.ResponseText
	Status := WinHTTP.Status
	return Result
}

PB_PushUpload_formData(PB_upload_url, PB_postData, PB_ContentType)
{
	WinHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	WinHTTP.Open("POST", PB_upload_url, true)
	WinHTTP.SetRequestHeader("Content-Type", PB_ContentType)
	WinHTTP.Option(6) := False ; No auto redirect
	WinHTTP.Send(PB_postData)
	WinHTTP.WaitForResponse()
	Result := WinHTTP.ResponseText
	Status := WinHTTP.Status
	return Status
}

PB_PushFile(PB_Token, PB_Body, PB_file_name, PB_file_type, PB_file_url)
{
	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"": ""file"", ""body"": """ PB_Body """, ""file_name"": """ PB_file_name """, ""file_type"": """ PB_file_type """, ""file_url"": """ PB_file_url """}"
	WinHTTP.Send(PB_Body)
	Result := WinHTTP.ResponseText
	Status := WinHTTP.Status
	return Status
}
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:

Guest

Re: PushBullet & AutoHotkey

Post by Guest » 22 Dec 2017, 13:07

Maybe someone come in handy ... Works without glitches.

Code: Select all

PB_PushNote( PB_Token, PB_Message, PB_Number, PB_SourceUserID, PB_TargetDivaceID )
{
    WinHTTP := ComObjCreate("WinHTTP.WinHttpRequest.5.1")
    WinHTTP.SetProxy(0)
    WinHTTP.Open("POST", "https://api.pushbullet.com/v2/ephemerals", 0)
    WinHTTP.SetCredentials(PB_Token, "", 0)
    WinHTTP.SetRequestHeader("Content-Type", "application/json")
    PB_Body := "{""push"": {""conversation_iden"": """ PB_Number """, ""message"": """ PB_Message """, ""package_name"": ""com.pushbullet.android"", ""source_user_iden"": """ PB_SourceUserID """, ""target_device_iden"": """ PB_TargetDivaceID """, ""type"": ""messaging_extension_reply""}, ""type"": ""push""}"
    WinHTTP.Send(PB_Body)
    Result := WinHTTP.ResponseText
    Status := WinHTTP.Status
    Return Status
}

downloaderfan
Posts: 34
Joined: 09 Jun 2017, 09:19

Re: PushBullet & AutoHotkey

Post by downloaderfan » 11 Jan 2018, 13:12

Does anyone have the code for receiving notifications from other devices in order to trigger ahk scripts? i.e. I send a Pushbullet notification containing specific text from my Android phone to PC & that triggers the AHK script actions.

icolinb
Posts: 4
Joined: 27 Dec 2015, 12:47

Re: PushBullet & AutoHotkey

Post by icolinb » 05 Feb 2018, 13:53

Hi, I have tried but failed, is there anyway that I can use Pushbullet script without getting the Response Msg windows from appearing with the status.

User avatar
boiler
Posts: 17696
Joined: 21 Dec 2014, 02:44

Re: PushBullet & AutoHotkey

Post by boiler » 05 Mar 2022, 06:50

PushBullet no longer supports iOS devices. Is anyone aware of an alternative?


User avatar
boiler
Posts: 17696
Joined: 21 Dec 2014, 02:44

Re: PushBullet & AutoHotkey

Post by boiler » 05 Mar 2022, 13:11

Looks promising. Thank you.

frosty3908
Posts: 4
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

Post by frosty3908 » 05 Nov 2024, 06:20

Can anyone tell me why in the example code this line is required for the push notification to be sent to the phone?
MsgBox % PB_PushNote(PB_Token, PB_Title, PB_Message)

It works fine with it, but I don't want a msgbox on the pc to popup, and if I remove it, I get no notification on phone?

User avatar
Chunjee
Posts: 1650
Joined: 18 Apr 2014, 19:05
Contact:

Re: PushBullet & AutoHotkey

Post by Chunjee » 05 Nov 2024, 09:16

do you still have PB_PushNote(PB_Token, PB_Title, PB_Message) or did you remove the entire line?

frosty3908
Posts: 4
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

Post by frosty3908 » 06 Nov 2024, 01:31

Chunjee wrote:
05 Nov 2024, 09:16
do you still have PB_PushNote(PB_Token, PB_Title, PB_Message) or did you remove the entire line?
Removed the entire line... so I need to just remove MsgBox %( and )?

frosty3908
Posts: 4
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

Post by frosty3908 » 10 Nov 2024, 02:48

Could anyone explain this for me? I'm not great at this stuff but I do want to learn

User avatar
Chunjee
Posts: 1650
Joined: 18 Apr 2014, 19:05
Contact:

Re: PushBullet & AutoHotkey

Post by Chunjee » 11 Nov 2024, 16:21

Can't see your code. Sounds like you deleted both the msgbox and the function call. If you want the pushbullet call and not the msgbox, you will need to add back the code that was removed.

frosty3908
Posts: 4
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

Post by frosty3908 » 11 Nov 2024, 18:29

Chunjee wrote:
11 Nov 2024, 16:21
Can't see your code. Sounds like you deleted both the msgbox and the function call. If you want the pushbullet call and not the msgbox, you will need to add back the code that was removed.
The code I'm using is just the example code.
It seems that if I remove the MsgBox while leaving the remaining line I'll just have the same call twice?
So to be clear, the example code was unchanged and had:
MsgBox % PB_PushNote(PB_Token, PB_Title, PB_Message)
PB_PushNote(PB_Token, PB_Title, PB_Message)
But I didn't want a msgbox popping up so removed the first line, this stopped it working (no push received).
If I remove just the Msgbox % then I'd have the same call twice in a row wouldn't I? eg;
PB_PushNote(PB_Token, PB_Title, PB_Message)
PB_PushNote(PB_Token, PB_Title, PB_Message)

Post Reply

Return to “Tutorials (v1)”