It is currently August 10th, 2020, 3:57 pm

[Bug] Rainmeter opens PNGs, ICOs, other files randomly

Report bugs with the Rainmeter application and suggest features.
User avatar
jsmorley
Developer
Posts: 21235
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by jsmorley »

There is really no need to remove the physical file in order to "disable" a plugin. Just don't have any skins that use it, and it isn't in any way loaded or executed. The only thing that will still happen is that the properties of the .dll file are read when Rainmeter is refreshed, so the details can be added to the About / Plugins dialog.
User avatar
jsmorley
Developer
Posts: 21235
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by jsmorley »

I fail to see how IsFullScreen could be the culprit in this, although I guess anything is possible. Here is the code for PluginIsFullScreen.cpp:

Code: Select all

#include <Windows.h>
#include <Psapi.h>
#include <string>
#include "../../API/RainmeterAPI.h"

struct Measure
{
	std::wstring processName;
	Measure() {}
};

PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
	Measure* measure = new Measure;
	*data = measure;
}

PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	Measure* measure = (Measure*)data;
}

PLUGIN_EXPORT double Update(void* data)
{
	Measure* measure = (Measure*)data;
	measure->processName.clear();

	double foundFullScreen = 0.0;
	RECT appBounds = { 0 };
	RECT screenBounds = { 0 };
	HWND foregroundHandle = GetForegroundWindow();

	GetWindowRect(GetDesktopWindow(), &screenBounds);

	if (foregroundHandle != GetDesktopWindow() && foregroundHandle != GetShellWindow())
	{
		DWORD processPID;
		GetWindowThreadProcessId(foregroundHandle, &processPID);

		HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processPID);
		if (processHandle)
		{
			WCHAR processName[MAX_PATH];
			if (0 != GetModuleBaseName(processHandle, NULL, processName, MAX_PATH))
			{
				measure->processName = processName;
			}

			CloseHandle(processHandle);
		}

		GetWindowRect(foregroundHandle, &appBounds);
		if (EqualRect(&appBounds, &screenBounds))
		{
			foundFullScreen = 1.0;
		}
	}

	return foundFullScreen;
}

PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
	Measure* measure = (Measure*)data;
	return measure->processName.c_str();
}

//PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args)
//{
//   Measure* measure = (Measure*)data;
//}

PLUGIN_EXPORT void Finalize(void* data)
{
	Measure* measure = (Measure*)data;
	delete measure;
}
So what it does is figure out what process is in the "foreground", then get the window handle for that process and see if that window is "full screen", if the size of the process window is the same as the size of the primary screen. It does open a handle to the existing process, so it can get the process "name" from the process PID. I can't really see how this code can cause anything to be "executed". It's not "running" anything. The function OpenProcess() doesn't mean "open some process", it means "take a look at some existing open process".

I'd be interested to see what number and string values the measure is returning when this behavior happens, although this is a little tricky to get, since unless you have About / Skins open on a second monitor, you are likely to be unable to see the current value without giving focus to the About dialog, which will change the value.
User avatar
Yincognito
Posts: 2223
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by Yincognito »

jsmorley wrote: July 24th, 2020, 12:25 pm There is really no need to remove the physical file in order to "disable" a plugin. Just don't have any skins that use it, and it isn't in any way loaded or executed. The only thing that will still happen is that the properties of the .dll file are read when Rainmeter is refreshed, so the details can be added to the About / Plugins dialog.
I know, and you're right, of course. That's just me, keeping redundancy and aggregation of things I don't use to a minimum (since I also generally avoid using "unofficial" / not fully "suported" plugins in my code). :) I know this may look exaggerate, but I do the same with my skins, by the way, only my suite and a skin to measure dimensions / position are in my Rainmeter folder - the others are on a separate partition. I would have deleted Illustro as well, but it's pointless since it comes by default with Rainmeter, so it's the only lucky product to survive my little obsession with keeping only the things I use "alive".

One potential / hypothetical benefit of this is minimizing possible conflicts between plugins when I test or install some other skin. If it's not IsFullScreen at fault for the OP's problem (it certainly looks that way looking at the code), that's the next thing in line for a cause of this. As far as I recall, he's using multiple plugins for his on focus / menu skin(s), so who knows, maybe this could play a part as well. As I said, it's annoying when things happen at random, as the debugging and identification of the actual issue / culprit takes much more time and there's is always an element of uncertainty as to whether the solution fixed things or not. I prefer persistent issues at any time over random ones - much easier to solve and get to the bottom of it.
User avatar
jsmorley
Developer
Posts: 21235
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by jsmorley »

Yincognito wrote: July 24th, 2020, 1:24 pm I know, and you're right, of course. That's just me, keeping redundancy and aggregation of things I don't use to a minimum (since I also generally avoid using "unofficial" / not fully "suported" plugins in my code). :) I know this may look exaggerate, but I do the same with my skins, by the way, only my suite and a skin to measure dimensions / position are in my Rainmeter folder - the others are on a separate partition. I would have deleted Illustro as well, but it's pointless since it comes by default with Rainmeter, so it's the only lucky product to survive my little obsession with keeping only the things I use "alive".

One potential / hypothetical benefit of this is minimizing possible conflicts between plugins when I test or install some other skin. If it's not IsFullScreen at fault for the OP's problem (it certainly looks that way looking at the code), that's the next thing in line for a cause of this. As far as I recall, he's using multiple plugins for his on focus / menu skin(s), so who knows, maybe this could play a part as well. As I said, it's annoying when things happen at random, as the debugging and identification of the actual issue / culprit takes much more time and there's is always an element of uncertainty as to whether the solution fixed things or not. I prefer persistent issues at any time over random ones - much easier to solve and get to the bottom of it.
I sympathize with a desire to keep things as clean as possible. I'm much the same way. My only fear with doing that with plugins, is that there is some value in having the latest version of any given plugin physically present, as it will avoid having some older .rmskin, that you install to test out, install some older version of the plugin. My rule of thumb is to keep around any plugins that I ever use, and keep ALL versions of the plugin in @Vault, just in case I want, for some reason, to return to an earlier version of a plugin. There are for instance 7 versions of IsFullScreen that have been released over time, and I certainly want to be sure I'm using the very latest one.


2.jpg



It does mean my About / Plugin dialog gets a little long... ;-)


1.jpg


2/3's or more of these plugins I would NEVER use in a skin myself, but you never know what I am going to be testing to help some user.
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Posts: 2223
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by Yincognito »

jsmorley wrote: July 24th, 2020, 1:33 pm I sympathize with a desire to keep things as clean as possible. I'm much the same way. My only fear with doing that with plugins, is that there is some value in having the latest version of any given plugin physically present, as it will avoid having some older .rmskin, that you install to test out, install some older version of the plugin. My rule of thumb is to keep around any plugins that I ever use, and keep ALL versions of the plugin in @Vault, just in case I want, for some reason, to return to an earlier version of a plugin. There are for instance 7 versions of IsFullScreen that have been released over time, and I certainly want to be sure I'm using the very latest one.



2.jpg




It does mean my About / Plugin dialog gets a little long... ;-)



1.jpg



2/3's or more of these plugins I would NEVER use in a skin myself, but you never know what I am going to be testing to help some user.
Yep, that suits your case, as you handle other stuff in Rainmeter as well, and it's good to be as aware as possible on the evolution of a plugin; not to mention the plugin (IsFullScreen) is your work and as any good developer you keep backups of your previous versions and / or resources. I also keep the old versions of my works (finished or not) but use their latest version (in Rainmeter or otherwise) for a similar reason, just in case I want to go back and start on a different route, while keeping as up to date as possible with everything:
Versions.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 11192
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by balala »

Yincognito wrote: July 24th, 2020, 8:37 am I don't know how Cariboudjan does it, but I just delete them (if I don't need them anymore) from both the @Vault folder and the C:\Users\<UserName>\AppData\Roaming\Rainmeter\Plugins folder, or move them to another drive or something (if it's only a temporary thing).
Yes, but this isn't a disabling, it's a removing.
Yincognito wrote: July 24th, 2020, 8:37 am I might be wrong, but I didn't see any option in Rainmeter itself to "disable" a plugin on the fly, so I use brute force on it. :twisted:
Agree, nor me. I'd be curious how can a plugin disabled.
User avatar
jsmorley
Developer
Posts: 21235
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by jsmorley »

balala wrote: July 24th, 2020, 3:37 pm Yes, but this isn't a disabling, it's a removing.

Agree, nor me. I'd be curious how can a plugin disabled.
It depends a bit on the plugin in question. For the most part, plugins use the Update() function in the plugin to do the "work", and that is controlled by the update of the skin measure, just like any other measure. There are some, like UsageMonitor, that don't depend on the Update() function, but are always running when they are active in any skin. UsageMonitor really can't be "disabled" once it is running. You can stop it from returning values to the skin, but you really can't stop it from polling the performance counters.

It's up to the plugin author how they structure things, but we recommend that all "work" be done in the Update() function. That gives the most control to the skin author, and is the most efficient way to design things.
User avatar
Yincognito
Posts: 2223
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by Yincognito »

balala wrote: July 24th, 2020, 3:37 pm Yes, but this isn't a disabling, it's a removing.

Agree, nor me. I'd be curious how can a plugin disabled.
Fair enough on the semantics... although removing does achieve the end purpose of "disabling", from a technical point of view. :D
User avatar
Cariboudjan
Posts: 89
Joined: May 12th, 2019, 8:55 am

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by Cariboudjan »

balala wrote: July 24th, 2020, 6:28 am How do you disable a plugin?
Change to .old. I do this with AHK to toggle on/off .old extension.
Last edited by Cariboudjan on July 24th, 2020, 4:02 pm, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 21235
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Rainmeter opens PNGs, ICOs, other files randomly

Post by jsmorley »

You can see how the API for plugins is structured here:

https://docs.rainmeter.net/developers/plugin/cpp/