-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added Basic Window Switcher Hotkeys, like Basic Global Hotkeys exce…
…pt not registered as global hotkeys with Windows
- Loading branch information
Joe Thaler
committed
Feb 15, 2022
1 parent
0cf1916
commit d3173a4
Showing
4 changed files
with
416 additions
and
0 deletions.
There are no files selected for viewing
170 changes: 170 additions & 0 deletions
170
Basic Window Switcher Hotkeys/BasicWindowSwitcherHotkeys.Session.iss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
objectdef bwshSession | ||
{ | ||
variable taskmanager TaskManager=${LMAC.NewTaskManager["bwshSession"]} | ||
|
||
variable jsonvalue SlotHotkeys="[]" | ||
variable bool Enabled=0 | ||
variable bool HotkeyInstalled | ||
variable filepath AgentFolder="${Script.CurrentDirectory}" | ||
|
||
variable string NextWindowKey="Ctrl+Alt+X" | ||
variable string PreviousWindowKey="Ctrl+Alt+Z" | ||
|
||
method Initialize() | ||
{ | ||
LavishScript:RegisterEvent[OnHotkeyFocused] | ||
|
||
This:LoadSettings | ||
This:Enable | ||
|
||
LGUI2.Element[consolewindow]:SetVisibility[Visible] | ||
} | ||
|
||
method Shutdown() | ||
{ | ||
; shut down the Task Manager, ensuring that any hotkey we're still holding is effectively released | ||
TaskManager:Destroy | ||
|
||
This:Disable | ||
} | ||
|
||
method LoadSettings() | ||
{ | ||
variable jsonvalue jo | ||
|
||
if !${jo:ParseFile["${AgentFolder~}/bwsh.Settings.json"](exists)} || !${jo.Type.Equal[object]} | ||
{ | ||
return | ||
} | ||
|
||
SlotHotkeys:SetValue["${jo.Get["slotHotkeys"].AsJSON~}"] | ||
if ${jo.Has[nextWindowHotkey]} | ||
NextWindowKey:Set["${jo.Get["nextWindowHotkey"]~}"] | ||
if ${jo.Has[previousWindowHotkey]} | ||
PreviousWindowKey:Set["${jo.Get["previousWindowHotkey"]~}"] | ||
|
||
if !${SlotHotkeys.Type.Equal[array]} | ||
SlotHotkeys:SetValue["[]"] | ||
} | ||
|
||
method Enable() | ||
{ | ||
if ${Enabled} | ||
return | ||
|
||
Enabled:Set[1] | ||
This:InstallHotkeys | ||
} | ||
|
||
method Disable() | ||
{ | ||
if !${Enabled} | ||
return | ||
Enabled:Set[0] | ||
This:UninstallHotkeys | ||
} | ||
|
||
; Installs a Hotkey, given a name, a key combination, and LavishScript code to execute on PRESS | ||
method InstallHotkey(string name, string keyCombo, string methodName) | ||
{ | ||
variable jsonvalue joBinding | ||
; initialize a LGUI2 input binding object with JSON | ||
joBinding:SetValue["$$> | ||
{ | ||
"name":${name.AsJSON~}, | ||
"combo":${keyCombo.AsJSON~}, | ||
"eventHandler":{ | ||
"type":"task", | ||
"taskManager":"bwshSession", | ||
"task":{ | ||
"type":"ls1.code", | ||
"start":${methodName.AsJSON~} | ||
} | ||
} | ||
} | ||
<$$"] | ||
|
||
; now add the binding to LGUI2! | ||
LGUI2:AddBinding["${joBinding.AsJSON~}"] | ||
} | ||
|
||
method InstallHotkeys() | ||
{ | ||
variable uint i | ||
for (i:Set[1] ; ${i}<=${SlotHotkeys.Used} ; i:Inc) | ||
{ | ||
This:InstallHotkey[bwsh.Slot${i},"${SlotHotkeys.Get[${i}]~}","BWSHSession:OnSlotHotkey[${i}]"] | ||
} | ||
|
||
if ${NextWindowKey.NotNULLOrEmpty} | ||
This:InstallHotkey[bwsh.NextWindow,"${NextWindowKey~}","BWSHSession:NextWindow"] | ||
if ${PreviousWindowKey.NotNULLOrEmpty} | ||
This:InstallHotkey[bwsh.PreviousWindow,"${PreviousWindowKey~}","BWSHSession:PreviousWindow"] | ||
} | ||
|
||
member:uint GetNextSlot() | ||
{ | ||
variable uint Slot=${JMB.Slot} | ||
if !${Slot} | ||
return 0 | ||
|
||
Slot:Inc | ||
if ${Slot}>${JMB.Slots.Used} | ||
return 1 | ||
|
||
return ${Slot} | ||
} | ||
|
||
member:uint GetPreviousSlot() | ||
{ | ||
variable uint Slot=${JMB.Slot} | ||
if !${Slot} | ||
return 0 | ||
|
||
Slot:Dec | ||
if !${Slot} | ||
return ${JMB.Slots.Used} | ||
|
||
return ${Slot} | ||
} | ||
|
||
method PreviousWindow() | ||
{ | ||
variable uint previousSlot=${This.GetPreviousSlot} | ||
if !${previousSlot} | ||
return | ||
|
||
if !${Display.Window.IsForeground} | ||
return | ||
|
||
uplink focus "jmb${previousSlot}" | ||
relay "jmb${previousSlot}" "Event[OnHotkeyFocused]:Execute" | ||
} | ||
|
||
method NextWindow() | ||
{ | ||
variable uint nextSlot=${This.GetNextSlot} | ||
if !${nextSlot} | ||
return | ||
|
||
if !${Display.Window.IsForeground} | ||
return | ||
|
||
uplink focus "jmb${nextSlot}" | ||
relay "jmb${nextSlot}" "Event[OnHotkeyFocused]:Execute" | ||
} | ||
|
||
method OnSlotHotkey(uint numSlot) | ||
{ | ||
uplink focus "jmb${numSlot}" | ||
relay "jmb${numSlot}" "Event[OnHotkeyFocused]:Execute" | ||
} | ||
} | ||
|
||
variable(global) bwshSession BWSHSession | ||
|
||
function main() | ||
{ | ||
while 1 | ||
waitframe | ||
} |
110 changes: 110 additions & 0 deletions
110
Basic Window Switcher Hotkeys/BasicWindowSwitcherHotkeys.Uplink.iss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
objectdef bwshUplink | ||
{ | ||
variable jsonvalue SlotHotkeys="[]" | ||
variable bool Enabled=1 | ||
variable filepath AgentFolder="${Script.CurrentDirectory}" | ||
variable string NextWindowKey="Ctrl+Alt+X" | ||
variable string PreviousWindowKey="Ctrl+Alt+Z" | ||
|
||
method Initialize() | ||
{ | ||
This:LoadSettings | ||
|
||
LGUI2:LoadPackageFile[BasicWindowSwitcherHotkeys.Uplink.lgui2Package.json] | ||
LGUI2.Element[bwsh.filename]:SetText["${AgentFolder.Replace["/","\\"]~}\\bwsh.Settings.json"] | ||
} | ||
|
||
method Shutdown() | ||
{ | ||
This:Disable | ||
LGUI2:UnloadPackageFile[BasicWindowSwitcherHotkeys.Uplink.lgui2Package.json] | ||
} | ||
|
||
method LoadSettings() | ||
{ | ||
variable jsonvalue jo | ||
|
||
if !${AgentFolder.FileExists[bwsh.Settings.json]} | ||
{ | ||
jo:SetValue["$$> | ||
{ | ||
"slotHotkeys":[ | ||
"Ctrl+Alt+1", | ||
"Ctrl+Alt+2", | ||
"Ctrl+Alt+3", | ||
"Ctrl+Alt+4", | ||
"Ctrl+Alt+5", | ||
"Ctrl+Alt+6", | ||
"Ctrl+Alt+7", | ||
"Ctrl+Alt+8", | ||
"Ctrl+Alt+9", | ||
"Ctrl+Alt+0", | ||
"Ctrl+Alt+-", | ||
"Ctrl+Alt+=", | ||
], | ||
"previousWindowHotkey":"Ctrl+Alt+Z", | ||
"nextWindowHotkey":"Ctrl+Alt+X" | ||
} | ||
<$$"] | ||
|
||
jo:WriteFile["${AgentFolder~}/bwsh.Settings.json",multiline] | ||
} | ||
|
||
if !${jo:ParseFile["${AgentFolder~}/bwsh.Settings.json"](exists)} || !${jo.Type.Equal[object]} | ||
{ | ||
return | ||
} | ||
|
||
SlotHotkeys:SetValue["${jo.Get["slotHotkeys"].AsJSON~}"] | ||
if ${jo.Has[nextWindowHotkey]} | ||
NextWindowKey:Set["${jo.Get["nextWindowHotkey"]~}"] | ||
if ${jo.Has[previousWindowHotkey]} | ||
PreviousWindowKey:Set["${jo.Get["previousWindowHotkey"]~}"] | ||
|
||
if !${SlotHotkeys.Type.Equal[array]} | ||
SlotHotkeys:SetValue["[]"] | ||
} | ||
|
||
method StoreSettings() | ||
{ | ||
variable jsonvalue jo | ||
jo:SetValue["${This.AsJSON~}"] | ||
jo:WriteFile["${AgentFolder~}/bwsh.Settings.json",multiline] | ||
} | ||
|
||
member AsJSON() | ||
{ | ||
variable jsonvalue jo="{}" | ||
jo:Set["slotHotkeys","${SlotHotkeys.AsJSON~}"] | ||
jo:Set["nextWindowHotkey","${NextWindowKey.AsJSON~}"] | ||
jo:Set["previousWindowHotkey","${PreviousWindowKey.AsJSON~}"] | ||
return "${jo.AsJSON~}" | ||
} | ||
|
||
method Enable() | ||
{ | ||
if ${Enabled} | ||
return | ||
|
||
Enabled:Set[1] | ||
|
||
relay all BWSHSession:InstallHotkey | ||
} | ||
|
||
method Disable() | ||
{ | ||
if !${Enabled} | ||
return | ||
Enabled:Set[0] | ||
relay all BWSHSession:UninstallHotkey | ||
} | ||
|
||
} | ||
|
||
variable(global) bwshUplink BWSHUplink | ||
|
||
function main() | ||
{ | ||
while 1 | ||
waitframe | ||
} |
102 changes: 102 additions & 0 deletions
102
Basic Window Switcher Hotkeys/BasicWindowSwitcherHotkeys.Uplink.lgui2Package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json", | ||
"templates":{ | ||
"bwsh.defaultSettings":{ | ||
"slotHotkeys":[ | ||
"Ctrl+Alt+1", | ||
"Ctrl+Alt+2", | ||
"Ctrl+Alt+3", | ||
"Ctrl+Alt+4", | ||
"Ctrl+Alt+5", | ||
"Ctrl+Alt+6", | ||
"Ctrl+Alt+7", | ||
"Ctrl+Alt+8", | ||
"Ctrl+Alt+9", | ||
"Ctrl+Alt+0", | ||
"Ctrl+Alt+-", | ||
"Ctrl+Alt+=" | ||
], | ||
"previousWindowHotkey":"Ctrl+Alt+Z", | ||
"nextWindowHotkey":"Ctrl+Alt+X" | ||
} | ||
}, | ||
"elements": [ | ||
{ | ||
"type": "window", | ||
"name": "basicWindowSwitcherHotkeys.window", | ||
"title": "Basic Window Switcher Hotkeys", | ||
"visibility":"hidden", | ||
"content":{ | ||
"type":"stackpanel", | ||
"orientation":"vertical", | ||
"backgroundBrush":{ | ||
"color":"#FF003322" | ||
}, | ||
"padding":20, | ||
"children":[ | ||
{ | ||
"type":"textblock", | ||
"text":"Joe Multiboxer: Basic Window Switcher Hotkeys", | ||
"margin":5, | ||
"font":{ | ||
"bold":true, | ||
"face":"Verdana", | ||
"heightFactor":1.5 | ||
} | ||
}, | ||
{ | ||
"type":"textblock", | ||
"text":"Work is in progress on this Agent's configuration GUI.", | ||
"margin":[5,5,5,0] | ||
}, | ||
{ | ||
"type":"textblock", | ||
"text":"Default Hotkeys: Ctrl+Alt+1 through Ctrl+Alt+=", | ||
"margin":[5,15,5,10], | ||
"font":{ | ||
"heightFactor":1.5, | ||
"bold":true | ||
} | ||
}, | ||
{ | ||
"type":"textblock", | ||
"text":"Hotkeys can be set in the file:", | ||
"margin":[5,5,5,0] | ||
}, | ||
{ | ||
"type":"textblock", | ||
"name":"bwsh.filename", | ||
"margin":[5,5,5,10], | ||
"font":{ | ||
"heightFactor":1.2, | ||
"bold":true | ||
} | ||
}, | ||
{ | ||
"type":"expander", | ||
"margin":5, | ||
"header":"More ...", | ||
"expanded":false, | ||
"content":{ | ||
"type":"stackpanel", | ||
"orientation":"vertical", | ||
"children":[ | ||
{ | ||
"type":"button", | ||
"content":"Reload Basic Window Switcher Hotkeys", | ||
"margin":[5,5,5,0], | ||
"eventHandlers":{ | ||
"onPress":{ | ||
"type":"code", | ||
"code":"JMB.Agent[Basic Window Switcher Hotkeys]:Stop:Start" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.