It is currently December 4th, 2020, 1:09 am

IsFullScreen 3.0

Plugins and Addons popular with the Community
User avatar
balala
Rainmeter Sage
Posts: 11858
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IsFullScreen 3.0

Post by balala »

mambans wrote: November 21st, 2019, 9:43 pm Hello, I can't seem to figure out how to change the update/refresh interval when in fullscreen.
The [Rainmeter] section doesn't support dynamic changes, which means you can't change the Update value of a skin dynamically, while the skin is loaded. The only way to achieve this is to write physically the new value through a !WriteKeyValue bang, but this requires a refresh of the skin.
What you can do is to change dynamically the UpdateDivider of different sections (meters and measures precisely). A such change can be made dynamically, either with !SetVariable, or with !SetOption bang.
User avatar
mambans
Posts: 3
Joined: November 21st, 2019, 9:39 pm

Re: IsFullScreen 3.0

Post by mambans »

Ah oke, thanks. I changed it to a variable but the "IfTrueAction" under "[MeasureIsFullScreen]" still doesn't work. Do you have any tip?
Appreciate the help.

Code: Select all

[Variables]
@include=#@#User\Options.inc
RefreshRate=1

;------------------------------------------------------------------

[Metadata]
Name=IsFullScreen
Author=JSMorley
Version=3.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Demonstrates IsFullScreen Plugin.

[MeasureIsFullScreen]
Measure=Plugin
Plugin=IsFullScreen
IfCondition=MeasureIsFullScreen=1
IfTrueAction=[!SetVariable RefreshRate 5]
IfFalseAction=[!SetVariable RefreshRate 1]

;------------------------------------------------------------------

[MeasureCores]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\CurrentControlSet\Control\Session Manager\Environment
RegValue=NUMBER_OF_PROCESSORS
UpdateDivider=#RefreshRate#
User avatar
balala
Rainmeter Sage
Posts: 11858
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IsFullScreen 3.0

Post by balala »

mambans wrote: November 22nd, 2019, 4:03 pm Ah oke, thanks. I changed it to a variable but the "IfTrueAction" under "[MeasureIsFullScreen]" still doesn't work. Do you have any tip?
Yep, I have. It does work, however there something is missing. When the [MeasureIsFullScreen] measure returns 1, the IfTrueAction is executed, RefreshRate variable is set to 5, but the [MeasureCores] measure can't use it, because it is dynamically set. Add a DynamicVaribales=1 option to the measure to make it to use the variable.
User avatar
mambans
Posts: 3
Joined: November 21st, 2019, 9:39 pm

Re: IsFullScreen 3.0

Post by mambans »

balala wrote: November 22nd, 2019, 4:33 pm Yep, I have. It does work, however there something is missing. When the [MeasureIsFullScreen] measure returns 1, the IfTrueAction is executed, RefreshRate variable is set to 5, but the [MeasureCores] measure can't use it, because it is dynamically set. Add a DynamicVaribales=1 option to the measure to make it to use the variable.
Now it works :) Thanks a lot for the help!
User avatar
balala
Rainmeter Sage
Posts: 11858
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IsFullScreen 3.0

Post by balala »

mambans wrote: November 22nd, 2019, 4:50 pm Now it works :) Thanks a lot for the help!
You're welcome. I'm glad if it does. :thumbup:
User avatar
Krainz
Posts: 190
Joined: May 27th, 2012, 5:16 am

Re: IsFullScreen 3.0

Post by Krainz »

Does this work with windowed fullscreen / borderless windowed games?

It's slowly becoming the standard over regular fullscreen
User avatar
Cariboudjan
Posts: 117
Joined: May 12th, 2019, 8:55 am

Re: IsFullScreen 3.0

Post by Cariboudjan »

Is there a way to have the plugin check to see if a window is fullscreen on a non-primary display?
User avatar
jsmorley
Developer
Posts: 21520
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IsFullScreen 3.0

Post by jsmorley »

Cariboudjan wrote: February 26th, 2020, 7:46 pm Is there a way to have the plugin check to see if a window is fullscreen on a non-primary display?
No, sorry.
Cherryleaf
Posts: 2
Joined: February 27th, 2020, 5:12 am

Re: IsFullScreen 3.0

Post by Cherryleaf »

Hello! Thank you for this plugin!

I also needed the feature of detecting maximized and windowed windows, so I decided to alter your plugin to handle those cases as well. It was fairly easy.

CPP code

Code: Select all

#include <Windows.h>
#include <WinUser.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();

	// 1.0 = fullscreen
	// 2.0 = maximized
	// 3.0 = windowed
	double foundResult= 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);
		}

		// Fullscreen
		GetWindowRect(foregroundHandle, &appBounds);
		if (EqualRect(&appBounds, &screenBounds))
		{
			foundResult = 1.0;
		}
		// Maximized
		else if (IsZoomed(foregroundHandle)) {
			foundResult = 2.0;
		}
		// Windowed
		// Probably could've used only else, but this is here for a sanity check
		else if (IsWindowVisible(foregroundHandle)) {
			foundResult = 3.0;
		}
	}

	return foundResult;
}

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;
}
skin code

Code: Select all

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

[Metadata]
Name=ForegroundWindowState
Author=JSMorley (updated 2/2020)
Version=4.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Demonstrates ForegroundWindowState Plugin.
; This plugin will check to see if the "foreground" window, the window that currently has
; "focus", is full screen, maximized, or windowed.
; Values returned:
; 1 if full screen,
; 2 if maximized
; 3 if windowed
; 0 none of these (probably an unhandled condition)
; empty string: Desktop has focus
; 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 applies to 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".

[MeasureForegroundWindowState]
Measure=Plugin
Plugin=ForegroundWindowState
IfCondition=MeasureForegroundWindowState=1
IfTrueAction=[!SetOption MeterForegroundWindowState Text "Full screen and has focus"][!UpdateMeter *][!Redraw]
IfCondition2=MeasureForegroundWindowState=2
IfTrueAction2=[!SetOption MeterForegroundWindowState Text "Maximized and has focus"][!UpdateMeter *][!Redraw]
IfCondition3=MeasureForegroundWindowState=3
IfTrueAction3=[!SetOption MeterForegroundWindowState Text "Windowed and has focus"][!UpdateMeter *][!Redraw]
IfCondition4=MeasureForegroundWindowState=0
IfTrueAction4=[!SetOption MeterForegroundWindowState Text "Unhandled condition. You should report this"][!UpdateMeter *][!Redraw]
IfMatch=^$
IfMatchAction=[!SetOption MeterProcessName Text "Desktop"][!HideMeter MeterForegroundWindowState][!UpdateMeter *][!Redraw]
IfNotMatchAction=[!SetOption MeterProcessName Text ""][!ShowMeter MeterForegroundWindowState][!UpdateMeter *][!Redraw]

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

[MeterForegroundWindowState]
Meter=String
Y=30
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
I also compiled the dll's already into a rmskin. ;) I renamed the plugin as it includes more features. I consider it the 4th version of your plugin. Thanks for your plugin again. ;)

P.S. Forgive me if I got anything wrong. This is literally my FIRST foray into rainmeter. It seems the first thing I did was edit a dll plugin instead of making a skin. :D Should I make this a new topic instead? :confused:

Also note: This was built in the latest version of Windows 10. I don't guarantee support for any older Windows OS versions.
ForegroundWindowState_4.0.rmskin
You do not have the required permissions to view the files attached to this post.
Cherryleaf
Posts: 2
Joined: February 27th, 2020, 5:12 am

Re: IsFullScreen 3.0

Post by Cherryleaf »

Cariboudjan wrote: February 26th, 2020, 7:46 pm Is there a way to have the plugin check to see if a window is fullscreen on a non-primary display?
This code would do it, but I'm not sure if I feel like implementing it.

Code: Select all

bool isFullscreen(HWND windowHandle)
{
    MONITORINFO monitorInfo = { 0 };
    monitorInfo.cbSize = sizeof(MONITORINFO);
    GetMonitorInfo(MonitorFromWindow(windowHandle, MONITOR_DEFAULTTOPRIMARY), &monitorInfo);

    RECT windowRect;
    GetWindowRect(windowHandle, &windowRect);

    return windowRect.left == monitorInfo.rcMonitor.left
        && windowRect.right == monitorInfo.rcMonitor.right
        && windowRect.top == monitorInfo.rcMonitor.top
        && windowRect.bottom == monitorInfo.rcMonitor.bottom;
}