181 lines
2.9 KiB
AutoHotkey
181 lines
2.9 KiB
AutoHotkey
#SingleInstance force ; Only one instance at a time
|
|
FileEncoding, UTF-8 ; Makes sure special characters dont break stuff
|
|
|
|
|
|
global userID := "userID from the desktop software webhook page"
|
|
|
|
|
|
If (A_Args[1] = "off")
|
|
{
|
|
off()
|
|
ExitApp
|
|
}
|
|
|
|
if A_Args[3] is number
|
|
{
|
|
length := A_Args[3]
|
|
} else
|
|
{
|
|
length := 0
|
|
}
|
|
|
|
|
|
Switch A_Args[1]
|
|
{
|
|
Case "s":
|
|
solid(A_Args[2], length)
|
|
Case "b":
|
|
blink(A_Args[2], length)
|
|
Case "p":
|
|
patt(A_Args[2], length)
|
|
Default:
|
|
MsgBox,, Flag, % "Incorrect parameters passed to script: " A_Args[1] ", " A_Args[2] ", " length
|
|
}
|
|
|
|
|
|
solid(input, length)
|
|
{
|
|
Switch input
|
|
{
|
|
Case "red", "green", "yellow", "blue", "white", "cyan", "magenta":
|
|
json_str =
|
|
(
|
|
{
|
|
"userId": "%userID%",
|
|
"actionFields":{
|
|
"color": "%input%"
|
|
}
|
|
}
|
|
)
|
|
Default:
|
|
json_str =
|
|
(
|
|
{
|
|
"userId": "%userID%",
|
|
"actionFields":{
|
|
"color": "custom",
|
|
"custom_color": "%input%"
|
|
}
|
|
}
|
|
)
|
|
}
|
|
translate("https://api.luxafor.com/webhook/v1/actions/solid_color", json_str, length)
|
|
}
|
|
|
|
blink(input, length)
|
|
{
|
|
If (length = 0)
|
|
{
|
|
length := 1000000
|
|
}
|
|
|
|
Switch input
|
|
{
|
|
Case "red", "green", "yellow", "blue", "white", "cyan", "magenta":
|
|
color := input
|
|
Default:
|
|
MsgBox % input " is not an accepted input"
|
|
ExitApp
|
|
}
|
|
json_str =
|
|
(
|
|
{
|
|
"userId": "%userID%",
|
|
"actionFields":{
|
|
"color": "%color%"
|
|
}
|
|
}
|
|
)
|
|
translate("https://api.luxafor.com/webhook/v1/actions/blink", json_str, length)
|
|
}
|
|
|
|
patt(input, length)
|
|
{
|
|
If (length = 0)
|
|
{
|
|
length := 1000000
|
|
}
|
|
|
|
Switch input
|
|
{
|
|
Case "police", "rainbow", "sea", "synthetic":
|
|
pattern := input
|
|
Case "traffic_lights":
|
|
pattern := "traffic lights"
|
|
Case "white_wave":
|
|
pattern := "white wave"
|
|
Case "random":
|
|
Random, rando, 1, 5
|
|
pattern := "random " rando
|
|
Case "random1":
|
|
pattern := "random 1"
|
|
Case "random2":
|
|
pattern := "random 2"
|
|
Case "random3":
|
|
pattern := "random 3"
|
|
Case "random4":
|
|
pattern := "random 4"
|
|
Case "random5":
|
|
pattern := "random 5"
|
|
Default:
|
|
MsgBox % input " is not an accepted input"
|
|
ExitApp
|
|
}
|
|
json_str =
|
|
(
|
|
{
|
|
"userId": "%userID%",
|
|
"actionFields":{
|
|
"pattern": "%pattern%"
|
|
}
|
|
}
|
|
)
|
|
translate("https://api.luxafor.com/webhook/v1/actions/pattern", json_str, length)
|
|
}
|
|
|
|
translate(url, data, length)
|
|
{
|
|
If (length = 0)
|
|
{
|
|
req(url, data)
|
|
ExitApp
|
|
} Else {
|
|
time_to_run := length * 1000
|
|
start_time := A_TickCount
|
|
end_time := start_time + time_to_run
|
|
while (A_tickcount < end_time) {
|
|
req(url, data)
|
|
}
|
|
}
|
|
|
|
If (InStr(url, "solid"))
|
|
{
|
|
Sleep, (length * 1000)
|
|
off()
|
|
}
|
|
}
|
|
|
|
off()
|
|
{
|
|
data =
|
|
(
|
|
{
|
|
"userId": "%userID%",
|
|
"actionFields":{
|
|
"color": "custom",
|
|
"custom_color": "000000"
|
|
}
|
|
}
|
|
)
|
|
url := "https://api.luxafor.com/webhook/v1/actions/solid_color"
|
|
req(url, data)
|
|
}
|
|
|
|
req(url, data)
|
|
{
|
|
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
|
|
whr.Open("POST", url, false)
|
|
whr.SetRequestHeader("Content-Type", "application/json")
|
|
whr.Send(data)
|
|
whr.WaitForResponse()
|
|
} |