It is currently March 29th, 2024, 1:42 am

IfMatch problem

Get help with creating, editing & fixing problems with skins
swagginnate
Posts: 12
Joined: February 11th, 2018, 8:25 am

IfMatch problem

Post by swagginnate »

I have an audio switcher that has an image for a headset and speakers, the image would default to speaker even if the audio device was the headset
In this sample code the devicename is measured, if it doesn't match its copied to the clipboard, i added a clipboard variable for an easy destination to paste to.
This match always returns false and I don't know why

Code: Select all

[rainmeter]
update=100

[variables]
color=255,255,255
clipboard=Speakers (High Definition Audio Device)

[BG]
meter=image
x=0
y=0
h=100
w=300
solidcolor=#color#,255
DynamicVariables=1

[MeasureAudioLevel]
Measure=Plugin
Plugin=AudioLevel
type=devicename

[stringmeter]
meter=string
measurename=measurestring
text=%1

[measurestring]
measure=string
string=[MeasureAudioLevel]
ifmatch=#clipboard#
ifmatchaction=[!setvariable color "0,255,100"]
ifnotmatchaction=[!setvariable color "255,0,0"][!Setclip "[measureaudiolevel]"]
Last edited by swagginnate on February 20th, 2018, 9:06 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatch problem

Post by balala »

swagginnate wrote:I have an audio switcher that has an image for a headset and speakers, the image would default to speaker even if the audio device was the headset
In this sample code the devicename is measured, if it doesn't match its copied to the clipboard, i added a clipboard variable for an easy destination to paste to.
This match always returns false and I don't know why
I'm not very sure what you'd like to accomplish. The code does the following: when refreshed, the [MeasureAudioLevel] measure returns the name of the audio device. The (otherwise useless) [measurestring] String measure gets the same value (name). If this matches the value of the clipboard variable, the IfMatchAction option sets the color of the [BG] meter to green, otherwise the IfNotMatchAction option sets it to red and copies the name of the audio device to clipboard. Note that this isn't the same thing as setting the same value to the clipboard variable. This variable doesn't get the name of the device. This name will only be copied to clipboard.
swagginnate
Posts: 12
Joined: February 11th, 2018, 8:25 am

Re: IfMatch problem

Post by swagginnate »

I know the clipboard variable isnt updated unless you edit the program
What i want is for the BG to turn green, but i cannot get the ifmatch to return true
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatch problem

Post by balala »

swagginnate wrote:I know the clipboard variable isnt updated unless you edit the program
What i want is for the BG to turn green, but i cannot get the ifmatch to return true
Not sure. What the [MeasureAudioLevel] measure returns, in different situations?
Also note that I wouldn't use the AudioLevel plugin, but the Win7AudioPlugin. Just try to replace the Plugin option of the [MeasureAudioLevel] measure with Plugin=Win7AudioPlugin.
swagginnate
Posts: 12
Joined: February 11th, 2018, 8:25 am

Re: IfMatch problem

Post by swagginnate »

i used the win7audioplugin and that worked
this is what i ended up with

Code: Select all

[Variables]
ImgColor=150,150,150,150
headsetname=Sades Headset
mute=[!CommandMeasure "MeasureMediaKey" "VolumeMute"][!Update]  
toHeadSet=[!CommandMeasure "MeasureWin7Audio" "SetOutPutIndex 1"][!ShowMeterGroup Headphones][!HideMeterGroup Speakers]
toSpeaker=[!CommandMeasure "MeasureWin7Audio" "SetOutPutIndex 2"][!ShowMeterGroup Speakers][!HideMeterGroup Headphones]

[MeasureWin7Audio] 
Measure=Plugin 
Plugin=Win7AudioPlugin

[measurestring]
measure=string
string=[MeasureWin7Audio]
ifmatch="#headsetname#"
ifmatchaction=#toHeadSet#
ifnotmatchaction=#tospeaker#

[Speakers]
meter=Image
ImageName=speaker.png
antialias=1
SolidColor=0,0,0,1
ImageTint=#ImgColor#
x=100
y=100
W=30
H=30
Group=Speakers
MiddleMouseDownAction=#mute#
leftmouseupaction=#toheadset#
hidden=0

[Headphones]
meter=Image
ImageName=headset.png
antialias=1
SolidColor=0,0,0,1
ImageTint=#ImgColor#
x=100
y=100
W=30
H=30
Group=Headphones
MiddleMouseDownAction=#mute#
leftmouseupaction=#tospeaker#
hidden=1
It is detecting whether the audio device is the headest and changes the meter group accordingly
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatch problem

Post by balala »

swagginnate wrote:i used the win7audioplugin and that worked
this is what i ended up with

It is detecting whether the audio device is the headest and changes the meter group accordingly
So, you got it working as intended, if I understood well. Right?