PushBullet & AutoHotkey

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

Re: PushBullet & AutoHotkey

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: 628
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: PushBullet & AutoHotkey

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: 3019
Joined: 29 Sep 2013, 19:01

Re: PushBullet & AutoHotkey

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

Re: PushBullet & AutoHotkey

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

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

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

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

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: 17706
Joined: 21 Dec 2014, 02:44

Re: PushBullet & AutoHotkey

05 Mar 2022, 06:50

PushBullet no longer supports iOS devices. Is anyone aware of an alternative?
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: PushBullet & AutoHotkey

05 Mar 2022, 13:11

Looks promising. Thank you.
frosty3908
Posts: 3
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

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: 1601
Joined: 18 Apr 2014, 19:05
Contact:

Re: PushBullet & AutoHotkey

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: 3
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

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: 3
Joined: 20 Oct 2016, 03:33

Re: PushBullet & AutoHotkey

Today, 02:48

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

Return to “Tutorials (v1)”

Who is online

Users browsing this forum: No registered users and 9 guests