1
+ $MeterPrefix = " module.Taskbar.Icon."
2
+ $RootConfigPath = $RmApi.VariableStr (" RootConfigPath" )
3
+ $RootConfig = $RmApi.VariableStr (" RootConfig" )
4
+
5
+ function MaxProgramCount { # Retrieves the #MasProgramCount# Variable
6
+ $Count = $RmAPI.VariableStr (" module.Taskbar.ProgramCount" )
7
+ return $Count
8
+ }
9
+
10
+ function StockIcons { # Retrieves an array of the avaliable png files in the path specified by #StockIconPath#
11
+ $Path = $RmAPI.VariableStr (" module.Taskbar.StockIconPath" )
12
+ $List = @ ()
13
+
14
+ Get-ChildItem $Path - File | Where-Object Name -Match " png$" | ForEach-Object {
15
+ $List += $_.BaseName
16
+ }
17
+ Return $List
18
+ }
19
+
20
+ function RunGetIcons { # Runs the GetIcon.exe executable to get icon images of all currently running processes
21
+ $GetIconsPath = $RmAPI.VariableStr (" module.Taskbar.GetIconsPath" ) + " \getIcons.exe"
22
+ $AddDepPath = $RmAPI.VariableStr (" module.Taskbar.AddDep" )
23
+ & " $GetIconsPath " " $AddDepPath "
24
+ }
25
+
26
+ function GetProgramName { # Get the ProgramName of a particular program
27
+ Param ([int ] $ID )
28
+
29
+ $ProgramName = $RmAPI.VariableStr (" ProgramName" + $ID )
30
+ return $ProgramName
31
+ }
32
+ function GetProgramCount { # Get the number of children (instances) of a particular program
33
+ Param ([int ] $ID )
34
+
35
+ $ProgramCount = $RmAPI.VariableStr (" ProgramsCount" + $ID )
36
+ return $ProgramCount
37
+ }
38
+
39
+ function SetProgramCoord {
40
+ Param ([Int ] $ID )
41
+
42
+ $Width = $RmAPI.VariableStr (" module.Taskbar.ProgramW" )
43
+ $Size = $RmAPI.VariableStr (" module.Taskbar.IconSize" )
44
+ $Coord = " ($ID *$Width +($Width -$Size )*0.5)"
45
+
46
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID x $Coord " )
47
+ }
48
+
49
+ function SetProgramImage { # Set the icon image of a particular program
50
+ Param ([Int ] $ID )
51
+
52
+ $ProgramName = GetProgramName($ID )
53
+ $StockIcons = StockIcons
54
+ $StockIconPath = $RmAPI.VariableStr (" module.Taskbar.StockIconPath" )
55
+ $GenIconPath = $RmAPI.VariableStr (" module.Taskbar.GetIconsPath" ) + " \Icons"
56
+
57
+ If ($ProgramName -Match " Empty" ) {
58
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID ImageName "" " )
59
+ }
60
+ Else {
61
+ If ($StockIcons -clike $ProgramName ){ # if there exist a stock icon, then use the stock icon instead, if not use the generated one
62
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID ImageName `"`"`" $StockIconPath \$ProgramName .png`"`"`" " )
63
+ }
64
+ Else {
65
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID ImageName `"`"`" $GenIconPath \$ProgramName .png`"`"`" " )
66
+ }
67
+ }
68
+ }
69
+
70
+ function SetProgramMouseAction { # Set the relevant mouse actions of a particular program
71
+ Param ([Int ] $ID )
72
+
73
+ $ProgramName = GetProgramName($ID )
74
+ If ($ProgramName -Match " Empty" ){ # Not in use
75
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID LeftMouseUpAction `"`"`" $Null `"`"`" " )
76
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MouseOverAction `"`"`" $Null `"`"`" " )
77
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MouseLeaveAction `"`"`" $Null `"`"`" " )
78
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MiddleMouseUpAction `"`"`" $Null `"`"`" " )
79
+ }
80
+ else {
81
+ $ProgramCount = GetProgramCount($ID )
82
+ if ($ProgramCount -gt 0 ) { # Has open windows
83
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID LeftMouseUpAction `"`"`" [!CommandMeasure module.Taskbar.ProgramOptions ToFront|Main|$ID ]`"`"`" " )
84
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MouseOverAction `"`"`" !CommandMeasure module.Taskbar.PSRM `"`"`" MouseOverIconAction $ID `"`"`"`"`"`" " )
85
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MouseLeaveAction `"`"`" !CommandMeasure module.Taskbar.PSRM `"`"`" MouseLeaveIconAction $ID `"`"`"`"`"`" " )
86
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MiddleMouseUpAction `"`"`" !CommandMeasure module.Taskbar.ProgramOptions `"`"`" StartNew|$ID `"`"`"`"`"`" " )
87
+ }
88
+ else { # Pinned Program but no open windows
89
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID LeftMouseUpAction `"`"`" [!CommandMeasure module.Taskbar.ProgramOptions StartNew|$ID ]`"`"`" " )
90
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MouseOverAction `"`"`" $Null `"`"`" " )
91
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MouseLeaveAction `"`"`" $Null `"`"`" " )
92
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID MiddleMouseUpAction `"`"`" !CommandMeasure module.Taskbar.ProgramOptions `"`"`" StartNew|$ID `"`"`"`"`"`" " )
93
+ }
94
+ }
95
+ }
96
+
97
+ function MouseOverIconAction {
98
+ Param ([Int ] $ID )
99
+
100
+ # MouseOver Animation
101
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID ImageTint `"`"`" 255,255,255`"`"`" " )
102
+ $RmAPI.Bang (" !UpdateMeter $MeterPrefix$ID " )
103
+
104
+ # Update coords
105
+ $UpdateCoord = $RmAPI.ReplaceVariablesStr (" #UpdateCoord#" )
106
+ $RmAPI.Bang (" $UpdateCoord " )
107
+
108
+ # Set PopUp Coord
109
+ $ContainerCoord = $RmAPI.ReplaceVariables (" [module.Taskbar.Container:x]" )
110
+ $Width = $RmAPI.VariableStr (" module.Taskbar.ProgramW" )
111
+ $Size = $RmAPI.VariableStr (" module.Taskbar.IconSize" )
112
+ $Coord = " ($ContainerCoord +$ID *$Width +($Width -$Size )*0.5+$Width *0.5)"
113
+ $RmAPI.Bang (" !WriteKeyValue Variables Parent.Position `"`"`" $Coord `"`"`" `"`"`" $ ( $RootConfigPath ) PopUp\Taskbar_PopUp.ini`"`"`" " )
114
+
115
+ # EstablishPopUp
116
+ EstablishPopUp($ID )
117
+ }
118
+
119
+ function MouseLeaveIconAction {
120
+ Param ([Int ] $ID )
121
+
122
+ # MouseLeave Animation
123
+ $RmAPI.Bang (" !SetOption $MeterPrefix$ID ImageTint `"`"`" 180,180,180`"`"`" " )
124
+ $RmAPI.Bang (" !UpdateMeter $MeterPrefix$ID " )
125
+
126
+ # Start Deactivate queue
127
+ $RmAPI.Bang (" !CommandMeasure module.Taskbar.PopUpTimer `"`"`" Execute 1`"`"`" " )
128
+ }
129
+
130
+ function EstablishPopUp {
131
+ Param ([Int ] $ID )
132
+
133
+ # Stop Deactivate queue
134
+ $RmAPI.Bang (" !CommandMeasure module.Taskbar.PopUpTimer `"`"`" Stop 1`"`"`" " )
135
+
136
+ $ProgramCount = GetProgramCount($ID )
137
+ If ($ProgramCount -gt 0 ){ # If a popup is needed
138
+ # Set size
139
+ $ProgramCount = GetProgramCount($ID )
140
+ $RmAPI.Bang (" !WriteKeyValue Variables Module.Taskbar.NumProgram `"`"`" $ProgramCount `"`"`" `"`"`" $ ( $RootConfigPath ) PopUp\Taskbar_PopUp.ini`"`"`" " )
141
+
142
+ # Activate Popup
143
+ $RmAPI.Bang (" !DeactivateConfig `"`"`" $RootConfig \Popup`"`"`" `"`"`" Taskbar_PopUp.ini`"`"`" " )
144
+ $RmAPI.Bang (" !ActivateConfig `"`"`" $RootConfig \Popup`"`"`" `"`"`" Taskbar_PopUp.ini`"`"`" " )
145
+
146
+ # Set ID
147
+ $RmAPI.Bang (" !SetVariable Module.Taskbar.ProgramID `"`"`" $ID `"`"`" `"`"`" $RootConfig \PopUp`"`"`" " )
148
+
149
+ # Set window names
150
+ for ($i = 0 ; $i -lt $ProgramCount ; $i ++ ) {
151
+ $RmAPI.Bang (" !CommandMeasure module.Taskbar.ProgramOptions `"`"`" SetVariable|module.Taskbar.WindowName|ChildWindowName|$ID |$i `"`"`" " )
152
+ $WinName = $RmAPI.VariableStr (" module.Taskbar.WindowName" )
153
+ $RmAPI.Bang (" !SetOption $i Text `"`"`" $WinName `"`"`" `"`"`" $RootConfig \PopUp`"`"`" " )
154
+ }
155
+ $RmAPI.Bang (" !UpdateMeterGroup TaskbarChildString `"`"`" $RootConfig \PopUp`"`"`" " )
156
+ $RmAPI.Bang (" !Redraw `"`"`" $RootConfig \PopUp`"`"`" " )
157
+ }
158
+ }
159
+
160
+ function UpdateNow {
161
+ RunGetIcons
162
+ $MaxProgramCount = MaxProgramCount
163
+ for ($i = 0 ; $i -lt $MaxProgramCount ; $i ++ ) { # iterate through all programs
164
+ SetProgramCoord($i )
165
+ SetProgramImage($i )
166
+ SetProgramMouseAction($i )
167
+ }
168
+ $RmAPI.Bang (" !UpdateMeterGroup module.Taskbar.Icon" )
169
+ $RmAPI.Bang (" !Redraw" )
170
+ }
171
+
172
+ function Update {
173
+ $NeedsUpdate = $RmAPI.VariableStr (" NeedsUpdate" ) # Checks if an update is required
174
+ If ($NeedsUpdate -eq 1 ){
175
+ UpdateNow # If so, run all relevant instructions
176
+ $RmAPI.Bang (" !SetVariable NeedsUpdate 0" ) # Reset variable
177
+ }
178
+ }
0 commit comments