It is currently May 10th, 2024, 7:12 am

Amateur-modified WindowState code doesn't work after a while

Get help with creating, editing & fixing problems with skins
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

Amateur-modified WindowState code doesn't work after a while

Post by hiuwo »

I am super amateur and I have been trying use JSMorley's WindowState to track processes.
I didnt want to use PerfMon because WindowState seems to use less CPU load.

I know the modified code i made is pretty inefficient cuz I suck at it, but I just want it to work 😦 . (original skin/code: https://forum.rainmeter.net/viewtopic.php?t=21785)

It does work when I test it but after sometime, say half an hour (?), it will freeze and not update.
And the log would say a bunch of:

Code: Select all

Error 101: Program still running: C:\Users\Neko\Documents\Rainmeter\Skins\hiuwoWindowState2@Resources\Addons\WindowState.exe (hiuwoWindowState2\WindowStateEACH.ini - [MeasureWindow6])
.
.
.
Error 101: Program still running: C:\Users\Neko\Documents\Rainmeter\Skins\hiuwoWindowState2@Resources\Addons\WindowState.exe (hiuwoWindowState2\WindowStateEACH.ini - [MeasureWindow6]) 
Screenshot 2023-05-30 233644.png

Can someone help me identify why and perhaps make it a bit more efficient? Super thankful!!

Here is the code https://pastebin.com/dkFa8U4U (very sorry for the crazy inefficient codes):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
;https://forum.rainmeter.net/viewtopic.php?t=21785
;https://docs.rainmeter.net/tips/update-guide/
 
[Metadata]
Name=WindowState
Author=JSMorley
Version=Sep 15, 2015
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Demonstrates the included WindowState.exe AutoIt addon to check the "state" of any program window.
 
; Notes: The variable TitleRegExp must be part or all of the "Title" string displayed in the title bar of the window you wish to check. This does not operate on the "process" name, but the "window" name of the application. This is a case-insensitive regular expression.
 
; While simply searching for "Notepad" to find the window for Notepad.exe will work, it can be ambiguous if you also have Notepad++ running, or even a browser opened to a site with "notepad" anywhere in the site title. Using ".* - Notepad$" in this instance is going to more reliably find the Notepad.exe window.
 
; The WindowState.exe addon is simply called with:
; WindowState.exe "Title string to search for"
 
; It will return to STDOUT a decimal number that is the addition of the following matching attributes:
 
;1 = Window exists
;2 = Window is visible
;4 = Window is enabled
;8 = Window has focus
;16 = Window is minimized
;32 = Window is maximized
 
;The Bitwise AND (&) operator is used to determine if any specific hex attribute is set:
 
;0x1 = Window exists
;0x2 = Window is visible
;0x4 = Window is enabled
;0x8 = Window has focus
;0x10 = Window is minimized
;0x20 = Window is maximized
 
[Variables]
TitleRegExp1=Outplayed.*$
TitleRegExp2=Blitz.*$
TitleRegExp3=League of Legends.*$
TitleRegExp4=θ‹±ι›„θ―η›Ÿε°εŠ©ζ‰‹.*$
TitleRegExp5=Discord.*$
TitleRegExp6=Google Chrome.*$
CosmeticName=All
Exists=0x1
;Visible=0x2
;Enabled=0x4
;Focus=0x8
;Minimized=0x10
;Maximized=0x20
 
[MeasureUpdate]
Measure=Calc
Formula=1
UpdateDivider=5 ;5
OnUpdateAction=[!CommandMeasure MeasureWindow1 "Run"] [!CommandMeasure MeasureWindow2 "Run"] [!CommandMeasure MeasureWindow3 "Run"] [!CommandMeasure MeasureWindow4 "Run"] [!CommandMeasure MeasureWindow5 "Run"] [!CommandMeasure MeasureWindow6 "Run"]
 
 
[MeasureWindow1]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp1#""
OutputType=ANSI
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]
 
[MeasureExists1]
Measure=Calc
Group=States
Formula=[MeasureWindow1] & #Exists# = #Exists# ? 1 : -1
;Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"
 
[MeasureWindow2]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp2#""
OutputType=ANSI
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]
 
[MeasureExists2]
Measure=Calc
Group=States
Formula=[MeasureWindow2] & #Exists# = #Exists# ? 1 : -1
;Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"
 
 
[MeasureWindow3]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp3#""
OutputType=ANSI
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]
 
[MeasureExists3]
Measure=Calc
Group=States
Formula=[MeasureWindow3] & #Exists# = #Exists# ? 1 : -1
;Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"
 
 
[MeasureWindow4]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp4#""
OutputType=ANSI
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]
 
[MeasureExists4]
Measure=Calc
Group=States
Formula=[MeasureWindow4] & #Exists# = #Exists# ? 1 : -1
;Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"
 
 
[MeasureWindow5]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp5#""
OutputType=ANSI
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]
 
[MeasureExists5]
Measure=Calc
Group=States
Formula=[MeasureWindow5] & #Exists# = #Exists# ? 1 : -1
;Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"
 
 
[MeasureWindow6]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp6#""
OutputType=ANSI
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]
 
[MeasureExists6]
Measure=Calc
Group=States
Formula=[MeasureWindow6] & #Exists# = #Exists# ? 1 : -1
;Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"
 
 
[textStyleGen]
FontSize=15
FontColor=255,255,255,255
Padding=5,5,5,5
AntiAlias=0
 
 
[titletext]
Meter=String
MeterStyle=textStyleGen
SolidColor=47,47,47,200
FontSize=16
InlineSetting=Size | 20
InlinePattern=#CosmeticName#
InlineSetting2=GradientColor | 180 | 252,94,37 ; 0.0 | 252,117,41 ; 0.25 | 251,163,48 ; 0.5 | 249,215,56 ; 0.75 | 249,242,61 ; 1.0
;InlinePattern2=#CosmeticName#
Text=#CosmeticName#       .#CRLF##CRLF##CRLF##CRLF##CRLF##CRLF##CRLF#
LeftMouseUpAction=["C:\Windows\System32\cmd.exe" /c "D:\Tools\bats\LoL triplet.bat"]
 
[MeterWindowState]
Meter=String
MeterStyle=textStyleGen
Y=30 ;25+5
;FontSize=15
;FontColor=255,255,255,255
;SolidColor=47,47,47,200
;Padding=5,5,5,5
;AntiAlias=0
Text=Outplayed  [MeasureExists1]#CRLF#
;InlineSetting=Size | 20
;InlinePattern=#CosmeticName#
;InlineSetting2=GradientColor | 180 | 252,94,37 ; 0.0 | 252,117,41 ; 0.25 | 251,163,48 ; 0.5 | 249,215,56 ; 0.75 | 249,242,61 ; 1.0
;InlinePattern2=#CosmeticName#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Program Files (x86)\Overwolf\OverwolfLauncher.exe" -launchapp cghphpbjeabdkomiphingnegihoigeggcfphdofo -from-desktop]
 
[MeterWindowState2]
Meter=String
MeterStyle=textStyleGen
Y=55 ;50
Text=Blitz      [MeasureExists2]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\WINDOWS\system32\schtasks.exe" /run /tn "Blitz.exe_546938825"]
 
 
 
[MeterWindowState3]
Meter=String
MeterStyle=textStyleGen
Y=80 ;75
Text=LeagueClient   [MeasureExists3]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Games\Main Games\Riot Games\Riot Client\RiotClientServices.exe"]
 
 
 
[MeterWindowState4]
Meter=String
MeterStyle=textStyleGen
Y=105 ;100+5
Text=LeaguHelper    [MeasureExists4]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Users\Neko\Downloads\LeaguHelper v1.3.1.exe"]
 
 
 
[MeterWindowState5]
Meter=String
MeterStyle=textStyleGen
Y=130 ;125+5
Text=Discord        [MeasureExists5]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Users\Neko\AppData\Local\Discord\Update.exe" --processStart Discord.exe]
 
 
[MeterWindowState6]
Meter=String
MeterStyle=textStyleGen
Y=155 ;150+5
Text=Chrome     [MeasureExists6]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
Last edited by hiuwo on May 31st, 2023, 10:24 am, edited 1 time in total.
User avatar
tass_co
Posts: 518
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Amateur-modified WindowState code doesn't work after a while

Post by tass_co »

hiuwo wrote: ↑May 30th, 2023, 4:48 am I am super amateur and I have been trying use JSMorley's WindowState to track processes.
I didnt want to use PerfMon because WindowState seems to use less CPU load.

I know the modified code i made is pretty inefficient cuz I suck at it, but I just want it to work 😦 .

It does work when I test it but after sometime, say half an hour (?), it will freeze and not update.
And the log would say a bunch of:

Code: Select all

Error 101: Program still running: C:\Users\Neko\Documents\Rainmeter\Skins\hiuwoWindowState2@Resources\Addons\WindowState.exe (hiuwoWindowState2\WindowStateEACH.ini - [MeasureWindow6])
.
.
.
Error 101: Program still running: C:\Users\Neko\Documents\Rainmeter\Skins\hiuwoWindowState2@Resources\Addons\WindowState.exe (hiuwoWindowState2\WindowStateEACH.ini - [MeasureWindow6]) 
Screenshot 2023-05-30 233644.png


Can someone help me identify why and perhaps make it a bit more efficient? Super thankful!!

Here is the code https://pastebin.com/dkFa8U4U (very sorry for the crazy inefficient codes):
Can you try adding Timeout=1000 and UpdateDivider=5 to the [MeasureWindow6] section?

Code: Select all

[MeasureWindow6]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp6#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]
 
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
balala
Rainmeter Sage
Posts: 16207
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Amateur-modified WindowState code doesn't work after a while

Post by balala »

hiuwo wrote: ↑May 30th, 2023, 4:48 am Can someone help me identify why and perhaps make it a bit more efficient? Super thankful!!
It's hard, because we don't have the WindowState.exe addon you're using (and to be honest even if I'd have it, would be tempted not to run it, just to be safe), but the error is caused most probably by the fact that there are six [MeasureWindowX] RunCommand plugin measures, all of them using this addon. Running so many instances of this addon is probably causing the error. All these six instances of the addon are run simultaneously, by the OnUpdateAction option of the [MeasureUpdate] measure. You should have to try running the plugin measures one after the other. If you don't know how to do this and tass_co's idea doesn't help, let me know to can try to help you.
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

Re: Amateur-modified WindowState code doesn't work after a while

Post by hiuwo »

tass_co wrote: ↑May 30th, 2023, 4:30 pm Can you try adding Timeout=1000 and UpdateDivider=5 to the [MeasureWindow6] section?

Code: Select all

[MeasureWindow6]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp6#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]
 
OK i will try. I suppose I will try to add it to all the 6 instances. I will report back
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

Re: Amateur-modified WindowState code doesn't work after a while

Post by hiuwo »

balala wrote: ↑May 30th, 2023, 7:10 pm It's hard, because we don't have the WindowState.exe addon you're using (and to be honest even if I'd have it, would be tempted not to run it, just to be safe), but the error is caused most probably by the fact that there are six [MeasureWindowX] RunCommand plugin measures, all of them using this addon. Running so many instances of this addon is probably causing the error. All these six instances of the addon are run simultaneously, by the OnUpdateAction option of the [MeasureUpdate] measure. You should have to try running the plugin measures one after the other. If you don't know how to do this and tass_co's idea doesn't help, let me know to can try to help you.
Thank you. It is from the URL I commented out: https://forum.rainmeter.net/viewtopic.php?t=21785
I will change the post to make it more obvious too! :oops: :oops: :rosegift:

I will try to work out how to achieve what you said but adding timeouts in each of them so they "take a break" one after another
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

Re: Amateur-modified WindowState code doesn't work after a while

Post by hiuwo »

tass_co wrote: ↑May 30th, 2023, 4:30 pm Can you try adding Timeout=1000 and UpdateDivider=5 to the [MeasureWindow6] section?

Code: Select all

[MeasureWindow6]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp6#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]
 
Thank you so much!

It seems to work now. Though log would tell errors still, is it okay to just ignore it and keep using it? I also don't really understand why it says calc has an extra operation.. Am I using an old syntax?
Screenshot 2023-06-01 015314.png
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2620
Joined: March 23rd, 2015, 5:26 pm

Re: Amateur-modified WindowState code doesn't work after a while

Post by SilverAzide »

hiuwo wrote: ↑May 31st, 2023, 5:57 pm Though log would tell errors still, is it okay to just ignore it and keep using it? I also don't really understand why it says calc has an extra operation.. Am I using an old syntax?
No, the "extra operation" error is not OK, and probably the formula is failing completely. I suspect in your case you just need to add some parentheses to help Rainmeter's math parser figure out what you want. For example, try changing this:

Formula=[MeasureWindow1] & #Exists# = #Exists# ? 1 : -1

to this:

Formula=(([MeasureWindow1] & #Exists#) = #Exists#) ? 1 : -1

Whenever you have logical (or bitwise) operators, it usually helps to add parens.

Another possibility is [MeasureWindow1] is returning an empty string, which can happen if things are running asynchronously (VERY likely this is happening, since you are running an external process and the FinishAction is commented out). In that case, you'd need to take some extra steps to ensure the calc measure does not execute.
β€’ Gadgets β€’ Wiki β€’ GitHub β€’ More Gadgets... β€’
User avatar
balala
Rainmeter Sage
Posts: 16207
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Amateur-modified WindowState code doesn't work after a while

Post by balala »

SilverAzide wrote: ↑May 31st, 2023, 8:02 pm No, the "extra operation" error is not OK, and probably the formula is failing completely. I suspect in your case you just need to add some parentheses to help Rainmeter's math parser figure out what you want. For example, try changing this:

Formula=[MeasureWindow1] & #Exists# = #Exists# ? 1 : -1

to this:

Formula=(([MeasureWindow1] & #Exists#) = #Exists#) ? 1 : -1

Whenever you have logical (or bitwise) operators, it usually helps to add parens.
No, unfortunately this doesn't help. See below.
hiuwo wrote: ↑May 31st, 2023, 5:57 pm It seems to work now. Though log would tell errors still, is it okay to just ignore it and keep using it? I also don't really understand why it says calc has an extra operation.. Am I using an old syntax?
SilverAzide wrote: ↑May 31st, 2023, 8:02 pm Another possibility is [MeasureWindow1] is returning an empty string, which can happen if things are running asynchronously (VERY likely this is happening, since you are running an external process and the FinishAction is commented out). In that case, you'd need to take some extra steps to ensure the calc measure does not execute.
This is the case. And can easily be fixed, by disabling all [MeasureExists1] - [MeasureExists6] measures (by add a Disabled=1 option to each of them - in fact this option did exist on those measures, but have been commented out) and a Finishaction=[!EnableMeasure "MeasureExists1"][!UpdateMeasure "MeasureExists1"] - Finishaction=[!EnableMeasure "MeasureExists6"][!UpdateMeasure "MeasureExists6"] options to each of the [MeasureWindow1] - [MeasureWindow6] measures. This way you can ensure the Calc measures are disabled as long as the RunCommand plugin measures have not yet numerical values.
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

Re: Amateur-modified WindowState code doesn't work after a while

Post by hiuwo »

SilverAzide wrote: ↑May 31st, 2023, 8:02 pm No, the "extra operation" error is not OK, and probably the formula is failing completely. I suspect in your case you just need to add some parentheses to help Rainmeter's math parser figure out what you want. For example, try changing this:

Formula=[MeasureWindow1] & #Exists# = #Exists# ? 1 : -1

to this:

Formula=(([MeasureWindow1] & #Exists#) = #Exists#) ? 1 : -1

Whenever you have logical (or bitwise) operators, it usually helps to add parens.

Another possibility is [MeasureWindow1] is returning an empty string, which can happen if things are running asynchronously (VERY likely this is happening, since you are running an external process and the FinishAction is commented out). In that case, you'd need to take some extra steps to ensure the calc measure does not execute.
balala wrote: ↑May 31st, 2023, 8:52 pm No, unfortunately this doesn't help. See below.


This is the case. And can easily be fixed, by disabling all [MeasureExists1] - [MeasureExists6] measures (by add a Disabled=1 option to each of them - in fact this option did exist on those measures, but have been commented out) and a Finishaction=[!EnableMeasure "MeasureExists1"][!UpdateMeasure "MeasureExists1"] - Finishaction=[!EnableMeasure "MeasureExists6"][!UpdateMeasure "MeasureExists6"] options to each of the [MeasureWindow1] - [MeasureWindow6] measures. This way you can ensure the Calc measures are disabled as long as the RunCommand plugin measures have not yet numerical values.
I have incoporated both the suggestions but still giving errors.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
;https://forum.rainmeter.net/viewtopic.php?t=21785
;https://docs.rainmeter.net/tips/update-guide/

[Metadata]
Name=WindowState
Author=JSMorley
Version=Sep 15, 2015
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Demonstrates the included WindowState.exe AutoIt addon to check the "state" of any program window.

; Notes: The variable TitleRegExp must be part or all of the "Title" string displayed in the title bar of the window you wish to check. This does not operate on the "process" name, but the "window" name of the application. This is a case-insensitive regular expression.

; While simply searching for "Notepad" to find the window for Notepad.exe will work, it can be ambiguous if you also have Notepad++ running, or even a browser opened to a site with "notepad" anywhere in the site title. Using ".* - Notepad$" in this instance is going to more reliably find the Notepad.exe window.

; The WindowState.exe addon is simply called with:
; WindowState.exe "Title string to search for"

; It will return to STDOUT a decimal number that is the addition of the following matching attributes:

;1 = Window exists
;2 = Window is visible
;4 = Window is enabled
;8 = Window has focus
;16 = Window is minimized
;32 = Window is maximized

;The Bitwise AND (&) operator is used to determine if any specific hex attribute is set:

;0x1 = Window exists
;0x2 = Window is visible
;0x4 = Window is enabled
;0x8 = Window has focus
;0x10 = Window is minimized
;0x20 = Window is maximized

[Variables]
TitleRegExp1=Outplayed.*$
TitleRegExp2=Blitz.*$
TitleRegExp3=League of Legends.*$
TitleRegExp4=θ‹±ι›„θ―η›Ÿε°εŠ©ζ‰‹.*$
TitleRegExp5=Discord.*$
TitleRegExp6=Google Chrome.*$
CosmeticName=All
Exists=0x1
;Visible=0x2
;Enabled=0x4
;Focus=0x8
;Minimized=0x10
;Maximized=0x20

[MeasureUpdate]
Measure=Calc
Formula=1
UpdateDivider=5 ;5
OnUpdateAction=[!CommandMeasure MeasureWindow1 "Run"] [!CommandMeasure MeasureWindow2 "Run"] [!CommandMeasure MeasureWindow3 "Run"] [!CommandMeasure MeasureWindow4 "Run"] [!CommandMeasure MeasureWindow5 "Run"] [!CommandMeasure MeasureWindow6 "Run"]


[MeasureWindow1]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp1#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
Finishaction=[!EnableMeasure "MeasureExists1"][!UpdateMeasure "MeasureExists1"]
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]

[MeasureExists1]
Measure=Calc
Group=States
;Formula=[MeasureWindow1] & #Exists# = #Exists# ? 1 : -1
Formula=(([MeasureWindow1] & #Exists#) = #Exists#) ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"

[MeasureWindow2]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp2#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
Finishaction=[!EnableMeasure "MeasureExists2"][!UpdateMeasure "MeasureExists2"]
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]

[MeasureExists2]
Measure=Calc
Group=States
;Formula=[MeasureWindow2] & #Exists# = #Exists# ? 1 : -1
Formula=(([MeasureWindow2] & #Exists#) = #Exists#) ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"


[MeasureWindow3]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp3#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
Finishaction=[!EnableMeasure "MeasureExists3"][!UpdateMeasure "MeasureExists3"]
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]

[MeasureExists3]
Measure=Calc
Group=States
;Formula=[MeasureWindow3] & #Exists# = #Exists# ? 1 : -1
Formula=(([MeasureWindow3] & #Exists#) = #Exists#) ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"


[MeasureWindow4]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp4#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
Finishaction=[!EnableMeasure "MeasureExists4"][!UpdateMeasure "MeasureExists4"]
;FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]

[MeasureExists4]
Measure=Calc
Group=States
;Formula=[MeasureWindow4] & #Exists# = #Exists# ? 1 : -1
Formula=(([MeasureWindow4] & #Exists#) = #Exists#) ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"


[MeasureWindow5]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp5#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
Finishaction=[!EnableMeasure "MeasureExists5"][!UpdateMeasure "MeasureExists5"]
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]

[MeasureExists5]
Measure=Calc
Group=States
;Formula=[MeasureWindow5] & #Exists# = #Exists# ? 1 : -1
Formula=(([MeasureWindow5] & #Exists#) = #Exists#) ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"


[MeasureWindow6]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp6#""
OutputType=ANSI
Timeout=1000
UpdateDivider=5
Finishaction=[!EnableMeasure "MeasureExists6"][!UpdateMeasure "MeasureExists6"]
;FinishAction=[!EnableMeasureGroup States]
;[!ShowMeter MeterWindowState MeterWindowState2 MeterWindowState3 MeterWindowState4 MeterWindowState5]

[MeasureExists6]
Measure=Calc
Group=States
;Formula=[MeasureWindow6] & #Exists# = #Exists# ? 1 : -1
Formula=(([MeasureWindow6] & #Exists#) = #Exists#) ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"β˜‘"


[textStyleGen]
FontSize=15
FontColor=255,255,255,255
Padding=5,5,5,5
AntiAlias=0


[titletext]
Meter=String
MeterStyle=textStyleGen
SolidColor=47,47,47,200
FontSize=16
InlineSetting=Size | 20
InlinePattern=#CosmeticName#
InlineSetting2=GradientColor | 180 | 252,94,37 ; 0.0 | 252,117,41 ; 0.25 | 251,163,48 ; 0.5 | 249,215,56 ; 0.75 | 249,242,61 ; 1.0
;InlinePattern2=#CosmeticName#
Text=#CosmeticName#		  .#CRLF##CRLF##CRLF##CRLF##CRLF##CRLF##CRLF#
LeftMouseUpAction=["C:\Windows\System32\cmd.exe" /c "D:\Tools\bats\LoL triplet.bat"]

[MeterWindowState]
Meter=String
MeterStyle=textStyleGen
Y=30 ;25+5
;FontSize=15
;FontColor=255,255,255,255
;SolidColor=47,47,47,200
;Padding=5,5,5,5
;AntiAlias=0
Text=Outplayed	[MeasureExists1]#CRLF#
;InlineSetting=Size | 20
;InlinePattern=#CosmeticName#
;InlineSetting2=GradientColor | 180 | 252,94,37 ; 0.0 | 252,117,41 ; 0.25 | 251,163,48 ; 0.5 | 249,215,56 ; 0.75 | 249,242,61 ; 1.0
;InlinePattern2=#CosmeticName#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Program Files (x86)\Overwolf\OverwolfLauncher.exe" -launchapp cghphpbjeabdkomiphingnegihoigeggcfphdofo -from-desktop]

[MeterWindowState2]
Meter=String
MeterStyle=textStyleGen
Y=55 ;50
Text=Blitz		[MeasureExists2]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\WINDOWS\system32\schtasks.exe" /run /tn "Blitz.exe_546938825"]



[MeterWindowState3]
Meter=String
MeterStyle=textStyleGen
Y=80 ;75
Text=LeagueClient	[MeasureExists3]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Games\Main Games\Riot Games\Riot Client\RiotClientServices.exe"]



[MeterWindowState4]
Meter=String
MeterStyle=textStyleGen
Y=105 ;100+5
Text=LeaguHelper	[MeasureExists4]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Users\Neko\Downloads\LeaguHelper v1.3.1.exe"]



[MeterWindowState5]
Meter=String
MeterStyle=textStyleGen
Y=130 ;125+5
Text=Discord		[MeasureExists5]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
LeftMouseUpAction=["C:\Users\Neko\AppData\Local\Discord\Update.exe" --processStart Discord.exe]


[MeterWindowState6]
Meter=String
MeterStyle=textStyleGen
Y=155 ;150+5
Text=Chrome		[MeasureExists6]#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*β˜‘#CRLF#
;Hidden=1
DynamicVariables=1
Screenshot 2023-06-02 001910.png
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7212
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Amateur-modified WindowState code doesn't work after a while

Post by Yincognito »

hiuwo wrote: ↑May 30th, 2023, 4:48 am I am super amateur and I have been trying use JSMorley's WindowState to track processes.
I didnt want to use PerfMon because WindowState seems to use less CPU load.

I know the modified code i made is pretty inefficient cuz I suck at it, but I just want it to work 😦 . (original skin/code: https://forum.rainmeter.net/viewtopic.php?t=21785)
I avoided answering this until now, but what EXACTLY are you trying to check? I mean specifics. Are you trying to check if ANY of the TitleRegExp... windows exists, or are you trying to check WHICH of them exists (since if it's the former, that should be achievable via "|" aka "or" in the regex from the parameter of a single WindowState.exe instance, as jsmorley implied)? Are you interested in the window specifics (maximized, minimized, etc.) or you simply want to know if the window / process exists or it's running? The solution to your problem depends on what exactly are you after.

Now, on the WindowState.exe and your code, I'll be blunt - no offense: the code isn't just inefficient, it's atrociously so. Now I know you're not an expert and such, but it's actually a matter of logic here. What you're doing in this case is, to give a plastic example (feel free to laugh at it, I certainly am inclined to do so, but it captures the essence pretty well), like needing 10 eggs from the market and sending 10 people for them, each of them tasked with bringing you just one single egg. Naturally, since you sent them at the same time and to the same market, it's quite likely that they will come back to you with that one egg each at about the same time, giving them all to you at once and expecting payment. The effect: since you only have two hands and one wallet, you'll probably break or drop some eggs and make them wait for the payment (might even lose some money in the process too, lol). It's the same thing here, just in bits and errors.

The program / skin that jsmorley wrote is designed for checking after a single window, not many windows at the same time. Spawning multiple instances of WindowState.exe at the same time is seriously suboptimal as a result, and yields those "program still running" / "cannot terminate blah blah blah" errors. At this point I'm not even concerned about the Calc error, because the solution is downright wrong. Can't see how using other methods is more CPU intensive or inefficient than this, especially if you're only after checking if the program runs or not. In such a case, see the Process measure, or use the UsageMonitor plugin to check the Thread Count of those processes (according to the PerfMon.msc help, every running process has at least one thread, so it is suited to check the running status):

Code: Select all

[Variables]
Process1=Nero
Process2=notepad
Process3=Taskmgr
Process4=mmc
Process5=winamp
Process6=WhereIsIt

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

---Measures---

[ThreadCount1]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Whitelist=#Process1#|#Process2#|#Process3#|#Process4#|#Process5#|#Process6#
Name=#Process1#

[ThreadCount2]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Whitelist=#Process1#|#Process2#|#Process3#|#Process4#|#Process5#|#Process6#
Name=#Process2#

[ThreadCount3]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Whitelist=#Process1#|#Process2#|#Process3#|#Process4#|#Process5#|#Process6#
Name=#Process3#

[ThreadCount4]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Whitelist=#Process1#|#Process2#|#Process3#|#Process4#|#Process5#|#Process6#
Name=#Process4#

[ThreadCount5]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Whitelist=#Process1#|#Process2#|#Process3#|#Process4#|#Process5#|#Process6#
Name=#Process5#

[ThreadCount6]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Whitelist=#Process1#|#Process2#|#Process3#|#Process4#|#Process5#|#Process6#
Name=#Process6#

---Meters---

[MeterTest]
Meter=String
SolidColor=47,47,47,255
FontColor=255,255,255,255
FontFace=Consolas
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text=#Process1#: [ThreadCount1:]#CRLF##Process2#: [ThreadCount2:]#CRLF##Process3#: [ThreadCount3:]#CRLF##Process4#: [ThreadCount4:]#CRLF##Process5#: [ThreadCount5:]#CRLF##Process6#: [ThreadCount6:]
DynamicVariables=1
There are other solutions to this as well, like running a single instance of "tasklist" in a RunCommand measure (updated, say, once every couple of seconds) and then checking its STDOUT result for the names of the processes you're after, but then, every solution involving running another program will be slower than something already running (like one of Rainmeter's plugins, e.g. UsageMonitor), even if it's about the very fast command lines.

Of course, if what you're looking for has to do with window specifics, that changes things, making the jsmorley executable one of the few possibilities you have. Even so, as someone else already said in the thread, running the RunCommand instances sequentially (i.e. not at the same time, but one after another) should alleviate the inefficiency of the method somewhat. You won't get states from the same moments for different programs, obviously, but you'll get them nevertheless, if you're approaching this in a more organized fashion.

Let us know if any of the above is useful for your case. ;-)
Profiles: Rainmeter Profile β—‡ DeviantArt Profile β—† Suites: MYiniMeter β—† Skins: Earth