It is currently April 27th, 2024, 6:27 pm

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

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

Post by hiuwo »

In response to your first paragraph, I want to detect 6 separate processes and show in a tasklist yes, and I apologise for not putting it up in my first paragraph.

So, as result, using RegEx "|" will not work because I don't want to just know either/all/none of the listed items to return one single status. I want 6 results. But, yes I agree from a programmer's pov, the idea is to just return once the process list, and then use that same saved list to check for 6 things, and then destroy the list after one run is the most sensible choice. I think I know how to do it on cmd, but I am not sure how it works with Rainmeter or WindowState here... :(

In reponse to the perfmon thing, running just one PerfMon instance pushes my rainmeter +6~+12% of cpu load, observed in Task Manager. While using JSMorley's WindowState Rainimeter and other detectable instances seem to not add any noticeable additional load to cpu (I could be wrong obviously.) Hence, I would love to keep using WindowState as it seems to me very efficient, written by JSMorley, and also can return multiple window management related status so I can possible use in the future. :lol:

I will try also to modify the UsageMonitor one later and see about it's cpu load, and how far I can go with that!
Thank you for the lengthy suggestion and the code! They are good directions and keywords for me to try to rewrite my WindowState code.


Yincognito wrote: June 2nd, 2023, 12:40 am 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. ;-)
User avatar
SilverAzide
Rainmeter Sage
Posts: 2613
Joined: March 23rd, 2015, 5:26 pm

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

Post by SilverAzide »

hiuwo wrote: June 2nd, 2023, 10:24 am In reponse to the perfmon thing, running just one PerfMon instance pushes my rainmeter +6~+12% of cpu load, observed in Task Manager. While using JSMorley's WindowState Rainimeter and other detectable instances seem to not add any noticeable additional load to cpu (I could be wrong obviously.) Hence, I would love to keep using WindowState as it seems to me very efficient, written by JSMorley, and also can return multiple window management related status so I can possible use in the future. :lol:

I will try also to modify the UsageMonitor one later and see about it's cpu load, and how far I can go with that!
Thank you for the lengthy suggestion and the code! They are good directions and keywords for me to try to rewrite my WindowState code.
This cannot possibly be correct. I have hundreds of UsageMonitor measures running all the time and Rainmeter is barely at 1% usage. Something else must be happening if you see a performance hit like that... Unless you are referring to some other non-Rainmeter plug-in; years ago some folks created "PerfMon" and "FerpNom" plug-ins that were similar to UsageMonitor, but neither of those plug-ins are of much use now.

It appears from your description, if I am understanding correctly, that all you want to know is if a process is running. If so, WindowState (or even tasklist) is definitely not the way to go. All you need are 6 Process measures, which are very lightweight. WindowState is intended to be used to determine the appearance of an app (full screen, minimized, maximized, etc.).
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

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

Post by Yincognito »

SilverAzide wrote: June 2nd, 2023, 3:45 pm This cannot possibly be correct. I have hundreds of UsageMonitor measures running all the time and Rainmeter is barely at 1% usage. Something else must be happening if you see a performance hit like that... Unless you are referring to some other non-Rainmeter plug-in; years ago some folks created "PerfMon" and "FerpNom" plug-ins that were similar to UsageMonitor, but neither of those plug-ins are of much use now.

It appears from your description, if I am understanding correctly, that all you want to know is if a process is running. If so, WindowState (or even tasklist) is definitely not the way to go. All you need are 6 Process measures, which are very lightweight. WindowState is intended to be used to determine the appearance of an app (full screen, minimized, maximized, etc.).
Precisely - that's the same thing I was trying to convey. :confused:
But then, if he really wants to use a WindowState like executable instead of the more optimal choices we talked about, I will post a "multi window state" skin later on. 8-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
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: June 2nd, 2023, 10:24 am In response to your first paragraph, I want to detect 6 separate processes and show in a tasklist yes, and I apologise for not putting it up in my first paragraph.

So, as result, using RegEx "|" will not work because I don't want to just know either/all/none of the listed items to return one single status. I want 6 results. But, yes I agree from a programmer's pov, the idea is to just return once the process list, and then use that same saved list to check for 6 things, and then destroy the list after one run is the most sensible choice. I think I know how to do it on cmd, but I am not sure how it works with Rainmeter or WindowState here... :(

In reponse to the perfmon thing, running just one PerfMon instance pushes my rainmeter +6~+12% of cpu load, observed in Task Manager. While using JSMorley's WindowState Rainimeter and other detectable instances seem to not add any noticeable additional load to cpu (I could be wrong obviously.) Hence, I would love to keep using WindowState as it seems to me very efficient, written by JSMorley, and also can return multiple window management related status so I can possible use in the future. :lol:

I will try also to modify the UsageMonitor one later and see about it's cpu load, and how far I can go with that!
Thank you for the lengthy suggestion and the code! They are good directions and keywords for me to try to rewrite my WindowState code.
No need to apologize, it's you who can benefit from a better help if you specify more accurately what you want to do - so the apologies should be directed to yourself (at least that's how I see things here). We already mentioned that you're choosing the suboptimal route here with WindowState instead of lighter alternatives like using Process or UsageMonitor measures, but, to cover all the angles, here are your main choices:

1. Using Process measures (check if various processes are running - fast variant)

Code: Select all

[Variables]
Process1=cmd
Process2=notepad
Process3=Taskmgr
Process4=mmc
Process5=Calculator
Process6=winamp

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

---Measures---

[Process1]
Measure=Process
ProcessName=#Process1#.exe
Substitute="-1":"not running","1":"running"

[Process2]
Measure=Process
ProcessName=#Process2#.exe
Substitute="-1":"not running","1":"running"

[Process3]
Measure=Process
ProcessName=#Process3#.exe
Substitute="-1":"not running","1":"running"

[Process4]
Measure=Process
ProcessName=#Process4#.exe
Substitute="-1":"not running","1":"running"

[Process5]
Measure=Process
ProcessName=#Process5#.exe
Substitute="-1":"not running","1":"running"

[Process6]
Measure=Process
ProcessName=#Process6#.exe
Substitute="-1":"not running","1":"running"

---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
MeasureName =Process1
MeasureName2=Process2
MeasureName3=Process3
MeasureName4=Process4
MeasureName5=Process5
MeasureName6=Process6
Text=#Process1# is %1#CRLF##Process2# is %2#CRLF##Process3# is %3#CRLF##Process4# is %4#CRLF##Process5# is %5#CRLF##Process6# is %6
2. Using UsageMonitor measures (check if various processes are running - good variant)

Code: Select all

[Variables]
Process1=cmd
Process2=notepad
Process3=Taskmgr
Process4=mmc
Process5=Calculator
Process6=winamp

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

---Measures---

[Process1]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Name=#Process1#
RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:]","^0$":"not running","^\d+$":"running"
DynamicVariables=1

[Process2]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Name=#Process2#
RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:]","^0$":"not running","^\d+$":"running"
DynamicVariables=1

[Process3]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Name=#Process3#
RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:]","^0$":"not running","^\d+$":"running"
DynamicVariables=1

[Process4]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Name=#Process4#
RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:]","^0$":"not running","^\d+$":"running"
DynamicVariables=1

[Process5]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Name=#Process5#
RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:]","^0$":"not running","^\d+$":"running"
DynamicVariables=1

[Process6]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=Thread Count
Name=#Process6#
RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:]","^0$":"not running","^\d+$":"running"
DynamicVariables=1

---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
MeasureName =Process1
MeasureName2=Process2
MeasureName3=Process3
MeasureName4=Process4
MeasureName5=Process5
MeasureName6=Process6
Text=#Process1# is %1#CRLF##Process2# is %2#CRLF##Process3# is %3#CRLF##Process4# is %4#CRLF##Process5# is %5#CRLF##Process6# is %6
3. Using MultiWindowState executable (check the states of various windows - single instance)

Code: Select all

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Opt("WinTitleMatchMode", -2)

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

Local $StdOutput = ""
Local $Separator = ""
For $i = 1 To $CmdLine[0]
  Local $hWnd = WinGetHandle("[REGEXPTITLE:(?i)" & $CmdLine[$i] & "]")
  If $hWnd Then
    $StdOutput = $StdOutput & $Separator & WinGetState($hWnd)
  Else
    $StdOutput = $StdOutput & $Separator & "0"
  EndIf
  $Separator = " "
Next
ConsoleWrite($StdOutput)
Exit

Code: Select all

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

[Metadata]
Name=MultiWindowState
Author=JSMorley & Yincognito
Version=Jun 02, 2023
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Demonstrates the included MultiWindowState.exe AutoIt addon to check the "states" of any program windows.

; 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 works, 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 MultiWindowState.exe addon is simply called with (any number of titles can be searched for):
; MultiWindowState.exe "First title string to search for" "Second title string to search for" ...

; It will return to STDOUT a list of space separated decimal numbers (as many as there are titles
; being searched), and each returned number 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=^.*(?:cmd.exe|Command Prompt).*$
TitleRegExp2=^.* - Notepad$
TitleRegExp3=^Task Manager$
TitleRegExp4=^Performance Monitor$
TitleRegExp5=^.*Calculator.*$
TitleRegExp6=^.*winamp.*$
ActualTitle1=Command Prompt
ActualTitle2=Notepad
ActualTitle3=Task Manager
ActualTitle4=Performance Monitor
ActualTitle5=Calculator
ActualTitle6=Winamp
Exists=0x1
Visible=0x2
Enabled=0x4
Focus=0x8
Minimized=0x10
Maximized=0x20

---Measures RunCommand---

[MeasureUpdate]
Group=Commands
Measure=Calc
Formula=1
UpdateDivider=5
OnUpdateAction=[!CommandMeasure MeasureWindows "Run"]

[MeasureWindows]
Group=Commands
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\MultiWindowState.exe"
Parameter=""#TitleRegExp1#" "#TitleRegExp2#" "#TitleRegExp3#" "#TitleRegExp4#" "#TitleRegExp5#" "#TitleRegExp6#""
OutputType=ANSI
FinishAction=[!EnableMeasureGroup Windows][!EnableMeasureGroup States][!ShowMeterGroup Output]

---Measures Windows---

[MeasureWindow1]
Group=Windows
Disabled=1
Measure=String
String=[MeasureWindows]
RegExpSubstitute=1
Substitute="^(?:\s?\d+){0,0}+\s?(\d+).*$":"\1","^(?:\\1|)$":"0"
DynamicVariables=1

[MeasureWindow2]
Group=Windows
Disabled=1
Measure=String
String=[MeasureWindows]
RegExpSubstitute=1
Substitute="^(?:\s?\d+){0,1}+\s?(\d+).*$":"\1","^(?:\\1|)$":"0"
DynamicVariables=1

[MeasureWindow3]
Group=Windows
Disabled=1
Measure=String
String=[MeasureWindows]
RegExpSubstitute=1
Substitute="^(?:\s?\d+){0,2}+\s?(\d+).*$":"\1","^(?:\\1|)$":"0"
DynamicVariables=1

[MeasureWindow4]
Group=Windows
Disabled=1
Measure=String
String=[MeasureWindows]
RegExpSubstitute=1
Substitute="^(?:\s?\d+){0,3}+\s?(\d+).*$":"\1","^(?:\\1|)$":"0"
DynamicVariables=1

[MeasureWindow5]
Group=Windows
Disabled=1
Measure=String
String=[MeasureWindows]
RegExpSubstitute=1
Substitute="^(?:\s?\d+){0,4}+\s?(\d+).*$":"\1","^(?:\\1|)$":"0"
DynamicVariables=1

[MeasureWindow6]
Group=Windows
Disabled=1
Measure=String
String=[MeasureWindows]
RegExpSubstitute=1
Substitute="^(?:\s?\d+){0,5}+\s?(\d+).*$":"\1","^(?:\\1|)$":"0"
DynamicVariables=1

---Measures States---

[MeasureExists1]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow1] & #Exists# = #Exists# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureVisible1]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow1] & #Visible# = #Visible# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureEnabled1]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow1] & #Enabled# = #Enabled# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureFocus1]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow1] & #Focus# = #Focus# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMinimized1]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow1] & #Minimized# = #Minimized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMaximized1]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow1] & #Maximized# = #Maximized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureExists2]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow2] & #Exists# = #Exists# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureVisible2]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow2] & #Visible# = #Visible# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureEnabled2]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow2] & #Enabled# = #Enabled# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureFocus2]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow2] & #Focus# = #Focus# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMinimized2]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow2] & #Minimized# = #Minimized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMaximized2]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow2] & #Maximized# = #Maximized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureExists3]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow3] & #Exists# = #Exists# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureVisible3]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow3] & #Visible# = #Visible# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureEnabled3]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow3] & #Enabled# = #Enabled# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureFocus3]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow3] & #Focus# = #Focus# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMinimized3]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow3] & #Minimized# = #Minimized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMaximized3]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow3] & #Maximized# = #Maximized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureExists4]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow4] & #Exists# = #Exists# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureVisible4]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow4] & #Visible# = #Visible# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureEnabled4]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow4] & #Enabled# = #Enabled# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureFocus4]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow4] & #Focus# = #Focus# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMinimized4]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow4] & #Minimized# = #Minimized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMaximized4]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow4] & #Maximized# = #Maximized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureExists5]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow5] & #Exists# = #Exists# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureVisible5]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow5] & #Visible# = #Visible# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureEnabled5]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow5] & #Enabled# = #Enabled# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureFocus5]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow5] & #Focus# = #Focus# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMinimized5]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow5] & #Minimized# = #Minimized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMaximized5]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow5] & #Maximized# = #Maximized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureExists6]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow6] & #Exists# = #Exists# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureVisible6]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow6] & #Visible# = #Visible# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureEnabled6]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow6] & #Enabled# = #Enabled# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureFocus6]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow6] & #Focus# = #Focus# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMinimized6]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow6] & #Minimized# = #Minimized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

[MeasureMaximized6]
Group=States
Disabled=1
Measure=Calc
Formula=[MeasureWindow6] & #Maximized# = #Maximized# ? 1 : -1
Substitute="-1":"🗷","1":"🗹"
DynamicVariables=1

---Meters---

[MeterActualTitles]
Group=Output
Hidden=1
Meter=String
W=205
FontSize=16
FontColor=255,255,255,255
SolidColor=0,0,0,128
Padding=5,5,5,5
AntiAlias=1
Text=Windows States#CRLF##ActualTitle1##CRLF##ActualTitle2##CRLF##ActualTitle3##CRLF##ActualTitle4##CRLF##ActualTitle5##CRLF##ActualTitle6#
InlinePattern=(?siU)^.*\R(.*)$
InlineSetting=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
DynamicVariables=1

[MeterWindowsStates]
Group=Output
Hidden=1
Meter=String
X=5R
FontSize=14
FontColor=255,255,255,255
SolidColor=0,0,0,128
Padding=5,5,5,5
AntiAlias=1
MeasureName  =MeasureExists1
MeasureName2 =MeasureVisible1
MeasureName3 =MeasureEnabled1
MeasureName4 =MeasureFocus1
MeasureName5 =MeasureMinimized1
MeasureName6 =MeasureMaximized1
MeasureName7 =MeasureExists2
MeasureName8 =MeasureVisible2
MeasureName9 =MeasureEnabled2
MeasureName10=MeasureFocus2
MeasureName11=MeasureMinimized2
MeasureName12=MeasureMaximized2
MeasureName13=MeasureExists3
MeasureName14=MeasureVisible3
MeasureName15=MeasureEnabled3
MeasureName16=MeasureFocus3
MeasureName17=MeasureMinimized3
MeasureName18=MeasureMaximized3
MeasureName19=MeasureExists4
MeasureName20=MeasureVisible4
MeasureName21=MeasureEnabled4
MeasureName22=MeasureFocus4
MeasureName23=MeasureMinimized4
MeasureName24=MeasureMaximized4
MeasureName25=MeasureExists5
MeasureName26=MeasureVisible5
MeasureName27=MeasureEnabled5
MeasureName28=MeasureFocus5
MeasureName29=MeasureMinimized5
MeasureName30=MeasureMaximized5
MeasureName31=MeasureExists6
MeasureName32=MeasureVisible6
MeasureName33=MeasureEnabled6
MeasureName34=MeasureFocus6
MeasureName35=MeasureMinimized6
MeasureName36=MeasureMaximized6
Text=R   V   E   F   S   L#CRLF#%1  %2  %3  %4  %5  %6#CRLF#%7  %8  %9  %10  %11  %12#CRLF#%13  %14  %15  %16  %17  %18#CRLF#%19  %20  %21  %22  %23  %24#CRLF#%25  %26  %27  %28  %29  %30#CRLF#%31  %32  %33  %34  %35  %36
InlinePattern=🗷
InlineSetting=Color | 128,128,128,255
InlinePattern2=🗹
InlineSetting2=Color | 182,252,196,255
DynamicVariables=1

[MeterInformation]
Group=Output
Hidden=1
Meter=String
X=(([MeterActualTitles:W]+[MeterWindowsStates:W])/2)
Y=5R
W=([MeterActualTitles:W]+[MeterWindowsStates:W])
FontSize=9
FontColor=255,255,255,255
SolidColor=0,0,0,128
Padding=5,5,5,5
StringAlign=Center
AntiAlias=1
Text=R: Running    V: Visible    E: Enabled    F: Focus    S: Small    L: Large
DynamicVariables=1
MultiWindowState_1.0.0.rmskin
MultiWindowState.jpg
Disregarding the bells and whistles which I couldn't care less about, I wouldn't use the last variant if I only wanted to know what is running or not, it's simply less efficient, to say the least. However, if you are by any chance interested in the window states / particularities and not just the running state of the programs, I've rewritten jsmorley's AutoIt script to support multiple regexes / title searches within the same executing session - this way, you only have to run a single instance of the new MultiWindowState.exe to find out about more programs, similar to how jsmorley described for his WindowState.exe version.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16178
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: June 1st, 2023, 4:52 pm I have incoporated both the suggestions but still giving errors.
I'm sorry, don't really know what to say, because I don't get these error messages when I use the code posted by you in the above post.

Did Yincognoto or SilverAzide fixed the issue?
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

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

Post by hiuwo »

This is the Usagemonitor I edited as of before I last check this thread, just trying out some of the calc stuff (6 separate calcs)
in case anyone is interested in impeaching:

Code: Select all

[Variables]
Process1=Outplayed
Process2=Blitz
Process3=LeagueClient
Process4=LeaguHelper
Process5=Discord
Process6=chrome

[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#


[calc1]
Measure=Calc
Formula=[ThreadCount1:]>0? 1 : -1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[calc2]
Measure=Calc
Formula=[ThreadCount2:]>0? 1 : -1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[calc3]
Measure=Calc
Formula=[ThreadCount3:]>0? 1 : -1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[calc4]
Measure=Calc
Formula=[ThreadCount4:]>0? 1 : -1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[calc5]
Measure=Calc
Formula=[ThreadCount5:]>0? 1 : -1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[calc6]
Measure=Calc
Formula=[ThreadCount6:]>0? 1 : -1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"



---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:]
Text=#Process1#: [calc1]#CRLF##Process2#: [calc2]#CRLF##Process3#: [calc3]#CRLF##Process4#: [calc4]#CRLF##Process5#: [calc5]#CRLF##Process6#: [calc6]
;Text=[calc2]
DynamicVariables=1


And this is the Process version edited with the checkboxes:

Code: Select all

[Variables]
Process1=Outplayed
Process2=Blitz
Process3=LeagueClient
Process4=LeaguHelper
Process5=Discord
Process6=Chrome

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

;---Measures---

[Process1]
Measure=Process
ProcessName=#Process1#.exe
Substitute="-1":"☐","1":"☑"

[Process2]
Measure=Process
ProcessName=#Process2#.exe
Substitute="-1":"☐","1":"☑"

[Process3]
Measure=Process
ProcessName=#Process3#.exe
Substitute="-1":"☐","1":"☑"

[Process4]
Measure=Process
ProcessName=#Process4#.exe
Substitute="-1":"☐","1":"☑"

[Process5]
Measure=Process
ProcessName=#Process5#.exe
Substitute="-1":"☐","1":"☑"

[Process6]
Measure=Process
ProcessName=#Process6#.exe
Substitute="-1":"☐","1":"☑"

;---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
MeasureName =Process1
MeasureName2=Process2
MeasureName3=Process3
MeasureName4=Process4
MeasureName5=Process5
MeasureName6=Process6
Text=#Process1# 	%1#CRLF##Process2# 		%2#CRLF##Process3# 	%3#CRLF##Process4# 	%4#CRLF##Process5# 	%5#CRLF##Process6# 		%6#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*☑#CRLF#
--------------------------------
SilverAzide wrote: June 2nd, 2023, 3:45 pm This cannot possibly be correct. I have hundreds of UsageMonitor measures running all the time and Rainmeter is barely at 1% usage. Something else must be happening if you see a performance hit like that... Unless you are referring to some other non-Rainmeter plug-in; years ago some folks created "PerfMon" and "FerpNom" plug-ins that were similar to UsageMonitor, but neither of those plug-ins are of much use now.
Yincognito wrote: June 2nd, 2023, 3:50 pm Precisely - that's the same thing I was trying to convey. :confused:

I only said Perfmon was bad for me and WIndowState was better than Perfmon... I have not tried nor did I say Usagemonitor was bad... And now you guys informed me of Usagemonitor I am having a blast with it. Maybe you guys have misunderstood some idea somewhere. Anyway, not an important point. Thank you for showing me other options.
hiuwo wrote: June 2nd, 2023, 10:24 am In reponse to the perfmon thing, running just one PerfMon instance pushes my rainmeter +6~+12% of cpu load, observed in Task Manager. While using JSMorley's WindowState Rainimeter and other detectable instances seem to not add any noticeable additional load to cpu (I could be wrong obviously.)
--------------------------------
Yincognito wrote: June 2nd, 2023, 12:40 am I avoided answering this until now..
Yincognito wrote: June 2nd, 2023, 5:30 pm No need to apologize, it's you who can benefit from a better help if you specify more accurately what you want to do - so the apologies should be directed to yourself...
Disregarding the bells and whistles which I couldn't care less about...
In terms of the discussion:
I am a bit sad :( because it came across a bit harsh, considering I am already very openly aware I know very little and this is very different to what I do for work.. I don't know what I could have done to not upset you. But again I think this post has been very very productive so I am trying my best to shrug it off, stay positive and catch up :) . So, thank you. And wow the fact that you are able to make MultiWindowState is awesome!
I should just explain that I just googled what I needed and PerfMon and WindowState came up. Process or UsageMonitor didn't come up as solutions at first. I then genuinely thought JSMorley's code was quite widely used, JSMorley also seemed active on this forum so when I had a problem with code I just thought most poeple here would know him, and more or less his stuff. I was clearly wrong.
Anyway, I guess the short answer to my original post is basically there is no way to shorten the WindowState apart from either rewriting the exe entirely or use something other than WindowState, because the original WindowState was just written that way.
I also didn't get what you meant by your "avoiding answering this post until now" (?).
But, anyway, moving on-

May I ask a question- am I right in thinking there is no way to apply a different MouseUpAction to each line of String in the same StringMeter? Cuz I would like to be able to click on the names of the processes and launch them if they do not exist, like I did in my original spaghetti code. I think inlinesetting for MouseUpAction does not work. Or am I mistaken?


--------------------------------
balala wrote: June 2nd, 2023, 5:53 pm I'm sorry, don't really know what to say, because I don't get these error messages when I use the code posted by you in the above post.

Did Yincognoto fixed the issue?
I will need a lot of time to digest what Yincognito has rewritten as well as how certain things work e.g. rewriting the AutoIt script (?) I somehow doubt I could comprehend how that works.. Anyway, it seems any choice of Yincognito's codes would be free of such problems as he certainly has proven to be a very proficient coder. Thank you for your input!


--------------------------------

Thank you everyone!!!!
Last edited by hiuwo on June 3rd, 2023, 3:11 am, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
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: June 2nd, 2023, 6:33 pm I am a bit sad :( because it came across a bit harsh [...]
Ok, let me clear up some things first. I'm sorry if you took what I said about the code personally, because it was not (hence mentioning "no offense" earlier, or "avoiding answering" up until now, knowing that my direct stance on it could be misunderstood this way). I was talking only about the code, not you as a person or your coding skills overall. We all originally started without knowing much in terms of code, and it would be stupid of me to criticize that, considering that I and many others have been in your place as well in the past.

I know it doesn't feel great when someone is saying some things about the code you wrote (by the way, did you know that jsmorley used to say that my code was "hideously complicated" too?) but it is meant to do well, make the other person aware of the mistakes he makes, and help him improve. Hopefully you understand where I'm going with this: when I see some seriously wrong approach in a code, I don't hide up behind nice words, I just say things as they are, and I'd expect others to do the same in my case, cause I value the truth above all else. It isn't meant to hurt or offend anyone, it's just the way it is, simple as that - I'm sure you already realized by now the major flaws of the previous approach. ;-)

---

Yes, you're right, unfortunately the only way to have WindowState act the way you wanted it to, and do it in a reasonable fashion in terms of impact, is to rewrite the AutoIt script accordingly and compile it to an .exe again - otherwise you'll just have to spawn it a ton of times and end up in the situation you got in your original and subsequent posts. The original WindowsState code is perfect for a one time / occasional single window state checking, but that's it.

No, you're not right that it's impossible to apply a different mouse action to different lines of string from the same meter. It is possible, but you'll have to approach it in a slightly "unorthodox" fashion. For example, if it's about clicks or scrolling, you can use the mouse variables in Rainmeter to compute the position of the mouse relative to the meter when doing that, and act accordingly. If it's about other actions that clicking or scrolling, there is the Mouse plugin by NighthawkSLO (see its documentation there) that you can use to get those mouse variables in other cases as well. If you need some specific example on it, let us know.
Also, not that it would matter, but it's Yincognito, balala just made a harmless typo earlier. And no, I'm not "impeaching" anyone for it, just saying, please don't make a tragedy out of it... :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

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

Post by hiuwo »

Yincognito wrote: June 2nd, 2023, 8:29 pm I know it doesn't feel great when someone is saying some things about the code you wrote
Well, not so much about feeling not great, but I feel like logically, if someone knew rainmeter codes enough to accomplish what they wanted, they wouldn't be here. So I am sorry you got hurt by JSMorley, but I hope this doesnt have to go in a circle. Having said that, rainmeter really isn't the most straight forward coding. At this point, many skins have been made, and to make something never been done before, it requires a lot of understanding (for amateurs) because otherwise they are most likely already online. I hope everyone can use a little positivity.
like this cat pic!
Image
Mew!

Continuing the actual coding question:
Yincognito wrote: June 2nd, 2023, 8:29 pm For example, if it's about clicks or scrolling, you can use the mouse variables in Rainmeter to compute the position of the mouse relative to the meter when doing that, and act accordingly.
Thanks for the direction!
I am trying to do this for the whole day today, but kinda stuck.

Since I have learnt in this post that rainmeter build-in measures would likely be most efficient, I would try to do mouse variable.
I learnt that IfCondition and IfAction exist. I also learn $MouseX$ can be called in actions such as MouseUpActions

However in the track of thought of clicking the line and conditionally returning a MouseUpAction that depend on the mouse's X. In the examples given in documentation, Ifcondition and IfAction are also cased inside a Measure. MouseUpAction are cased in Meters.
But, Mouse Variable do not require a measure, so how do I run an IfAction without a measure?
Do I make a bogus Calc Measure and put IfCondition/ IfAction in it?

Code: Select all

[Variable]
LineHeightApprox=29

[CoordinateMeasure]
Measure=Calc
Formula=$MouseX$
IfCondition=$MouseX$< #LineHeightApprox#
IfTrueAction=Action1
IfCondition2=$MouseX$> #LineHeightApprox#
IfTrueAction2=Action2
But this doesn't seem to work. Or should I do:

Code: Select all

[Variable]
LineHeightApprox=29

[CoordinateMeasure]
Measure=Calc
Formula=$MouseX$
IfCondition=$MouseX$< #LineHeightApprox#
IfTrueAction=[!SetOption MeterTest LeftMouseUpAction Action1]
IfCondition2=$MouseX$> #LineHeightApprox#
IfTrueAction=[!SetOption MeterTest LeftMouseUpAction Action2]

[MeterTest]
Meter=String
Text= ABC
But that also doesn't work... :(
So sad...
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
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: June 3rd, 2023, 12:56 pmSo I am sorry you got hurt by JSMorley, but I hope this doesnt have to go in a circle.
I only used it as an example to show that you're neither the first nor the last who received such opinions about his code, and that you shouldn't take it personally. You admitted yourself that the code is inefficient in your initial post, all I said was that it was extremely inefficient, and this was the truth, whether we use positivity or not. We're arguing about whether something is just reddish or plain red here, which is pointless... :confused:
Thanks for the cat picture though. :rosegift:
hiuwo wrote: June 3rd, 2023, 12:56 pmBut, Mouse Variable do not require a measure, so how do I run an IfAction without a measure?
Do I make a bogus Calc Measure and put IfCondition/ IfAction in it?
You can do it either way, or even combine the approaches ... like they say, there are many ways to skin a cat (pun intented). :lol:

1. Measure / height value variant (requires knowing the line height)

Code: Select all

[Variables]
LineHeight=28
ClickedLine=0

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

---Measures---

[DoStuff]
Measure=Calc
Formula=#ClickedLine#
UpdateDivider=-1
IfCondition=DoStuff=1
IfTrueAction=[!Log "Clicked Line = 1"]
IfCondition2=DoStuff=2
IfTrueAction2=[!Log "Clicked Line = 2"]
IfCondition3=DoStuff=3
IfTrueAction3=[!Log "Clicked Line = 3"]
IfConditionMode=1
DynamicVariables=1

---Meters---

[Lines]
Meter=String
SolidColor=47,47,47,255
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
AntiAlias=1
Padding=5,5,5,5
Text="Line One#CRLF#Line Two#CRLF#Line Three"
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable ClickedLine (Ceil($MouseY$/#LineHeight#))][!UpdateMeasure DoStuff]
DynamicVariables=1
2. Nested variable / height percent variant (requires knowing the line count)

Code: Select all

[Variables]
LineCount=3
ClickedLine=0
DoStuff1=[!Log "Clicked Line = 1"]
DoStuff2=[!Log "Clicked Line = 2"]
DoStuff3=[!Log "Clicked Line = 3"]

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

---Meters---

[Lines]
Meter=String
SolidColor=47,47,47,255
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
AntiAlias=1
Padding=5,5,5,5
Text="Line One#CRLF#Line Two#CRLF#Line Three"
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable ClickedLine (Ceil($MouseY:%$/100*#LineCount#))][#DoStuff[#ClickedLine]]
DynamicVariables=1
I had to use the nested syntax in the last variant for two reasons: it allows expressing a variable name (DoStuff...) based on the value of another variable (ClickedLine), AND it allows using the current / modified value of a variable (ClickedLine) in the same bang where it has been modified.

P.S. Your attempts didn't work mainly because mouse variables have no value outside of the mouse actions where you get them from. In other words, you must "save" that value somewhere for further use if you need to, e.g. into a variable, an option like the Formula of a Calc, etc. Also, if you use the last variant as it is (i.e. with the bangs saved as the DoStuff... variables), you might need to escape some of the other measures or variables that are part of those DoStuff... strings, if any (e.g. DoStuff1=[!SetOption SomeCalcMeasure Formula [*SomeOtherMeasure*]]...).

References:
- formula functions (Ceiling function)
- nesting variables (last example)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
hiuwo
Posts: 10
Joined: May 30th, 2023, 4:43 am

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

Post by hiuwo »

Yincognito wrote: June 3rd, 2023, 2:43 pm LeftMouseUpAction=[!SetVariable ClickedLine (Ceil($MouseY:%$/100*#LineCount#))][#DoStuff[#ClickedLine]]
Thanks Yincognito, I am able to understand both examples completely.

This works as desired. Cheers


Code: Select all

[Variables]
Process1=Outplayed
Process1b=InsightsCapture
Process2=Blitz
Process3=LeagueClient
Process4=LeaguHelper
Processreal4=LeaguHelper v1.3.1
Process5=Discord
Process6=Chrome
;LineHeightApprox=29
LineCount=8
ClickedLine=0
DoStuff1=["C:\Windows\System32\cmd.exe" /c "D:\Tools\bats\LoL triplet.bat"]
DoStuff2=["C:\Program Files (x86)\Overwolf\OverwolfLauncher.exe" -launchapp cghphpbjeabdkomiphingnegihoigeggcfphdofo -from-desktop] ;outplayed
DoStuff3=["C:\Program Files (x86)\Overwolf\OverwolfLauncher.exe" -launchapp okmohcjfmchpapljmoineeecekojmbbheniohgnp -from-desktop] ;outplayed
DoStuff4=["C:\WINDOWS\system32\schtasks.exe" /run /tn "Blitz.exe_546938825"]
DoStuff5=["C:\Games\Main Games\Riot Games\Riot Client\RiotClientServices.exe"]
DoStuff6=["C:\Users\Neko\Downloads\LeaguHelper v1.3.1.exe"]
DoStuff7=["C:\Users\Neko\AppData\Local\Discord\Update.exe" --processStart Discord.exe]


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

;---Measures---

[Process1]
Measure=Process
ProcessName=#Process1#.exe
Substitute="-1":"☐","1":"☑"

[Process1b]
Measure=Process
ProcessName=#Process1b#.exe
Substitute="-1":"☐","1":"☑"

[Process2]
Measure=Process
ProcessName=#Process2#.exe
Substitute="-1":"☐","1":"☑"

[Process3]
Measure=Process
ProcessName=#Process3#.exe
Substitute="-1":"☐","1":"☑"

[Process4]
Measure=Process
ProcessName=#Processreal4#.exe
Substitute="-1":"☐","1":"☑"

[Process5]
Measure=Process
ProcessName=#Process5#.exe
Substitute="-1":"☐","1":"☑"

[Process6]
Measure=Process
ProcessName=#Process6#.exe
Substitute="-1":"☐","1":"☑"


;---Meters---

[MeterTest]
Meter=String
SolidColor=47,47,47,255
FontColor=255,255,255,255
FontFace=Consolas
Padding=5,5,5,5
FontSize=16 ;29?
AntiAlias=1
MeasureName =Process1
MeasureName2=Process2
MeasureName3=Process3
MeasureName4=Process4
MeasureName5=Process5
MeasureName6=Process6
MeasureName7=Process1b
Text=ALL#CRLF##Process1# 	%1#CRLF#InsightsCap 	%7#CRLF##Process2# 		%2#CRLF##Process3# 	%3#CRLF##Process4# 	%4#CRLF##Process5# 	%5#CRLF##Process6# 		%6#CRLF#
InlineSetting=Color | 209,209,209
InlinePattern=.*☐#CRLF#
InlineSetting2=Color | 182,252,196
InlinePattern2=.*☑#CRLF#
LeftMouseUpAction=[!SetVariable ClickedLine (Ceil($MouseY:%$/100*#LineCount#))][#DoStuff[#ClickedLine]]