Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RappelBerryPi committed Feb 3, 2022
1 parent fb796ac commit 8af73d3
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.vs/
TurnBrightnessDown/bin
TurnBrightnessDown/obj
TurnBrightnessUp/bin
TurnBrightnessUp/obj
SetBrightnessLibrary/bin
SetBrightnessLibrary/obj
packages/
37 changes: 37 additions & 0 deletions SetBrightness.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetBrightnessLibrary", "SetBrightnessLibrary\SetBrightnessLibrary.csproj", "{248ADAA7-E2A0-41A5-87BD-37408680042F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TurnBrightnessUp", "TurnBrightnessUp\TurnBrightnessUp.csproj", "{99C0D1BB-104D-443B-87ED-F4234D77AEBD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TurnBrightnessDown", "TurnBrightnessDown\TurnBrightnessDown.csproj", "{8A524A3C-CBCF-40DC-9ECD-F8E4316F22B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{248ADAA7-E2A0-41A5-87BD-37408680042F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{248ADAA7-E2A0-41A5-87BD-37408680042F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{248ADAA7-E2A0-41A5-87BD-37408680042F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{248ADAA7-E2A0-41A5-87BD-37408680042F}.Release|Any CPU.Build.0 = Release|Any CPU
{99C0D1BB-104D-443B-87ED-F4234D77AEBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99C0D1BB-104D-443B-87ED-F4234D77AEBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99C0D1BB-104D-443B-87ED-F4234D77AEBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99C0D1BB-104D-443B-87ED-F4234D77AEBD}.Release|Any CPU.Build.0 = Release|Any CPU
{8A524A3C-CBCF-40DC-9ECD-F8E4316F22B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A524A3C-CBCF-40DC-9ECD-F8E4316F22B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A524A3C-CBCF-40DC-9ECD-F8E4316F22B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A524A3C-CBCF-40DC-9ECD-F8E4316F22B6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2871CBA-CE4E-45C2-AAAD-1E8DB534C844}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions SetBrightnessLibrary/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SetBrightnessLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SetBrightnessLibrary")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("248adaa7-e2a0-41a5-87bd-37408680042f")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
24 changes: 24 additions & 0 deletions SetBrightnessLibrary/ScreenBrightness.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Management;

namespace SetBrightnessLibrary {
public class ScreenBrightness {
public int GetBrightness() {
var searcher = new ManagementObjectSearcher("root\\wmi", "select * from WmiMonitorBrightness");
var results = searcher.Get();
var enumerator = results.GetEnumerator();
enumerator.MoveNext();
var brightness = (byte)enumerator.Current["CurrentBrightness"];
return Convert.ToInt32(brightness);
}

public void SetBrightness(int brightness) {
var searcher = new ManagementObjectSearcher("root\\wmi", "select * from WmiMonitorBrightnessMethods");
var results = searcher.Get();
var enumerator = results.GetEnumerator();
enumerator.MoveNext();
var current = (ManagementObject)enumerator.Current;
current.InvokeMethod("WmiSetBrightness", new object[] { (uint)1, brightness });
}
}
}
59 changes: 59 additions & 0 deletions SetBrightnessLibrary/SetBrightnessLibrary.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{248ADAA7-E2A0-41A5-87BD-37408680042F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SetBrightnessLibrary</RootNamespace>
<AssemblyName>SetBrightnessLibrary</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WMI\v1.0\Microsoft.Management.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.CodeDom, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.CodeDom.6.0.0\lib\net461\System.CodeDom.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ScreenBrightness.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
6 changes: 6 additions & 0 deletions SetBrightnessLibrary/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.1.0" targetFramework="net472" />
<package id="System.CodeDom" version="6.0.0" targetFramework="net472" />
<package id="System.Management" version="6.0.0" targetFramework="net472" />
</packages>
6 changes: 6 additions & 0 deletions TurnBrightnessDown/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
21 changes: 21 additions & 0 deletions TurnBrightnessDown/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using SetBrightnessLibrary;

namespace TurnBrightnessDown {
internal class Program {
private static void Main(string[] args) {
var brightness = 10;
if (args.Length == 1) {
brightness = int.Parse(args[0]);
}

var screenBrightness = new ScreenBrightness();
var currentBrightness = screenBrightness.GetBrightness();
currentBrightness -= brightness;
if (currentBrightness < 0) {
currentBrightness = 0;
}

screenBrightness.SetBrightness(currentBrightness);
}
}
}
51 changes: 51 additions & 0 deletions TurnBrightnessDown/TurnBrightnessDown.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8A524A3C-CBCF-40DC-9ECD-F8E4316F22B6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TurnBrightnessDown</RootNamespace>
<AssemblyName>TurnBrightnessDown</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SetBrightnessLibrary\SetBrightnessLibrary.csproj">
<Project>{248ADAA7-E2A0-41A5-87BD-37408680042F}</Project>
<Name>SetBrightnessLibrary</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
6 changes: 6 additions & 0 deletions TurnBrightnessUp/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
21 changes: 21 additions & 0 deletions TurnBrightnessUp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using SetBrightnessLibrary;

namespace TurnBrightnessUp {
internal class Program {
private static void Main(string[] args) {
var brightness = 10;
if (args.Length == 1) {
brightness = int.Parse(args[0]);
}

var screenBrightness = new ScreenBrightness();
var currentBrightness = screenBrightness.GetBrightness();
currentBrightness += brightness;
if (currentBrightness > 100) {
currentBrightness = 100;
}

screenBrightness.SetBrightness(currentBrightness);
}
}
}
51 changes: 51 additions & 0 deletions TurnBrightnessUp/TurnBrightnessUp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{99C0D1BB-104D-443B-87ED-F4234D77AEBD}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TurnBrightnessUp</RootNamespace>
<AssemblyName>TurnBrightnessUp</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SetBrightnessLibrary\SetBrightnessLibrary.csproj">
<Project>{248ADAA7-E2A0-41A5-87BD-37408680042F}</Project>
<Name>SetBrightnessLibrary</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 8af73d3

Please sign in to comment.