Skip to content

Commit 3aa4ed1

Browse files
committed
Added ColourAtCursor 1.0.
Path fixes for release builds.
1 parent 16445f6 commit 3aa4ed1

20 files changed

+3896
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,4 @@ ASALocalRun/
328328

329329
# MFractors (Xamarin productivity tool) working folder
330330
.mfractor/
331+
/GetDown

Bitness/Bitness.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PlatformTarget>AnyCPU</PlatformTarget>
2828
<DebugType>pdbonly</DebugType>
2929
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
30+
<OutputPath>..\bin\Release\Bitness\</OutputPath>
3131
<DefineConstants>TRACE</DefineConstants>
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
179 KB
Binary file not shown.

ColourAtCursor/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E8CD9920-B363-488B-B70A-F2ECF3C3AB3A}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ColourAtCursor</RootNamespace>
11+
<AssemblyName>ColourAtCursor</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>..\bin\Release\ColourAtCursor\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup>
36+
<ApplicationIcon>Alex-T-Splash-Of-Fruit-Button-orange.ico</ApplicationIcon>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Data.DataSetExtensions" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Deployment" />
46+
<Reference Include="System.Drawing" />
47+
<Reference Include="System.Net.Http" />
48+
<Reference Include="System.Windows.Forms" />
49+
<Reference Include="System.Xml" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<Compile Include="KeyboardHook.cs" />
53+
<Compile Include="MainDisplay.cs">
54+
<SubType>Form</SubType>
55+
</Compile>
56+
<Compile Include="MainDisplay.Designer.cs">
57+
<DependentUpon>MainDisplay.cs</DependentUpon>
58+
</Compile>
59+
<Compile Include="Program.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<EmbeddedResource Include="MainDisplay.resx">
62+
<DependentUpon>MainDisplay.cs</DependentUpon>
63+
</EmbeddedResource>
64+
<EmbeddedResource Include="Properties\Resources.resx">
65+
<Generator>ResXFileCodeGenerator</Generator>
66+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
67+
<SubType>Designer</SubType>
68+
</EmbeddedResource>
69+
<Compile Include="Properties\Resources.Designer.cs">
70+
<AutoGen>True</AutoGen>
71+
<DependentUpon>Resources.resx</DependentUpon>
72+
</Compile>
73+
<None Include="Properties\Settings.settings">
74+
<Generator>SettingsSingleFileGenerator</Generator>
75+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
76+
</None>
77+
<Compile Include="Properties\Settings.Designer.cs">
78+
<AutoGen>True</AutoGen>
79+
<DependentUpon>Settings.settings</DependentUpon>
80+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
81+
</Compile>
82+
</ItemGroup>
83+
<ItemGroup>
84+
<None Include="App.config" />
85+
</ItemGroup>
86+
<ItemGroup>
87+
<Content Include="Alex-T-Splash-Of-Fruit-Button-orange.ico" />
88+
</ItemGroup>
89+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
90+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
91+
Other similar extension points exist, see Microsoft.Common.targets.
92+
<Target Name="BeforeBuild">
93+
</Target>
94+
<Target Name="AfterBuild">
95+
</Target>
96+
-->
97+
</Project>

ColourAtCursor/KeyboardHook.cs

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.InteropServices;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Forms;
8+
9+
namespace ColourAtCursor
10+
{
11+
/// <summary>
12+
/// Source : https://stackoverflow.com/a/27309185/6614025
13+
/// </summary>
14+
public sealed class KeyboardHook : IDisposable
15+
{
16+
// Registers a hot key with Windows.
17+
[DllImport("user32.dll")]
18+
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
19+
// Unregisters the hot key with Windows.
20+
[DllImport("user32.dll")]
21+
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
22+
23+
/// <summary>
24+
/// Represents the window that is used internally to get the messages.
25+
/// </summary>
26+
private class Window : NativeWindow, IDisposable
27+
{
28+
private static int WM_HOTKEY = 0x0312;
29+
30+
public Window()
31+
{
32+
// create the handle for the window.
33+
this.CreateHandle(new CreateParams());
34+
}
35+
36+
/// <summary>
37+
/// Overridden to get the notifications.
38+
/// </summary>
39+
/// <param name="m"></param>
40+
protected override void WndProc(ref Message m)
41+
{
42+
base.WndProc(ref m);
43+
44+
// check if we got a hot key pressed.
45+
if (m.Msg == WM_HOTKEY)
46+
{
47+
// get the keys.
48+
Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
49+
ModifierKeys modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);
50+
51+
// invoke the event to notify the parent.
52+
if (KeyPressed != null)
53+
KeyPressed(this, new KeyPressedEventArgs(modifier, key));
54+
}
55+
}
56+
57+
public event EventHandler<KeyPressedEventArgs> KeyPressed;
58+
59+
#region IDisposable Members
60+
61+
public void Dispose()
62+
{
63+
this.DestroyHandle();
64+
}
65+
66+
#endregion
67+
}
68+
69+
private Window _window = new Window();
70+
private int _currentId;
71+
72+
public KeyboardHook()
73+
{
74+
// register the event of the inner native window.
75+
_window.KeyPressed += delegate (object sender, KeyPressedEventArgs args)
76+
{
77+
if (KeyPressed != null)
78+
KeyPressed(this, args);
79+
};
80+
}
81+
82+
/// <summary>
83+
/// Registers a hot key in the system.
84+
/// </summary>
85+
/// <param name="modifier">The modifiers that are associated with the hot key.</param>
86+
/// <param name="key">The key itself that is associated with the hot key.</param>
87+
public void RegisterHotKey(ModifierKeys modifier, Keys key)
88+
{
89+
// increment the counter.
90+
_currentId = _currentId + 1;
91+
92+
// register the hot key.
93+
if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
94+
throw new InvalidOperationException("Couldn’t register the hot key.");
95+
}
96+
97+
/// <summary>
98+
/// A hot key has been pressed.
99+
/// </summary>
100+
public event EventHandler<KeyPressedEventArgs> KeyPressed;
101+
102+
#region IDisposable Members
103+
104+
public void Dispose()
105+
{
106+
// unregister all the registered hot keys.
107+
for (int i = _currentId; i > 0; i--)
108+
{
109+
UnregisterHotKey(_window.Handle, i);
110+
}
111+
112+
// dispose the inner native window.
113+
_window.Dispose();
114+
}
115+
116+
#endregion
117+
}
118+
119+
/// <summary>
120+
/// Event Args for the event that is fired after the hot key has been pressed.
121+
/// </summary>
122+
public class KeyPressedEventArgs : EventArgs
123+
{
124+
private ModifierKeys _modifier;
125+
private Keys _key;
126+
127+
internal KeyPressedEventArgs(ModifierKeys modifier, Keys key)
128+
{
129+
_modifier = modifier;
130+
_key = key;
131+
}
132+
133+
public ModifierKeys Modifier
134+
{
135+
get { return _modifier; }
136+
}
137+
138+
public Keys Key
139+
{
140+
get { return _key; }
141+
}
142+
}
143+
144+
/// <summary>
145+
/// The enumeration of possible modifiers.
146+
/// </summary>
147+
[Flags]
148+
public enum ModifierKeys : uint
149+
{
150+
Alt = 1,
151+
Control = 2,
152+
Shift = 4,
153+
Win = 8
154+
}
155+
}

ColourAtCursor/MainDisplay.Designer.cs

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)