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.
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.