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 : Tuesday, November 26, 2019 1:35:16 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,185
United States
Location: Tampa, FL

Thanks: 25 times
Was thanked: 364 time(s) in 317 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.DXMonitorBrightness.GetMonitorFromPoint(action.Start);

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

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

    if(!DXMonitorBrightness.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.DXMonitorBrightness.DestroyPhysicalMonitors(aPhysicalMonitors);
}

Edited by user Tuesday, February 15, 2022 6:31:46 PM(UTC)  | Reason: Not specified

Matija  
#2 Posted : Tuesday, February 15, 2022 5:12:54 PM(UTC)
Matija

Rank: Member

Reputation:

Groups: Approved
Joined: 6/11/2021(UTC)
Posts: 24
Croatia

Thanks: 6 times
Hi, this is what I get when I try to use the example script:

Code:

[ScriptEngine.Execute() - ScriptEngineException] TypeError: DXMonitorBrightness.GetMonitorFromPoint is not a function
    at Script [162]:13:36 -> var hMonitor = DXMonitorBrightness.GetMonitorFromPoint(action.Start);


Is there an easy way to make it work again?
Rob  
#3 Posted : Tuesday, February 15, 2022 6:32:03 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,185
United States
Location: Tampa, FL

Thanks: 25 times
Was thanked: 364 time(s) in 317 post(s)
Hmm, in one of the recent updates changing the class structure, I thought I had this handled - but I guess not.

I've updated the original post script, try it out.
randomConstant  
#4 Posted : Monday, May 16, 2022 6:27:13 PM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 115
Pakistan

Thanks: 32 times
Was thanked: 10 time(s) in 9 post(s)
I am getting the following error when trying to use the provided script,
Code:
Error:
Error: An error occurred while transmitting data to the device on the I2C bus

Which has the following discussion on stackoverflow: I2C error when using the Windows Monitor Configuration Functions

Something about laptop displays not supporting DDC/CI..
Is there any alternative to this?

Thanks

Edit: Found that the error is already mentioned on the forum and another plugin which works for me.
Link to post: Adjust Screen Brightness

Edited by user Monday, May 16, 2022 6:35:46 PM(UTC)  | Reason: Not specified

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.