It is currently June 24th, 2024, 1:25 am

Skin help(HDR on off script)

Get help with creating, editing & fixing problems with skins
BorisLFC
Posts: 6
Joined: March 15th, 2024, 9:31 am

Skin help(HDR on off script)

Post by BorisLFC »

Hi.
So i would like a skin on my desktop, that says HDR is on or off. I got this far.

Code: Select all

[Rainmeter]
Update=1000

[MeasureHDRStatus]
Measure=Plugin
Plugin=RunCommand
Program=powershell.exe
Parameter=-ExecutionPolicy Bypass -File "C:\Users\Boris\Desktop\Rainmeter Portable\checkhdr.ps1"
OutputType=ANSI
State=Hide

[MeterStatus]
Meter=String
MeasureName=MeasureHDRStatus
X=500
Y=500
FontSize=26
FontColor=255,255,255
Text=%1
checkhdr.ps1

Code: Select all

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

$hdrStatus = (Get-WmiObject -Namespace root\WMI -Class WmiMonitorBasicDisplayParams).ActiveHDR

if ($hdrStatus -eq 1) {
    Write-Output "HDR ON"
} else {
    Write-Output "HDR OFF"
}
If i run the script inside Powershell ISE, it shows HDR OFF or ON. When i run the file, it shows a window for a split second and then its gone. However, loading the skin and refreshing does nothing, so im lost. I added AllowUnsafeScripts=1 into .ini file. Log file shows no errors. What else can i try?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Skin help(HDR on off script)

Post by eclectic-tech »

The plugin does not "run" when the skin is loaded or refreshed. An OnRefreshAction can be used in [Rainmeter] to do that.

If the Measurename method doesn't work for you, try using !SetVariable in a FinishAction of your RunCommand to save the status as a variable, and display that in your meter.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure MeasureHDRStatus "Run"]

[MeasureHDRStatus]
Measure=Plugin
Plugin=RunCommand
Program=powershell.exe
Parameter=-ExecutionPolicy Bypass -File "C:\Users\Boris\Desktop\Rainmeter Portable\checkhdr.ps1"
OutputType=ANSI
State=Hide
; FinishAction=[!SetVariable HDRStatus "[#CURRENTSECTION#]"]

[MeterStatus]
Meter=String
MeasureName=MeasureHDRStatus
X=500
Y=500
FontSize=26
FontColor=255,255,255
Text=%1
; Text=#HDRStatus#
DynamicVariables=1
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Skin help(HDR on off script)

Post by Yincognito »

The Run part of the Plugin Commands section from the RunCommand page in the manual says:
Runs the program. The plugin will take no action unless triggered with this command.
Example: LeftMouseUpAction=[!CommandMeasure MeasureName "Run"]
Where and how you command the measure to run is up to your preference - like eclectic-tech mentioned, you can do this in an OnRefreshAction, to trigger the script execution at the end of the first skin update after a refresh.

References (yeah, I know, all these info bits are distributed in different places):
https://docs.rainmeter.net/manual/plugins/runcommand/
https://docs.rainmeter.net/manual/skins/option-types/#Action
https://docs.rainmeter.net/manual/skins/rainmeter-section/
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
BorisLFC
Posts: 6
Joined: March 15th, 2024, 9:31 am

Re: Skin help(HDR on off script)

Post by BorisLFC »

I'll try the code when i get home, thankful for the help, both of you.
Thanks for the links, i'll go through them. Im eager to make something and fiddle with rainmeter.
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Skin help(HDR on off script)

Post by Yincognito »

BorisLFC wrote: March 20th, 2024, 9:45 pm I'll try the code when i get home, thankful for the help, both of you.
Thanks for the links, i'll go through them. Im eager to make something and fiddle with rainmeter.
Sure thing - take your time and enjoy it. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
BorisLFC
Posts: 6
Joined: March 15th, 2024, 9:31 am

Re: Skin help(HDR on off script)

Post by BorisLFC »

Since my OP script didnt work properly(it always displayed HDR OFF no matter what), i settled on following script

Code: Select all

# Run dxdiag command and capture the output in dxdiag_output.txt
dxdiag /t "C:\Portable Apps\PortableApps\Rainmeter Portable\dxdiag_output.txt"

# Wait for 6 seconds to ensure dxdiag has finished generating the output file
Start-Sleep -Seconds 6

# Read the dxdiag output file
$dxdiagContent = Get-Content -Path "C:\Portable Apps\PortableApps\Rainmeter Portable\dxdiag_output.txt" -Raw

# Check if "AdvancedColorEnabled" is present in the output
if ($dxdiagContent -match "AdvancedColorEnabled") {
    Write-Output "HDR ON"
} else {
    Write-Output "HDR OFF"
}
This generates the "dxdiag" file, wait timer is there as generating a file might take a second or two, i just gave it some leeway so the skin shows proper text.
I then created a AutoHotkey script

Code: Select all

#!b:: ; WIN+ALT+B
Run, C:\Portable Apps\PortableApps\Rainmeter Portable\Rainmeter.exe !RefreshApp
return
Hotkey is for toggling HDR in windows 11.

The code in skin is eclectic-tech one, which he kindly helped me with, i just had to use !Set variable in FinishAction as the Measure method didnt work for me. I then added a timer so it refreshes the skin once in a while, but since i have a hotkey its kinda pointless, at windows startup everything is refreshed anyway i believe so correct text would be shown either way.
I posted this for anyone, who would want this info in their skin in the future.
And again, thanks for all the help.
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Skin help(HDR on off script)

Post by Yincognito »

BorisLFC wrote: March 22nd, 2024, 1:09 pm I posted this for anyone, who would want this info in their skin in the future.
Thanks for sharing your solution, it might help other readers with a similar goal! :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Skin help(HDR on off script)

Post by eclectic-tech »

Always happy to help.
sherstillo
Posts: 3
Joined: May 15th, 2024, 10:05 am

Re: Skin help(HDR on off script)

Post by sherstillo »

Hi! I'm new to the Rainmeter and to coding but i realy like your idea to mesure HDR status. Did you succeed to do it? I've made a simple skin to toggle HDR via AHK script but I'd like my skin to show if the HDR is turbed on/of. As I understand it was your goal too. How is it possible?
User avatar
Yincognito
Rainmeter Sage
Posts: 7492
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Skin help(HDR on off script)

Post by Yincognito »

sherstillo wrote: May 15th, 2024, 10:12 am Hi! I'm new to the Rainmeter and to coding but i realy like your idea to mesure HDR status. Did you succeed to do it? I've made a simple skin to toggle HDR via AHK script but I'd like my skin to show if the HDR is turbed on/of. As I understand it was your goal too. How is it possible?
Can you check the HDR status from the AHK script?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth