Currently attempting to make a small .exe that will enable and disable Fountain of Colors when Spotify is open, since I only really want it open when Spotify is open. I'm trying to send Bangs using C++, and I have a near identical copy of the code provided in the "Developers" documentation section of the Rainmeter website, but it doesn't seem to work.
Every time I invoke this function it prints the error Rainmeter window not found. The else statement is, quite literally, the only modification I've made to the version of the function available on the website. What am I doing incorrectly?
Last edited by balala on April 30th, 2024, 8:48 pm, edited 1 time in total.
Reason:Please use <code> tags whenever are you posting codes. It's the </> button.
Shimadacat wrote: ↑April 30th, 2024, 8:12 pm
Currently attempting to make a small .exe that will enable and disable Fountain of Colors when Spotify is open, since I only really want it open when Spotify is open. I'm trying to send Bangs using C++, and I have a near identical copy of the code provided in the "Developers" documentation section of the Rainmeter website, but it doesn't seem to work.
I can't answer your question, but have another: why do you want to write a .exe for such a task? .exe files are extremely undesirable (exprecially if you'll want distributing yor skin). I assume a (simple) Rainmeter skin could do the job. The skin has to check if Spotify runs and act accordingly. You don't even need to much things, just:
I'm not using Spotify, but what you have to take care about the above code is to use the proper process name in the ProcessName option. I just assumed this name should be Spotify.exe, but if you're using Spotify, you are the one who has to find the proper name.
A set of IfCondition, to let the skin activating Fountain of Colors when Spotify runs and deactivate it otherwise. Try for instance the following options:
[MeasureSpotify]
Measure=Process
ProcessName=Spotify.exe
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!ActivateConfig "Fountain of Colors" "Fountain of Colors.ini"]
IfFalseAction=[!DeactivateConfig "Fountain of Colors"]
Can't try out this code, because as said I'm not using Spotify, but tried it with another process and worked. If you can find the name of the process of Spotify, it should work for you as well. Does it?
balala's answer is probably the easier way to go if this is the only task your .exe is doing.
As far as why FindWindow is failing, I have no idea. You could try one of the following to see if they work.
Also use the window's title: HWND rmWnd = FindWindow(L"DummyRainWClass", L"Rainmeter control window");
Try using FindWindowEx (with and without the window's title): HWND rmWnd = FindWindowEx(NULL, NULL, L"DummyRainWClass", NULL); or HWND rmWnd = FindWindowEx(NULL, NULL, L"DummyRainWClass", L"Rainmeter control window");
Besides balala's and Brian's suggestions, if you really want an .exe doing that, you could try AutoIt or AutoHotKey, as the process is roughly similar to C++ (using another window class though, not sure if the example from the manual is up to date in that regard - you could try that in C++ too and see if it changes things for the better), see this related example: https://forum.rainmeter.net/viewtopic.php?t=42450&start=20#p215590
In AutoHotKey I could only do an equivalent v1 code, since there are a few changes in v2 that I either don't know how to implement or I do it incorrectly (nobody on their forum answered me on that issue yet).
In any case, these things are possible in these programs too, since I basically made an almost complete "window spy" skin working with the rarely used WindowMessage plugin for Rainmeter.