This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Ciaran

By: a guest on Dec 14th, 2010  |  syntax: C#  |  size: 1.34 KB  |  views: 773  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Management;
  6.  
  7. namespace Brightener
  8. {
  9.     class Program
  10.     {
  11.  
  12.         public static void Main(string[] args)
  13.         {
  14.             try
  15.             {
  16.                 setBrightness(int.Parse(args[0]));
  17.             }
  18.             catch (Exception ex)
  19.             {
  20.                 Console.WriteLine("Please enter a number between 1 and 100");
  21.             }
  22.  
  23.         }
  24.  
  25.         private static void setBrightness(int brightnessLevel)
  26.         {
  27.             try
  28.             {
  29.                 ManagementScope s = new ManagementScope("root\\WMI");
  30.  
  31.                 SelectQuery q = new SelectQuery("WmiMonitorBrightnessMethods");
  32.  
  33.                 ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(s, q);
  34.  
  35.                 ManagementObjectCollection moc = mos.Get();
  36.  
  37.                 foreach (System.Management.ManagementObject o in moc)
  38.                 {
  39.                     o.InvokeMethod("WmiSetBrightness", new object[] {
  40.                                         UInt32.MaxValue,
  41.                                         brightnessLevel
  42.                                 });
  43.  
  44.                 }
  45.  
  46.                 moc.Dispose();
  47.                 mos.Dispose();
  48.             }
  49.             catch (Exception ex)
  50.             {
  51.                 Console.WriteLine(ex.ToString());
  52.             }
  53.         }
  54.     }
  55. }
clone this paste RAW Paste Data