StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rob  
#1 Posted : Monday, November 25, 2019 6:35:16 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 506
United States

Thanks: 5 times
Was thanked: 99 time(s) in 86 post(s)
This plug-in adds the functionality of the original StrokesPlus' acGetMonitorBrightness and acSetMonitorBrightness functions. Note that this is dependent on DirectX and device compatibility, which is why it's not included in StrokesPlus.net itself.

https://www.strokesplus.net/files/DXMonitorBrightness.zip

Download the file into your StrokesPlus.net\Plug-Ins folder and Reload S+.net from the tray icon.


NOTE: Windows may mark the DLL as unsafe or blocked. Right click the DLL and select Properties, there will be an option to unblock it.

Here's an example script which first gets the brightness and shows it to you, then sets the brightness to 50% (0.5).
The brightness scale is 0.0 - 1.0 (it seems), where 1.0 is 100%, 0.5 is 50%, etc.

Code:
var doubleT = host.type('System.Double');
var dNewBrightness = host.cast(doubleT, 0.5);  //Set brightness to 50%, 1.0 would be 100%

//Get monitor from point
var hMonitor = DXMonitorBrightness.GetMonitorFromPoint(action.Start);

//Get the physical monitor handle(s) from the monitor
var aPhysicalMonitors = DXMonitorBrightness.GetPhysicalMonitors(hMonitor)

//Attempt to access the DX monitor APIs
try {
    var dCurrentBrightness = host.cast(doubleT,DXMonitorBrightness.GetMonitorBrightnessA(aPhysicalMonitors[0]));
    sp.MessageBox("dCurrentBrightness: " + dCurrentBrightness, "dCurrentBrightness");

    if(!DXMonitorBrightness.SetMonitorBrightnessA(aPhysicalMonitors[0], dNewBrightness)) {
        sp.MessageBox("Failed to update brightness", "DXMonitorBrightness");
    } 
} catch (err) {
    //An error was encountered either getting or setting the brightness 
    sp.MessageBox("Error:\n" + err, "Error");
} finally {
    // Close the monitor handles.
    DXMonitorBrightness.DestroyPhysicalMonitors(aPhysicalMonitors);
}
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.