-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CreateInParameters, SetPropertyValue Wont work without : using (WmiMethod setMethod = obj.GetMethod("method name")) #45
Comments
You are assigning values to WMI objects. This feature is not fully implemented yet, as there has been no feature request for it until now. If you need this feature, I can provide a new version with it implemented within the week. |
@MartinKuschnik : Thanks man. Your response is very fast. I like that. Also, Love from India <3 Hats off to your work man... ! |
@MartinKuschnik : Also for your work, I have GlobalSign digital signature for DLL and exe. For 3 Year. Name as my personal name. I can sign your DLL without any cost. If you need, I can anytime do it for you, man ! I'm waiting for new release.... !!! |
@haseakash Please have a look to Version 6.10.0 that addes the The follwoing code should work: public static void SetLidCloseAction(int actionValue)
{
// GUID for lid close action setting (this GUID is standard across Windows versions)
string lidCloseGuid = "{5ca83367-6e45-459f-a27b-476b1d01c936}";
// WMI query to retrieve current power settings related to lid close action
string query = $"SELECT * FROM Win32_PowerSettingDataIndex WHERE InstanceID LIKE '%{lidCloseGuid}%'";
using (WmiConnection connection = new WmiConnection(@"\\.\root\cimv2\power"))
{
// Query the WmiMonitorBrightnessMethods class to get access to the method
foreach (WmiObject obj in connection.CreateQuery(query))
{
obj.SetPropertyValue("SettingIndexValue", actionValue);
obj.Put();
}
}
} |
Thank you so much bro.
You are a genius and lifesaver.
Hats off bro!
Respect!
…On Thu, Jan 2, 2025, 8:10 PM Martin Kuschnik ***@***.***> wrote:
@haseakash <https://github.com/haseakash> Please have a look to Version
6.10.0 <https://www.nuget.org/packages/WmiLight/6.10.0> that addes the Put
method.
The follwoing code should work:
public static void SetLidCloseAction(int actionValue){
// GUID for lid close action setting (this GUID is standard across Windows versions)
string lidCloseGuid = "{5ca83367-6e45-459f-a27b-476b1d01c936}";
// WMI query to retrieve current power settings related to lid close action
string query = $"SELECT * FROM Win32_PowerSettingDataIndex WHERE InstanceID LIKE '%{lidCloseGuid}%'";
using (WmiConnection connection = new WmiConnection(@"\\.\root\cimv2\power"))
{
// Query the WmiMonitorBrightnessMethods class to get access to the method
foreach (WmiObject obj in connection.CreateQuery(query))
{
obj.SetPropertyValue("SettingIndexValue", actionValue);
obj.Put();
}
}}
—
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5HB35UTBA6M3MICLF4BL2IVFWNAVCNFSM6AAAAABULZICC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRXHA3TMMBWGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
It Works bro,,
if you don't mind ,
using latest NuGet . What is converted code of following using WMILight
Then ?
public static void SetScreenBrightness(uint brightnessLevel)
{
// Ensure brightness level is within valid range
brightnessLevel = Math.Max(0, Math.Min(100, brightnessLevel));
// Query for WmiMonitorBrightnessMethods class
string query = "SELECT * FROM WmiMonitorBrightnessMethods";
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(@"root\wmi", query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject obj in queryCollection)
{
// Set brightness using WmiSetBrightness method
var inParams = obj.GetMethodParameters("WmiSetBrightness");
inParams["Brightness"] = brightnessLevel;
inParams["Timeout"] = 0; // No timeout for the change
obj.InvokeMethod("WmiSetBrightness", inParams, null);
}
}
.
It's really help me if you have time to reply me.
Regards,
SkyWorld Computers,
india
On Thu, Jan 2, 2025 at 11:31 PM Aakash Hase !!! ***@***.***>
wrote:
… Thank you so much bro.
You are a genius and lifesaver.
Hats off bro!
Respect!
On Thu, Jan 2, 2025, 8:10 PM Martin Kuschnik ***@***.***>
wrote:
> @haseakash <https://github.com/haseakash> Please have a look to Version
> 6.10.0 <https://www.nuget.org/packages/WmiLight/6.10.0> that addes the
> Put method.
>
> The follwoing code should work:
>
> public static void SetLidCloseAction(int actionValue){
> // GUID for lid close action setting (this GUID is standard across Windows versions)
> string lidCloseGuid = "{5ca83367-6e45-459f-a27b-476b1d01c936}";
>
> // WMI query to retrieve current power settings related to lid close action
> string query = $"SELECT * FROM Win32_PowerSettingDataIndex WHERE InstanceID LIKE '%{lidCloseGuid}%'";
>
> using (WmiConnection connection = new WmiConnection(@"\\.\root\cimv2\power"))
> {
> // Query the WmiMonitorBrightnessMethods class to get access to the method
> foreach (WmiObject obj in connection.CreateQuery(query))
> {
> obj.SetPropertyValue("SettingIndexValue", actionValue);
>
> obj.Put();
> }
> }}
>
> —
> Reply to this email directly, view it on GitHub
> <#45 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ASP5HB35UTBA6M3MICLF4BL2IVFWNAVCNFSM6AAAAABULZICC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRXHA3TMMBWGA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
The following code workes for me: public static void SetScreenBrightness(uint brightnessLevel)
{
// Ensure brightness level is within valid range
brightnessLevel = Math.Max(0, Math.Min(100, brightnessLevel));
using (WmiConnection connection = new WmiConnection(@"\\.\root\wmi"))
{
// Query the WmiMonitorBrightnessMethods class to get access to the method
foreach (var obj in connection.CreateQuery("SELECT * FROM WmiMonitorBrightnessMethods"))
{
using (WmiMethod setBrightnessMethod = obj.GetMethod("WmiSetBrightness"))
using (WmiMethodParameters parameters = setBrightnessMethod.CreateInParameters())
{
parameters.SetPropertyValue("Timeout", "0"); // Timeout in seconds (0 = immediate)
parameters.SetPropertyValue("Brightness", brightnessLevel.ToString());
int? result = obj.ExecuteMethod<int?>(setBrightnessMethod, parameters, out _);
if (result != null && result != 0)
throw new Exception($"Failed to set brightness. Error code: {result}");
}
}
}
} |
Thank you bro. My keep my previous code. That working too.
For this support. I am sharing the latest WmiLight Signed DLL files.
If you need for any purpose (without getting false positive)
I know you actually don't need it. But anytime want to sign then contact
me. I will share anytime with you man!
here is a Link ...
<links removed>
Thanks man!
Love for ur work <3.
…On Fri, Jan 3, 2025 at 2:30 PM Martin Kuschnik ***@***.***> wrote:
The following code workes for me:
public static void SetScreenBrightness(uint brightnessLevel){
// Ensure brightness level is within valid range
brightnessLevel = Math.Max(0, Math.Min(100, brightnessLevel));
using (WmiConnection connection = new WmiConnection(@"\\.\root\wmi"))
{
// Query the WmiMonitorBrightnessMethods class to get access to the method
foreach (var obj in connection.CreateQuery("SELECT * FROM WmiMonitorBrightnessMethods"))
{
using (WmiMethod setBrightnessMethod = obj.GetMethod("WmiSetBrightness"))
using (WmiMethodParameters parameters = setBrightnessMethod.CreateInParameters())
{
parameters.SetPropertyValue("Timeout", "0"); // Timeout in seconds (0 = immediate)
parameters.SetPropertyValue("Brightness", brightnessLevel.ToString());
int? result = obj.ExecuteMethod<int?>(setBrightnessMethod, parameters, out _);
if (result != null && result != 0)
throw new Exception($"Failed to set brightness. Error code: {result}");
}
}
}}
—
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5HBZBYU23BXMNRMMI7N32IZGRNAVCNFSM6AAAAABULZICC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRYHA4DENZQGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I have following code
I converted it to following using WmiLight ,
And Calling in my main Form As,
Problem is as i know ,
i just want to apply
with WmiLight .
As i know this does not depend on any Method Name. It i think directly set as PropertyValue.
But in WmiLight ,
SetPropertyValue will not works if there is no Method Name
i think it still required using (WmiMethod setMethod = obj.GetMethod("method name"))
May be im wrong. I dident find a solution , i tried all names on google etc . and chnage but still dosent work for me.
Can you fix to use SetPropertyValue without the obj.GetMethod("method name")) if any dosent have any method name?
And please tell me how to convert my code in WMILight ?
The text was updated successfully, but these errors were encountered: