It is currently November 21st, 2019, 10:19 am

WindowState addon

Share and get help with Plugins and Addons
User avatar
jsmorley
Developer
Posts: 19743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

WindowState addon

jsmorley » September 14th, 2015, 6:24 pm

This skin demonstrates a little AutoIt addon I created to return the "state" of any process window.
WindowState_1.3.rmskin

Code: Select all

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

[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]
TitleRegExp=.* - Notepad$
CosmeticName=Notepad
Exists=0x1
Visible=0x2
Enabled=0x4
Focus=0x8
Minimized=0x10
Maximized=0x20

[MeasureUpdate]
Measure=Calc
Formula=1
UpdateDivider=5
OnUpdateAction=[!CommandMeasure MeasureWindow "Run"]

[MeasureWindow]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp#""
OutputType=ANSI
FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]

[MeasureExists]
Measure=Calc
Group=States
Formula=[MeasureWindow] & #Exists# = #Exists# ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[MeasureVisible]
Measure=Calc
Group=States
Formula=[MeasureWindow] & #Visible# = #Visible# ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[MeasureEnabled]
Measure=Calc
Group=States
Formula=[MeasureWindow] & #Enabled# = #Enabled# ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[MeasureFocus]
Measure=Calc
Group=States
Formula=[MeasureWindow] & #Focus# = #Focus# ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[MeasureMinimized]
Measure=Calc
Group=States
Formula=[MeasureWindow] & #Minimized# = #Minimized# ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[MeasureMaximized]
Measure=Calc
Group=States
Formula=[MeasureWindow] & #Maximized# = #Maximized# ? 1 : -1
Disabled=1
DynamicVariables=1
Substitute="-1":"☐","1":"☑"

[MeterWindowState]
Meter=String
FontSize=15
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=#CosmeticName##CRLF#Exists		[MeasureExists]#CRLF#Visible		[MeasureVisible]#CRLF#Enabled		[MeasureEnabled]#CRLF#Focus		[MeasureFocus]#CRLF#Minimized	[MeasureMinimized]#CRLF#Maximized	[MeasureMaximized]#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#
InlineSetting3=Color | 209,209,209
InlinePattern3=#CRLF#.*☐
InlineSetting4=Color | 182,252,196
InlinePattern4=#CRLF#.*☑
Hidden=1
DynamicVariables=1
1.jpg
Be aware that this can be tricky with Windows 8/10 "modern" applications, as once they are run, Windows will often "hibernate" them in memory when they are exited, rather than completely shutting them down, and they can still have a window detected by this addon. The built-in Calculator application in Win10 is an example of this.

Windows 10 in particular has a different way of looking at resources and performance. As far as it is concerned "unused memory" is just wasted memory. It considers "performance" to be far more important than "free memory", and will use just tons of extra memory "parking" stuff, particularly "modern apps", that you used and just might use again at some point. If you were to ever get to the point where you actually needed more physical memory than is "free", it will then happily trash enough of the "parked" stuff to make room for you. This is actually a really good approach, but takes some getting used to. If you are worried about "free memory", then Windows 10 is going to make you nervous indeed. However, you are wrong to do so. Free memory is pointless.

Also be aware that applications that are running "minimized to the notification area" (the system tray) will often have a "window" detected as "exists" and "enabled", but none of the others. They will not be seen as "minimized" when in the notification area.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WindowState addon

jsmorley » September 15th, 2015, 1:03 pm

I have changed the addon to allow a "regular expression" when searching for the window title, this can be much more reliable and unambiguous, as searching for just "notepad" would find the window for Notepad.exe, but also for Notepad++ and even a browser window if you are connected to a site with the word "notepad" in the site title.
DaSquall
Posts: 10
Joined: February 28th, 2015, 8:31 am

Re: WindowState addon

DaSquall » September 16th, 2015, 8:06 am

i have trouble understand if that work or not, i'm not regular with advanced skin, i have the last beta version, installed the rmskin, charge it but it doesnt show anything, anyway that look great for what i want to do ! :)
User avatar
jsmorley
Developer
Posts: 19743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WindowState addon

jsmorley » September 16th, 2015, 11:40 am

DaSquall wrote:i have trouble understand if that work or not, i'm not regular with advanced skin, i have the last beta version, installed the rmskin, charge it but it doesnt show anything, anyway that look great for what i want to do ! :)
Changed it how?
DaSquall
Posts: 10
Joined: February 28th, 2015, 8:31 am

Re: WindowState addon

DaSquall » September 16th, 2015, 11:55 am

i changed nothing at first, launched notepad and nothing happen but since i am with a french systeme i tried with other thing like chrome or mumble :

[Variables]
TitleRegExp=.* - mumble$
CosmeticName=mumble
User avatar
jsmorley
Developer
Posts: 19743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WindowState addon

jsmorley » September 16th, 2015, 12:03 pm

Try changing the [MeasureWindow] measure to look like this:

[MeasureWindow]
Measure=Plugin
Plugin=RunCommand
Program="#@#Addons\WindowState.exe"
Parameter=""#TitleRegExp#""
OutputType=ANSI
FinishAction=[!EnableMeasureGroup States][!ShowMeter MeterWindowState]
User avatar
jsmorley
Developer
Posts: 19743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WindowState addon

jsmorley » September 16th, 2015, 12:06 pm

Updated the skin in the .rmskin to better handle spaces in the path to the addon.
DaSquall
Posts: 10
Joined: February 28th, 2015, 8:31 am

Re: WindowState addon

DaSquall » September 16th, 2015, 2:51 pm

i dont know if that's the problem but : Image
User avatar
jsmorley
Developer
Posts: 19743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WindowState addon

jsmorley » September 16th, 2015, 2:55 pm

DaSquall wrote:i dont know if that's the problem but : Image
Well that's just weird.

What version of Rainmeter and Windows are you on?
DaSquall
Posts: 10
Joined: February 28th, 2015, 8:31 am

Re: WindowState addon

DaSquall » September 16th, 2015, 2:58 pm

Windows 10 and the last version i guess 3.3.0 beta r2461 64 bit 15 aug