It is currently December 14th, 2018, 8:29 pm

IsFullScreen 3.0

Share your custom plugins and applications to enhance Rainmeter.
User avatar
jsmorley
Developer
Posts: 18494
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

IsFullScreen 3.0

jsmorley » April 18th, 2018, 3:25 am

This demonstrates (and installs) a small plugin that will return a number value of 1 if the application window that currently has focus is running in "full screen" mode, and 0 if not.

New! Thanks to some help from brian (THANKS!), The parent process name of the currently focused window will be returned as the string value.

Important note: This will be unable to detect any process run "As administrator" unless Rainmeter itself is run "As administrator". Otherwise, it should work with any full screen application, such as media players, Youtube in your browser, and games.

Note that this has to do with an application window on the "primary" monitor, the same one Rainmeter is hosted on. Running an application full screen on a second monitor will not trigger this.

Note that if you set the size of a Rainmeter skin to #SCREENAREAWIDTH# and #SCREENAREAHEIGHT#, and the skin is on the primary monitor at a position of 0,0, it will qualify as "full screen" and will cause this plugin to return 1 and Rainmeter.exe.

New: The string value of the measure will now always be the parent process of the currently focused window. If the Desktop has focus, 0 and an empty string will be returned. The number value will still be 1 or 0 depending on whether the window is full screen or not.

So full screen considerations aside, this plugin can also be used to answer the question "does process blah.exe currently have focus?".

Note that the parent process for all Windows 10 "apps", including things like Settings or Windows Update, as well as apps like OneNote or Calculator, is a process called ApplicationFrameHost.exe. That will always be returned in those cases. No, it can't tell you that you are playing Microsoft Solitaire.

Note that the parent process for all Window Explorer elements, like the Taskbar or any File Manager windows, is Explorer.exe. That will always be returned in those cases. No, it can't tell you that you have the folder C:\MyStuff\ open.


The 32bit and 64bit .dll files are also included in @Resources for use in your own .rmskins, and of course if you have the latest 4.2 of Rainmeter or better, installing this will put the plugin in @Vault\Plugins in your Skins folder.
IsFullScreen_3.0.rmskin
Skin:

Code: Select all

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

[Metadata]
Name=IsFullScreen
Author=JSMorley
Version=3.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 as the number value if so, and
; 0 as the number value if not. The name of the process for the currently focused window will
; be returned as the string value. An empty string will be returned if the Desktop has focus.

; Note that this is not about "maximized", but rather "full screen".
; Note that this applies to full screen windows on the "primary" monitor only.
; Note that this will be unable to detect any process run "As administrator" unless Rainmeter itself is run "As administrator".

[MeasureIsFullScreen]
Measure=Plugin
Plugin=IsFullScreen
IfCondition=MeasureIsFullScreen=1
IfTrueAction=[!SetOption MeterIsFullScreen Text "Full screen and has focus"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterIsFullScreen Text "Not full screen"][!UpdateMeter *][!Redraw]
IfMatch=^$
IfMatchAction=[!SetOption MeterProcessName Text "Desktop"][!HideMeter MeterIsFullScreen][!UpdateMeter *][!Redraw]
IfNotMatchAction=[!SetOption MeterProcessName Text ""][!ShowMeter MeterIsFullScreen][!UpdateMeter *][!Redraw]

[MeterProcessName]
Meter=String
MeasureName=MeasureIsFullScreen
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

[MeterIsFullScreen]
Meter=String
Y=30
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
IsFullScreen.dll C++ source code:

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;
}
You do not have the required permissions to view the files attached to this post.
Last edited by jsmorley on April 19th, 2018, 2:08 am, edited 1 time in total.
User avatar
Active Colors
Moderator
Posts: 498
Joined: February 16th, 2012, 3:32 am

Re: IsFullScreen

Active Colors » April 18th, 2018, 4:05 am

Sweet plugin. Was looking for this type of thing couple of month before. Thanks jsmorley!
Why is it not posted it the Plugins section by the way?
User avatar
jsmorley
Developer
Posts: 18494
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IsFullScreen

jsmorley » April 18th, 2018, 4:08 am

Active Colors wrote:Sweet plugin. Was looking for this type of thing couple of month before. Thanks jsmorley!
Why is it not posted it the Plugins section by the way?
Moved...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3053
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IsFullScreen

eclectic-tech » April 18th, 2018, 12:59 pm

The rmskin package says the plugin is the same version when installing... I think you forgot to update the version.
I have version 1 installed... and it says the versions are the same. Did the plugin change or only the skin code? :confused:
User avatar
jsmorley
Developer
Posts: 18494
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IsFullScreen

jsmorley » April 18th, 2018, 1:03 pm

eclectic-tech wrote:The rmskin package says the plugin is the same version when installing... I think you forgot to update the version.
I have version 1 installed... and it says the versions are the same. Did the plugin change or only the skin code? :confused:
There is something wrong with the way the version is being compared for this plugin, and we are digging into it. So far, it's a mystery.

Just check the box to "force" it to install the newer version.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3053
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IsFullScreen

eclectic-tech » April 18th, 2018, 1:14 pm

jsmorley wrote:There is something wrong with the way the version is being compared for this plugin, and we are digging into it. So far, it's a mystery.

Just check the box to "force" it to install the newer version.
Did that! Just wanted to let you know... :welcome:
User avatar
jsmorley
Developer
Posts: 18494
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IsFullScreen

jsmorley » April 18th, 2018, 1:16 pm

eclectic-tech wrote:Did that! Just wanted to let you know... :welcome:
Yeah, thanks! We are scratching our heads and staring at this intently.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3053
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IsFullScreen

eclectic-tech » April 18th, 2018, 1:26 pm

jsmorley wrote:Yeah, thanks! We are scratching our heads and staring at this intently.
That's my normal reaction when testing code! :lol:
User avatar
jsmorley
Developer
Posts: 18494
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IsFullScreen

jsmorley » April 18th, 2018, 1:37 pm

eclectic-tech wrote:That's my normal reaction when testing code! :lol:
I think I found it. It appears to have been a bug in Microsoft Visual Studio, and updating that seems to have corrected the issue. I have created a 2.1 version, which is in the first post. Can you get that and make sure it says "Replace" for the plugin when you install it? And if you install it again, it should say "Versions are the same".
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3053
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IsFullScreen

eclectic-tech » April 18th, 2018, 2:27 pm

jsmorley wrote:I think I found it. It appears to have been a bug in Microsoft Visual Studio, and updating that seems to have corrected the issue. I have created a 2.1 version, which is in the first post. Can you get that and make sure it says "Replace" for the plugin when you install it? And if you install it again, it should say "Versions are the same".
It works the way you would expect; replaced on first install and said versions were the same on second attempt. :17good