Skip to content

Instantly share code, notes, and snippets.

@ccloli
Created April 21, 2024 17:19
Show Gist options
  • Save ccloli/1f7eab00005db0a6c3f66291d1febdbf to your computer and use it in GitHub Desktop.
Save ccloli/1f7eab00005db0a6c3f66291d1febdbf to your computer and use it in GitHub Desktop.
A simple GUI script to turn off ASW, without pressing keyboard everytime.
#Requires AutoHotkey v2.0
actionTexts := Map()
actionTexts["1"] := "Disable ASW"
actionTexts["2"] := "Force 45 FPS without ASW"
actionTexts["3"] := "Force 45 FPS with ASW"
actionTexts["4"] := "Enable ASW Auto"
msg := ""
msgId := 0.0
title := "Oculus Link ASW Mode Switch"
isOnTop := False
MyGui := Gui(, title)
MyGui.setFont("s32")
For key , text in actionTexts
MyGui.Add("Button", "default w800", text).OnEvent("Click", SimulateAction.Bind(key))
MyGui.Add("Button", "default w800", "Toggle Always On Top").OnEvent("Click", ToggleAlwaysOnTop)
MyGui.Add("Text", "vMessage w800", msg)
MyGui.Show()
SimulateAction(action, *) {
SendMode "Event"
Switch action {
Case "1": Send ">^{Numpad1}"
Case "2": Send ">^{Numpad2}"
Case "3": Send ">^{Numpad3}"
Case "4": Send ">^{Numpad4}"
}
ShowMessage("[" . action . "] " . actionTexts.get(action))
}
ToggleAlwaysOnTop(*) {
global isOnTop := !isOnTop
WinSetAlwaysOnTop(isOnTop, myGui)
MyGui.Title := (isOnTop ? "[*] " : "") . title
ShowMessage((isOnTop ? "[ON]" : "[OFF]") . " Always On Top")
}
ShowMessage(text, time := 1000) {
MyGui["Message"].Text := text
curMsgId := Random()
global msgId := curMsgId
SetTimer(ClearMessage, time > 0 ? -time : time)
ClearMessage() {
if (curMsgId == msgId) {
MyGui["Message"].Text := ""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment