Push notifications when your compile finishes: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(wrote article)
m (clean up, added orphan, deadend tags)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Image:Phonenot 2.png|right|thumb|300px|What the notification looks like]]
{{Multiple issues|
{{Dead end|date=January 2024}}
{{Orphan|date=January 2024}}
}}
 
[[File:Phonenot 2.png|right|thumb|300px|What the notification looks like]]


Because compiling a map can take multiple hours, it's often necessary to step away from the computer while it's compiling. By following this tutorial, you can get a push notification on your phone when your compile finishes.
Because compiling a map can take multiple hours, it's often necessary to step away from the computer while it's compiling. By following this tutorial, you can get a push notification on your phone when your compile finishes.


This tutorial requires you have [https://www.autohotkey.com/ AutoHotKey] installed and working.
This tutorial requires you have [https://www.autohotkey.com/ AutoHotKey] installed and working.
{{note|This works for all [[Source]] engine branches (and possibly [[GoldSrc]])}}


== Setting up Pushbullet ==
== Setting up Pushbullet ==
In order to get notifications on your phone, we will be using [https://www.pushbullet.com/ Pushbullet]. Install the application on your phone (from the App Store or your phone's equivalent) , create an account, and allow it access to notifications.  
In order to get notifications on your phone, we will be using [https://www.pushbullet.com/ Pushbullet]. Install the application on your phone (from the App Store or your phone's equivalent), create an account, and allow it access to notifications.


Next, visit https://www.pushbullet.com/ and sign in. Once you have signed in, select "Settings" on the left, and then press the button labeled "Create Access Token" on the right. Copy the token it provides.
Next, visit https://www.pushbullet.com/ and sign in. Once you have signed in, select "Settings" on the left, and then press the button labeled "Create Access Token" on the right. Copy the token it provides.


== Creating the AutoHotKey executable ==
== Creating the AutoHotKey executable ==
Now we need to create the executable that hammer will run. With [https://www.autohotkey.com/ AutoHotKey] installed, right-click in the folder you want to keep the executable in and click New -> Autohotkey script. Name the file <code>compileNotification.ahk.</code>
Now we need to create the executable that hammer will run. With [https://www.autohotkey.com/ AutoHotKey] installed, right-click in the folder you want to keep the executable in and select New -> Autohotkey script. Name the file <code>compileNotification.ahk.</code>


Open the script (Double-clicking it will run it, right-click it and open with your text editor of choice), delete everything already inside the script, and paste in this code:
Open the script (Double-clicking it will run it, right-click it and open with your text editor of choice), delete everything already inside the script, and paste in this code:
Line 36: Line 39:
}
}
Exit</pre>
Exit</pre>
Make sure to replace "YOUR TOKEN HERE" with the access token we got from Pushbullet, then save the script and close your text editor.
Make sure to replace "YOUR TOKEN HERE" with the access token you got from Pushbullet, then save the script and close your text editor.


Finally, right-click on your .ahk file inside the file browser and press "Compile Script". This will take a moment, but once it is done, you will have a file called <code>compileNotification.exe</code>. If you double-click on it to run it, you should get a notification on your phone saying "Compile Done". On your computer, a box should appear saying "200". This means the  
Finally, right-click on your .ahk file inside the file browser and press "Compile Script". This will take a moment, but once it is done, you will have a file called <code>compileNotification.exe</code>. If you double-click on it to run it, you should get a notification on your phone saying "Compile Done". On your computer, a box should appear saying "200". This means the notification was sent successfully.


''Code from https://www.autohotkey.com/boards/viewtopic.php?t=4842''
''Code from https://www.autohotkey.com/boards/viewtopic.php?t=4842''
== Adding the script to Hammer ==
== Adding the script to Hammer ==


[[Image:Phonenots 1.png|right|thumb|500px|Inside the Expert compile window, press "New" then add the path to your .exe (with the .exe name) in the commands window.]]
[[File:Phonenots 1.png|right|thumb|500px|Inside the Expert compile window, press "New" then add the path to your .exe (with the .exe name) in the commands window.]]
 
Finally, we need to add the executable to Hammer so that it is run when our compilation finishes. Press F9 to open the Run Map window, then select "Expert" to open the expert compile menu. Select the compile type you want to use from the dropdown, then press "New". This will add a new step to the compile. In the "Command" box on the right, provide the path to the executable. This example uses <code>C:\Users\Dashz\Documents\Macros\compileNotification.exe</code>, but you should change it with the path to your executable. You do not need any parameters.


Finally, we need to add the executable to hammer so that it is run when our compilation finishes. Press F9 to open the Run Map window, then select "Expert" to open the expert compile menu. Select the compile type you want to use from the dropdown, then press "New". This will add a new step to the compile. In the "Command" box on the right, provide the path to the executable. This example uses <code>C:\Users\Dashz\Documents\Macros\compileNotification.exe</code>. You do not need any parameters.
'''You are all set!''' Now, when you finish compiling, you will get a notification on your phone.


You are all set! Now, when you finish compiling, you will get a notification on your phone.
[[Category:Tutorials]]

Latest revision as of 10:08, 21 January 2024

Wikipedia - Letter.png
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
What the notification looks like

Because compiling a map can take multiple hours, it's often necessary to step away from the computer while it's compiling. By following this tutorial, you can get a push notification on your phone when your compile finishes.

This tutorial requires you have AutoHotKey installed and working.

Setting up Pushbullet

In order to get notifications on your phone, we will be using Pushbullet. Install the application on your phone (from the App Store or your phone's equivalent), create an account, and allow it access to notifications.

Next, visit https://www.pushbullet.com/ and sign in. Once you have signed in, select "Settings" on the left, and then press the button labeled "Create Access Token" on the right. Copy the token it provides.

Creating the AutoHotKey executable

Now we need to create the executable that hammer will run. With AutoHotKey installed, right-click in the folder you want to keep the executable in and select New -> Autohotkey script. Name the file compileNotification.ahk.

Open the script (Double-clicking it will run it, right-click it and open with your text editor of choice), delete everything already inside the script, and paste in this code:

PB_Token   := "YOUR TOKEN HERE"
PB_Title   := "Compile Done"
PB_Message := "Come back!"

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
}
Exit

Make sure to replace "YOUR TOKEN HERE" with the access token you got from Pushbullet, then save the script and close your text editor.

Finally, right-click on your .ahk file inside the file browser and press "Compile Script". This will take a moment, but once it is done, you will have a file called compileNotification.exe. If you double-click on it to run it, you should get a notification on your phone saying "Compile Done". On your computer, a box should appear saying "200". This means the notification was sent successfully.

Code from https://www.autohotkey.com/boards/viewtopic.php?t=4842

Adding the script to Hammer

Inside the Expert compile window, press "New" then add the path to your .exe (with the .exe name) in the commands window.

Finally, we need to add the executable to Hammer so that it is run when our compilation finishes. Press F9 to open the Run Map window, then select "Expert" to open the expert compile menu. Select the compile type you want to use from the dropdown, then press "New". This will add a new step to the compile. In the "Command" box on the right, provide the path to the executable. This example uses C:\Users\Dashz\Documents\Macros\compileNotification.exe, but you should change it with the path to your executable. You do not need any parameters.

You are all set! Now, when you finish compiling, you will get a notification on your phone.