I've used rainmeter for a few years, but I never really got into modifying or creating my own skins. I'm currently using the Omnimo 5 Skin. I'm working on creating a panel that, when I click it, change my sound playback device from Speakers, to USB, and so on. I already have this part working. What I'm trying to do now is get it to change the icon that is displayed, depending on which output device I'm using (USB, show headphones image; Speakers, show speaker image).
What I'm trying to do is pull in a file called 'Settings.ini'. This file is what updates everytime I run my EXE file to change the audio output. Every time the output device changes, the file updates. I use webparser to find the 'Device=' string. The number after this string is what tells me what device I'm using (1 or 2). This number also corresponds with the file name of the icon needed (1.png, 2.png). I was hoping that this would allow me change icons on LeftMouseUpAction, but it wasn't as easy as I thought it would be.
I know for a fact that the first part ([MeasureGetIconText]) is working (1 is stored in index 1).
Sorry for the long explanation. Any help would be appreciated.
When using measure names in square brackets, you must set DynamicVariables=1 on the measure or meter you are using it in. Otherwise the meter/measure will not be updated if the measure's value changes.
Also MeasureGetIcon is not necessary here. you can just set StringIndex=1 on MeasureGetIconText directly.
!Execute is not needed any more in the newest Rainmeter version, so I removed it.
This is how the code would look with all those modifications:
It works for the most part. However, the only way i can get the icon to change is if I manually refresh the skin. If I do a manual refresh, the icon goes blank. Then when I click on it, the icon is updated, but it get updated to the previous devices icon (so, if the device is USB, the icon will change to speaker, and so on). Again, this will only work after a manual refresh.
The button executes an EXE file, which updates the Settings.ini file after the device is changed. Do I need to add some kind of delay to the !updatemeasure bangs to allow the EXE time to run before the measures are updated? It doesn't seem like the !update bangs are actually doing anything.
It may well be that your exe is not finished before the Update bang is executed. Rainmeter doesn't wait for external programs to finish before going on to the next bang. What you could do is set UpdateRate=1 on the WebParser measure. This will make it re-parse the ini file every update cycle. The default behavior of WebParser is updating every 600 update cycles, because you normally use it to get info from the web.
Works perfectly now! I pretty much can't update the icon on execute, so I set up the skin to have Update=1000, and set everything else up to update. It works just fine now. Thanks!