Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Management;
- namespace Brightener
- {
- class Program
- {
- public static void Main(string[] args)
- {
- try
- {
- setBrightness(int.Parse(args[0]));
- }
- catch (Exception ex)
- {
- Console.WriteLine("Please enter a number between 1 and 100");
- }
- }
- private static void setBrightness(int brightnessLevel)
- {
- try
- {
- ManagementScope s = new ManagementScope("root\\WMI");
- SelectQuery q = new SelectQuery("WmiMonitorBrightnessMethods");
- ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(s, q);
- ManagementObjectCollection moc = mos.Get();
- foreach (System.Management.ManagementObject o in moc)
- {
- o.InvokeMethod("WmiSetBrightness", new object[] {
- UInt32.MaxValue,
- brightnessLevel
- });
- }
- moc.Dispose();
- mos.Dispose();
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement