2023-08-16 02:52:12 +01:00
|
|
|
enum ButtonTypes {
|
|
|
|
State = 1
|
|
|
|
StateOnly = 2
|
|
|
|
Trigger = 3
|
|
|
|
}
|
|
|
|
|
2021-04-28 17:38:36 +01:00
|
|
|
class MacroButton {
|
2022-10-27 21:20:03 +01:00
|
|
|
[int32]$index
|
|
|
|
|
|
|
|
MacroButton ([int]$index) {
|
|
|
|
$this.index = $index
|
|
|
|
}
|
|
|
|
|
|
|
|
[string] ToString() {
|
|
|
|
return $this.GetType().Name + $this.index
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
[int] Getter ($mode) {
|
2023-08-16 02:52:12 +01:00
|
|
|
"Button[$($this.index)].$([ButtonTypes].GetEnumName($mode))" | Write-Debug
|
2022-10-27 21:20:03 +01:00
|
|
|
return MB_Get -Id $this.index -Mode $mode
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2023-08-16 02:52:12 +01:00
|
|
|
[void] Setter ($val, $mode) {
|
|
|
|
"Button[$($this.index)].$([ButtonTypes].GetEnumName($mode))=$val" | Write-Debug
|
|
|
|
MB_Set -Id $this.index -SET $val -Mode $mode
|
2022-01-19 21:52:59 +00:00
|
|
|
}
|
|
|
|
|
2021-04-28 17:38:36 +01:00
|
|
|
hidden $_state = $($this | Add-Member ScriptProperty 'state' `
|
|
|
|
{
|
2023-08-16 02:52:12 +01:00
|
|
|
[bool]$this.Getter([ButtonTypes]::State)
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-04-28 17:38:36 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param($arg)
|
2023-08-16 02:52:12 +01:00
|
|
|
$this._state = $this.Setter($arg, [ButtonTypes]::State)
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_stateonly = $($this | Add-Member ScriptProperty 'stateonly' `
|
|
|
|
{
|
2023-08-16 02:52:12 +01:00
|
|
|
[bool]$this.Getter([ButtonTypes]::StateOnly)
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-04-28 17:38:36 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param($arg)
|
2023-08-16 02:52:12 +01:00
|
|
|
$this._stateonly = $this.Setter($arg, [ButtonTypes]::StateOnly)
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_trigger = $($this | Add-Member ScriptProperty 'trigger' `
|
|
|
|
{
|
2023-08-16 02:52:12 +01:00
|
|
|
[bool]$this.Getter([ButtonTypes]::Trigger)
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-04-28 17:38:36 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param($arg)
|
2023-08-16 02:52:12 +01:00
|
|
|
$this._trigger = $this.Setter($arg, [ButtonTypes]::Trigger)
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Make_Buttons {
|
2021-04-28 17:38:36 +01:00
|
|
|
[System.Collections.ArrayList]$button = @()
|
2022-03-09 17:41:47 +00:00
|
|
|
0..79 | ForEach-Object {
|
2021-04-28 17:38:36 +01:00
|
|
|
[void]$button.Add([MacroButton]::new($_))
|
|
|
|
}
|
|
|
|
$button
|
|
|
|
}
|