Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| user:geek:streamdeck [2022-09-29 13:40] – geek | user:geek:streamdeck [2025-07-18 13:57] (current) – geek | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Stream Deck Ideas ====== | ====== Stream Deck Ideas ====== | ||
| + | |||
| + | <code autohotkey> | ||
| + | #Include < | ||
| + | |||
| + | Persistent | ||
| + | |||
| + | ; From WebViewToo | ||
| + | ParseUri(Uri) { | ||
| + | static Pattern := " | ||
| + | if (!RegExMatch(String(Uri), | ||
| + | return | ||
| + | } | ||
| + | Parsed := {} | ||
| + | Parsed.Scheme := Match[" | ||
| + | Parsed.Port := Match[" | ||
| + | Parsed.Fragment := Match[" | ||
| + | return Parsed | ||
| + | } | ||
| + | |||
| + | ; From https:// | ||
| + | UrlUnescape(url) { | ||
| + | if r := DllCall(" | ||
| + | throw OsError(r) | ||
| + | return url | ||
| + | } | ||
| + | |||
| + | RecvLine(this, | ||
| + | newlinePos := 0 | ||
| + | ; MsgSize should block until some size is available. If there is | ||
| + | ; an error, it returns early with zero. | ||
| + | while size := this.MsgSize() { | ||
| + | ; Peek at what's in the buffer and only break when a | ||
| + | ; full line is available | ||
| + | this._recv(buf := Buffer(size), | ||
| + | if newlinePos := InStr(StrGet(buf, | ||
| + | break | ||
| + | Sleep 1 | ||
| + | } | ||
| + | this._recv(buf := Buffer(newlinePos), | ||
| + | data := StrGet(buf, encoding) | ||
| + | return keepEnd ? data : RTrim(data, ' | ||
| + | } | ||
| + | |||
| + | class DeckServer extends Socket.Server { | ||
| + | onACCEPT(err) { | ||
| + | client := this.AcceptAsClient() | ||
| + | request := StrSplit(RecvLine(client), | ||
| + | |||
| + | if request[1] != ' | ||
| + | client.SendText(' | ||
| + | Sleep 50 | ||
| + | return | ||
| + | } | ||
| + | |||
| + | uri := ParseUri(request[2]) | ||
| + | fname := LTrim(UrlUnescape(uri.Path), | ||
| + | |||
| + | if !(Buttons.HasOwnProp(fname)) { | ||
| + | client.SendText(' | ||
| + | Sleep 50 | ||
| + | return | ||
| + | } | ||
| + | |||
| + | args := Map() | ||
| + | for pair in StrSplit(uri.Query, | ||
| + | pair := StrSplit(pair, | ||
| + | args[UrlUnescape(pair[1])] := UrlUnescape(pair[2]) | ||
| + | } | ||
| + | |||
| + | SetTimer () => Buttons.%fname%(args), | ||
| + | client.SendText(' | ||
| + | Sleep 50 | ||
| + | return | ||
| + | } | ||
| + | } | ||
| + | |||
| + | server := DeckServer(1337, | ||
| + | |||
| + | ; --- User Functions --- | ||
| + | |||
| + | class Buttons { | ||
| + | static Example(args) | ||
| + | { | ||
| + | MsgBox args[' | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| Window Management: | Window Management: | ||