It is currently May 25th, 2020, 1:59 pm

App Launcher for access with remote control

General topics related to Rainmeter.
Wolfson
Posts: 16
Joined: April 18th, 2020, 2:00 pm

Re: App Launcher for access with remote control

Post by Wolfson »

I've tried to experiment a bit with all the timings to find a compromise between CPU usage and speed and yielded the code shown below.
It seems I need a relatively short general update time for two reasons:
  • to properly startup the skin -> The skin reacts to arrow key presses
  • the Process Plugin updates fast enough
All other measures/meters are now set to only update when explicetely called (

Code: Select all

DefaultUpdateDivider=-1
).

It works now pretty good. The latency from pressing a hotkey (the arrow keys) up to the updated skin however could be a bit faster. But it's ok.

Here is the code:

Code: Select all

; ========= Metadata ==========
[Metadata]
Name=
Author=
Information=
; BY=attribution / SA=share-alike / ND=no-derivatives / NC=non-commercial
License=CC BY-SA-NC 3.0
Version=

; ========= Variables ==========
[Variables]
process1=C:\Program Files\TrueConf\Client\TrueConf.exe
process2=C:\Users\AsRock BeeBox\Desktop\Lahoe.url
process3=C:\Users\AsRock BeeBox\Desktop\Diashow.exe
process4=C:\Users\AsRock BeeBox\Desktop\Diashow.exe
checkProc1=TrueConf_GL.exe
checkProc2=firefox.exe
checkProc3=Diashow.exe
checkProc4=Diashow.exe
proc1run=0
proc2run=0
proc3run=0
proc4run=0
keysOff=0
updateDivProc=1

activatekey=ENTER
; Set by skin actions
selected=1
selPrev=4
alpha1=255
alpha2=75
alpha3=75
alpha4=75

; ========= Skin Settings ==========
[Rainmeter]
Update=500
DefaultUpdateDivider=-1
;AccurateText=1
;DynamicWindowSize=1
;OnRefreshAction=[!Move "0" "0"][!ZPos 0]

; ========= Measures ==========
[MeasureProcessPluginProc1]
Measure=Plugin
Plugin=Process
UpdateDivider=#updateDivProc#
ProcessName=#checkProc1#
IfAboveValue=0
IfAboveAction=[!SetVariable proc1run "1"]
IfBelowValue=0
IfBelowAction=[!SetVariable proc1run "0"]
OnChangeAction=[!UpdateMeasure MeasureCheckProcess]
DynamicVariables=1

[MeasureProcessPluginProc2]
Measure=Plugin
Plugin=Process
UpdateDivider=#updateDivProc#
ProcessName=#checkProc2#
IfAboveValue=0
IfAboveAction=[!SetVariable proc2run "1"]
IfBelowValue=0
IfBelowAction=[!SetVariable proc2run "0"]
OnChangeAction=[!UpdateMeasure MeasureCheckProcess]
DynamicVariables=1

[MeasureProcessPluginProc3]
Measure=Plugin
Plugin=Process
UpdateDivider=#updateDivProc#
ProcessName=#checkProc3#
IfAboveValue=0
IfAboveAction=[!SetVariable proc3run "1"]
IfBelowValue=0
IfBelowAction=[!SetVariable proc3run "0"]
OnChangeAction=[!UpdateMeasure MeasureCheckProcess]
DynamicVariables=1

[MeasureProcessPluginProc4]
Measure=Plugin
Plugin=Process
UpdateDivider=#updateDivProc#
ProcessName=#checkProc4#
IfAboveValue=0
IfAboveAction=[!SetVariable proc4run "1"]
IfBelowValue=0
IfBelowAction=[!SetVariable proc4run "0"]
OnChangeAction=[!UpdateMeasure MeasureCheckProcess]
DynamicVariables=1

[MeasureHotKeyUp]
Measure=Plugin
Plugin=HotKey
HotKey=UP
UpdateDivider=-1
;ShowAllKeys=1
;KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#-2,1,4))][!UpdateMeasure Measurealpha][!UpdateMeter *][!Redraw]
KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#-2,1,4))][!UpdateMeasure Measurealpha][!UpdateMeasure "MeasureHotKeyUp"][!UpdateMeasure "MeasureHotKeyDown"][!UpdateMeasure "MeasureHotKeyRight"][!UpdateMeasure "MeasureHotKeyLeft"]
DynamicVariables=1

[MeasureHotKeyDown]
Measure=Plugin
Plugin=HotKey
HotKey=DOWN
UpdateDivider=-1
;ShowAllKeys=1
;KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#+2,1,4))][!UpdateMeasure Measurealpha][!UpdateMeter *][!Redraw]
KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#+2,1,4))][!UpdateMeasure Measurealpha][!UpdateMeasure "MeasureHotKeyUp"][!UpdateMeasure "MeasureHotKeyDown"][!UpdateMeasure "MeasureHotKeyRight"][!UpdateMeasure "MeasureHotKeyLeft"]
DynamicVariables=1

[MeasureHotKeyRight]
Measure=Plugin
Plugin=HotKey
HotKey=RIGHT
UpdateDivider=-1
;ShowAllKeys=1
;KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#+1,1,4))][!UpdateMeasure Measurealpha][!UpdateMeter *][!Redraw]
KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#+1,1,4))][!UpdateMeasure Measurealpha][!UpdateMeasure "MeasureHotKeyUp"][!UpdateMeasure "MeasureHotKeyDown"][!UpdateMeasure "MeasureHotKeyRight"][!UpdateMeasure "MeasureHotKeyLeft"]
DynamicVariables=1

[MeasureHotKeyLeft]
Measure=Plugin
Plugin=HotKey
HotKey=LEFT
UpdateDivider=-1
;ShowAllKeys=1
;KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#-1,1,4))][!UpdateMeasure Measurealpha][!UpdateMeter *][!Redraw]
KeyUpAction=[!SetVariable selPrev #selected#][!SetVariable selected (Clamp(#selected#-1,1,4))][!UpdateMeasure Measurealpha][!UpdateMeasure "MeasureHotKeyUp"][!UpdateMeasure "MeasureHotKeyDown"][!UpdateMeasure "MeasureHotKeyRight"][!UpdateMeasure "MeasureHotKeyLeft"]
DynamicVariables=1

[MeasureHotKeyActivateProcess]
Measure=Plugin
Plugin=HotKey
HotKey=#activatekey#
;ShowAllKeys=1
KeyUpAction=["[#process[#selected]]"]
DynamicVariables=1

[MeasureCheckProcess]
Measure=Calc
Formula=1
IfCondition=(#proc1run#=1) || (#proc2run#=1) || (#proc3run#=1)
IfTrueAction=[!SetVariable keysOff 1][!CommandMeasure "MeasureHotKeyUp" "Stop"][!CommandMeasure "MeasureHotKeyDown" "Stop"][!CommandMeasure "MeasureHotKeyRight" "Stop"][!CommandMeasure "MeasureHotKeyLeft" "Stop"][!CommandMeasure "MeasureHotKeyActivateProcess" "Stop"]
IfCondition2=(#proc1run#=0) && (#proc2run#=0) && (#proc3run#=0)
IfTrueAction2=[!SetVariable keysOff 0][!CommandMeasure "MeasureHotKeyUp" "Start"][!CommandMeasure "MeasureHotKeyDown" "Start"][!CommandMeasure "MeasureHotKeyRight" "Start"][!CommandMeasure "MeasureHotKeyLeft" "Start"][!CommandMeasure "MeasureHotKeyActivateProcess" "Start"]
DynamicVariables=1

[Measurealpha]
Measure=Calc
IfCondition=(#selected#<>#selPrev#)
IfTrueAction=[!SetVariable alpha#selected# 255][!SetVariable alpha#selPrev# 55][!UpdateMeter MeterImage#selected#][!UpdateMeter MeterImage#selPrev#][!RedrawGroup MeterImage]
;IfTrueAction=[!SetVariable alpha#selected# 255][!UpdateMeter MeterImage#selected#][!SetVariable alpha#selPrev# 55][!UpdateMeter MeterImage#selPrev#][!RedrawGroup MeterImage]
IfConditionMode=1
DynamicVariables=1

; ========= Meters ==========
[Background]
Meter=Image
UpdateDivider=-1
X=1
Y=1
W=(#WorkAreaWidth#-2)
H=(#WorkAreaHeight#-2)
SolidColor=0,0,0

[MeterImage1]
Meter=Image
ImageName=#@#Images\Phone.png
DynamicVariables=1
Group=MeterImage
X=1
Y=1
W=([Background:W]*0.5)
H=([Background:H]*0.5)
SolidColor=200,50,50,#alpha1#
AntiAlias=1

[MeterImage2]
Meter=Image
DynamicVariables=1
Group=MeterImage
X=R
Y=r
W=([Background:W]*0.5)
H=([Background:H]*0.5)
ImageName=#@#Images\Lahoe.png
SolidColor=50,50,200,#alpha2#
AntiAlias=1

[MeterImage3]
Meter=Image
ImageName=#@#Images\Diashow.png
DynamicVariables=1
Group=MeterImage
X=1
Y=R
W=([Background:W]*0.5)
H=([Background:H]*0.5)
SolidColor=200,50,200,#alpha3#
AntiAlias=1

[MeterImage4]
Meter=Image
ImageName=#@#Images\Diashow.png
DynamicVariables=1
Group=MeterImage
X=R
Y=r
W=([Background:W]*0.5)
H=([Background:H]*0.5)
SolidColor=200,200,50,#alpha4#
AntiAlias=1
User avatar
balala
Rainmeter Sage
Posts: 10577
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: App Launcher for access with remote control

Post by balala »

Wolfson wrote:
April 26th, 2020, 9:02 pm
Here is the code:
A few observations related to the posted code:
  • Since you set a DefaultUpdateDivider=-1 option into the [Rainmeter] section, there is not needed to set the UpdateDivider=-1 on some measures (the HotKey plugine measures: [MeasureHotKeyUp], [MeasureHotKeyDown], [MeasureHotKeyRight], [MeasureHotKeyLeft]) and meters ([Background]). Doesn't create problems if you do, but it's practically useless.
  • There is no need to introduce and use the proc1run, proc2run and proc3run variables. Although doesn't hurt to use them, it can be avoided and usually the less variables (measure or whatever), the better. If you wanna give it a try, here is how can you do this:
    • Remove the above three variables from the [Variables] section.
    • Remove the IfAboveValue, IfAboveAction, IfBelowValue and IfBelowAction options of the [MeasureProcessPluginProc1], [MeasureProcessPluginProc2], [MeasureProcessPluginProc3] and [MeasureProcessPluginProc4] measures.
    • Replace the IfCondition and IfCondition2 options of the [MeasureCheckProcess] measure with the following ones:

      Code: Select all

      [MeasureCheckProcess]
      ...
      IfCondition=(Clamp(MeasureProcessPluginProc1,0,1)=1) || (Clamp(MeasureProcessPluginProc2,0,1)=1) || (Clamp(MeasureProcessPluginProc1,0,1)=1)
      ...
      IfCondition2=(Clamp(MeasureProcessPluginProc1,0,1)=0) && (Clamp(MeasureProcessPluginProc1,0,1)=0) && (Clamp(MeasureProcessPluginProc1,0,1)=0)
      ...
    The above solution lets you to remove the DynamicVariables=1 option from the same [MeasureCheckProcess] measure as well.
  • The !RedrawGroup bang is mistakenly used into the IfTrueAction option of the [Measurealpha] measure. The mistake, presumably made by many users is that you can't redraw just one meter or a group of meters. The whole skin has to be and is redrawn, when it is. !RedrawGroup redraws all skins belonging to the specified group. You posted the following form of this bang into the mentioned option: [!RedrawGroup MeterImage]. But in your code MeterImage is a group of meters, containing the [MeterImage1] - [MeterImage4] meters. As such you can't redraw them. So, replace the [!RedrawGroup MeterImage] bang (as said into the IfTrueActrion option of the [Measurealpha] measure) with [!Redraw]. This will reduce the responding time of the skin when you hit an arrow key on your keyboard (or the remote control, if I'm not wrong), because a small delay was still present. This was caused by the fact that although the appropriate meters have been updated, the skin wasn't redrawn. Now this I hope is fixed as well.
  • And one more: the common options of more meters can be grouped into a "style" section, used on all those meters which have to use that style. This way you can avoid to write / paste all those options one by one on each meter. For instance create an [ImageStyle] section into your code, as it follows:

    Code: Select all

    [ImageStyle]
    DynamicVariables=1
    Group=MeterImage
    AntiAlias=1
    W=([Background:W]*0.5)
    H=([Background:H]*0.5)
    Now replace all these options on all of the four meters ([MeterImage1] - [MeterImage4]) with one single MeterStyle=ImageStyle option.