It is currently March 19th, 2024, 5:13 am

[Suggestion] Rainmeter should know when a fullscreen application is running

Report bugs with the Rainmeter application and suggest features.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

[Suggestion] Rainmeter should know when a fullscreen application is running

Post by Virginityrocks »

I know it's possible. There are several apps, like Controller Companion that 1:1 know when an app, including a youtube video, is fullscreen.

I'd like for Rainmeter to know when an app is fullscreen, so skins can utilize that information to change Zpos on demand. For example, skins that are set to Topmost can be automatically set to On Desktop whenever a fullscreen app is launched, and vice versa.

I'm aware of applications like RainGame, but this is not built-in and is not automatic. There aren't any bangs or settings in skins such as OnFullscreenAction=. I'd like this to be added in to give Rainmeter more functionality and friendliness when using Topmost and Stay Topmost skins, so they do not obstruct windows when apps are launched in fullscreen.
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by jsmorley »

Not sure if we will be adding that to Rainmeter directly, perhaps at some point.

It will never be an action like OnFullScreenAction, we are just not going to have Rainmeter constantly polling for that. However, it is something that might be appropriate for the SysInfo plugin. We will see.

In the meantime, you might try this plugin:

https://forum.rainmeter.net/viewtopic.php?p=147499#p147499

This plugin will check to see if the "foreground" window, the window that currently has focus, is full screen. The measure will return "1" if so, and "0" if not.

This is only relevant to the primary monitor if you have more than one. It is also only about "full screen", and has no interest in "maximized". That is not the same thing.

Note that if you have a Rainmeter skin set to "Stay topmost" and run some game or program full screen, that is fine unless you click on the Rainmeter skin, as then IT will have "focus" and is not full screen, so the plugin will change to zero. This should not be an issue, since I assume the point is to immediately unload or move to the back any skins that conflict with your game or video or whatever.

As far as I can tell, this should work with any full screen application, desktop program or DirectX game. Certainly seems to work fine with YouTube or other videos running full screen.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=IsFullScreen
Author=JSMorley
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Demonstrates IsFullScreen Plugin.
; This plugin will check to see if the "foreground" window, the window that currently has
; "focus", is full screen. The measure will return "1" if so, and "0" if not.

[MeasureIsFullScreen]
Measure=Plugin
Plugin=IsFullScreen
UpdateDivider=5
IfCondition=MeasureIsFullScreen=1
IfTrueAction=[!SetOption MeterIsFullScreen Text "A full screen program has focus"][!Log "A full screen program has focus"]
IfFalseAction=[!SetOption MeterIsFullScreen Text "Active window not full screen"][!Log "Active window not full screen"]

[MeterIsFullScreen]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
You can have the IfCondition do whatever you like, maybe unload some skins, or set the ZPos of some or whatever actions you want to take. About the only thing you probably don't want to use it to do is unload Rainmeter, as then you pull the rug out from under it, and you have no way to know when the full screen program has ended and Rainmeter should be restarted.

Plugin code:

Code: Select all

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

RECT appBounds;
RECT screenBounds;
HWND foregroundHandle;

struct Measure
{
	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;

	foregroundHandle = GetForegroundWindow();

	GetWindowRect(GetDesktopWindow(), &screenBounds);

	if (foregroundHandle != GetDesktopWindow() && foregroundHandle != GetShellWindow())
	{
		GetWindowRect(foregroundHandle, &appBounds);
		if (EqualRect(&appBounds, &screenBounds))
		{
			return 1.0;
		}
	}

	return 0.0;
}

//PLUGIN_EXPORT LPCWSTR GetString(void* data)
//{
//	Measure* measure = (Measure*)data;
//	return L"";
//}

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

PLUGIN_EXPORT void Finalize(void* data)
{
	Measure* measure = (Measure*)data;
	delete measure;
}
32 bit and 64bit versions of the plugin for distribution are included in the @Resources folder of the example skin. I probably wouldn't start releasing skins using this to deviantART just yet, I wrote this like 5 minutes ago, and we should make sure it does what is expected with no issues.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by Virginityrocks »

Works perfectly. Thank you. My only problem is that the plugin seems to think that the desktop is a fullscreen application. When the desktop has focus, it switches to "A full screen program has focus". If there's a way around this, please let me know.
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by jsmorley »

Virginityrocks wrote:Works perfectly. Thank you. My only problem is that the plugin seems to think that the desktop is a fullscreen application. When the desktop has focus, it switches to "A full screen program has focus". If there's a way around this, please let me know.
It shouldn't. It is specifically designed not to do that. Doesn't for me on Win10...

What version of Windows are you on?
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by Virginityrocks »

Windows 10 64-bit
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by jsmorley »

Virginityrocks wrote:Windows 10 64-bit
Well, I'll be hornswoggled. This "if" statement should preclude that, and does for me:

if (foregroundHandle != GetDesktopWindow() && foregroundHandle != GetShellWindow())

You have more than one monitor? You running any software, Fences, Display Fusion or anything else that might in any way interact with the desktop window? In particular any that catch mouse clicks on the desktop.

If you click on the desktop the the window handle foregroundHandle should be the same as the handle returned by the GetDesktopWindow() function. In that case, it should skip any further comparisons and just return zero.
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by jsmorley »

I think I might see the issue. The desktop window is the base window for the desktop, created when you log in to Windows, its primary job is to hold the wallpaper you are using. However, if you have icons on your desktop, shortcuts, standard icons like recycle bin or documents, etc., then it looks like a child window is apparently created that is has a list view control that displays the icons. I suspect that when you have icons on the desktop and click there, the foreground window handle that is returned is this child window instead of the main desktop window.

I will have to explore this a bit, it's not quite as simple as what I have now, and I'm not sure you can easily get there. Windows isn't really excited about encouraging programs to mess with either of these windows, they belong to the shell, not to you.

Edit: I have tried putting all kinds of crap on my desktop, and I still can't get this to misbehave for me. I'm a bit puzzled why it is different for you.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by Virginityrocks »

I'll try to get more information later and test this on more machines.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by Virginityrocks »

Code: Select all

[MeasureIsFullScreen]
Measure=Plugin
Plugin=IsFullScreen
IfCondition=MeasureIsFullScreen=1
IfTrueAction=[!Zpos -2]
IfFalseAction=[!Zpos 1]
This causes Rainmeter to crash when the computer is woken from sleep mode. Not sure why. Taking away the [!Zpos] actions stops the crash.

(Unrelated) This also crashes Rainmeter when booting back from sleep mode:

Code: Select all

[ResetWorkArea]
Measure=Calc
Formula=#WorkAreaHeight#
OnChangeAction=[!RefreshApp]
DynamicVariables=1
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: [Suggestion] Rainmeter should know when a fullscreen application is running

Post by Bekarfel »

jsmorley wrote:About the only thing you probably don't want to use it to do is unload Rainmeter, as then you pull the rug out from under it, and you have no way to know when the full screen program has ended and Rainmeter should be restarted.
Sounds like a bug to me, someone should file a report :D
Post Reply