An update
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<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')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>DD2Switcher</RootNamespace>
|
<RootNamespace>DD2Switcher</RootNamespace>
|
||||||
<AssemblyName>DD2Switcher</AssemblyName>
|
<AssemblyName>DD2Switcher</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -23,28 +23,30 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32bit>false</Prefer32bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32bit>false</Prefer32bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System"/>
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core"/>
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq"/>
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions"/>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp"/>
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data"/>
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment"/>
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing"/>
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http"/>
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms"/>
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
@@ -53,10 +55,10 @@
|
|||||||
<Compile Include="Form1.Designer.cs">
|
<Compile Include="Form1.Designer.cs">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="HotKeyManager.cs" />
|
<Compile Include="HotKeyManager.cs"/>
|
||||||
<Compile Include="Pixel.cs" />
|
<Compile Include="Pixel.cs"/>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs"/>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
@@ -77,7 +79,10 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<ItemGroup>
|
||||||
|
<Content Include="beep.wav"/>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
||||||
</Project>
|
</Project>
|
@@ -1,12 +1,9 @@
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace DD2Switcher
|
namespace DD2Switcher;
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form {
|
||||||
{
|
public Form1() {
|
||||||
public Form1()
|
InitializeComponent();
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,104 +3,103 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace DD2Switcher {
|
namespace DD2Switcher;
|
||||||
public static class HotKeyManager {
|
|
||||||
private static volatile MessageWindow _wnd;
|
|
||||||
private static volatile IntPtr _hwnd;
|
|
||||||
private static readonly ManualResetEvent _windowReadyEvent = new ManualResetEvent(false);
|
|
||||||
|
|
||||||
private static int _id;
|
public static class HotKeyManager {
|
||||||
|
private static volatile MessageWindow _wnd;
|
||||||
|
private static volatile IntPtr _hwnd;
|
||||||
|
private static readonly ManualResetEvent _windowReadyEvent = new(false);
|
||||||
|
|
||||||
static HotKeyManager() {
|
private static int _id;
|
||||||
var messageLoop = new Thread(delegate() { Application.Run(new MessageWindow()); });
|
|
||||||
messageLoop.Name = "MessageLoopThread";
|
|
||||||
messageLoop.IsBackground = true;
|
|
||||||
messageLoop.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static event EventHandler<HotKeyEventArgs> HotKeyPressed;
|
static HotKeyManager() {
|
||||||
|
var messageLoop = new Thread(delegate() { Application.Run(new MessageWindow()); });
|
||||||
public static int RegisterHotKey(Keys key, KeyModifiers modifiers) {
|
messageLoop.Name = "MessageLoopThread";
|
||||||
_windowReadyEvent.WaitOne();
|
messageLoop.IsBackground = true;
|
||||||
var id = Interlocked.Increment(ref _id);
|
messageLoop.Start();
|
||||||
_wnd.Invoke(new RegisterHotKeyDelegate(RegisterHotKeyInternal), _hwnd, id, (uint)modifiers, (uint)key);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UnregisterHotKey(int id) {
|
|
||||||
_wnd.Invoke(new UnRegisterHotKeyDelegate(UnRegisterHotKeyInternal), _hwnd, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RegisterHotKeyInternal(IntPtr hwnd, int id, uint modifiers, uint key) {
|
|
||||||
RegisterHotKey(hwnd, id, modifiers, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void UnRegisterHotKeyInternal(IntPtr hwnd, int id) {
|
|
||||||
UnregisterHotKey(_hwnd, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnHotKeyPressed(HotKeyEventArgs e) {
|
|
||||||
if (HotKeyPressed != null) HotKeyPressed(null, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32", SetLastError = true)]
|
|
||||||
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
|
|
||||||
|
|
||||||
[DllImport("user32", SetLastError = true)]
|
|
||||||
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
|
||||||
|
|
||||||
private delegate void RegisterHotKeyDelegate(IntPtr hwnd, int id, uint modifiers, uint key);
|
|
||||||
|
|
||||||
private delegate void UnRegisterHotKeyDelegate(IntPtr hwnd, int id);
|
|
||||||
|
|
||||||
private class MessageWindow : Form {
|
|
||||||
private const int WM_HOTKEY = 0x312;
|
|
||||||
|
|
||||||
public MessageWindow() {
|
|
||||||
_wnd = this;
|
|
||||||
_hwnd = Handle;
|
|
||||||
_windowReadyEvent.Set();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m) {
|
|
||||||
if (m.Msg == WM_HOTKEY) {
|
|
||||||
var e = new HotKeyEventArgs(m.LParam);
|
|
||||||
OnHotKeyPressed(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.WndProc(ref m);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetVisibleCore(bool value) {
|
|
||||||
// Ensure the window never becomes visible
|
|
||||||
base.SetVisibleCore(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static event EventHandler<HotKeyEventArgs> HotKeyPressed;
|
||||||
|
|
||||||
public class HotKeyEventArgs : EventArgs {
|
public static int RegisterHotKey(Keys key, KeyModifiers modifiers) {
|
||||||
public readonly Keys Key;
|
_windowReadyEvent.WaitOne();
|
||||||
public readonly KeyModifiers Modifiers;
|
var id = Interlocked.Increment(ref _id);
|
||||||
|
_wnd.Invoke(new RegisterHotKeyDelegate(RegisterHotKeyInternal), _hwnd, id, (uint)modifiers, (uint)key);
|
||||||
public HotKeyEventArgs(Keys key, KeyModifiers modifiers) {
|
return id;
|
||||||
Key = key;
|
|
||||||
Modifiers = modifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HotKeyEventArgs(IntPtr hotKeyParam) {
|
|
||||||
var param = (uint)hotKeyParam.ToInt64();
|
|
||||||
Key = (Keys)((param & 0xffff0000) >> 16);
|
|
||||||
Modifiers = (KeyModifiers)(param & 0x0000ffff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
public static void UnregisterHotKey(int id) {
|
||||||
public enum KeyModifiers {
|
_wnd.Invoke(new UnRegisterHotKeyDelegate(UnRegisterHotKeyInternal), _hwnd, id);
|
||||||
Alt = 1,
|
}
|
||||||
Control = 2,
|
|
||||||
Shift = 4,
|
private static void RegisterHotKeyInternal(IntPtr hwnd, int id, uint modifiers, uint key) {
|
||||||
Windows = 8,
|
RegisterHotKey(hwnd, id, modifiers, key);
|
||||||
NoRepeat = 0x4000
|
}
|
||||||
|
|
||||||
|
private static void UnRegisterHotKeyInternal(IntPtr hwnd, int id) {
|
||||||
|
UnregisterHotKey(_hwnd, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnHotKeyPressed(HotKeyEventArgs e) {
|
||||||
|
if (HotKeyPressed != null) HotKeyPressed(null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32", SetLastError = true)]
|
||||||
|
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
|
||||||
|
|
||||||
|
[DllImport("user32", SetLastError = true)]
|
||||||
|
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||||
|
|
||||||
|
private delegate void RegisterHotKeyDelegate(IntPtr hwnd, int id, uint modifiers, uint key);
|
||||||
|
|
||||||
|
private delegate void UnRegisterHotKeyDelegate(IntPtr hwnd, int id);
|
||||||
|
|
||||||
|
private class MessageWindow : Form {
|
||||||
|
private const int WM_HOTKEY = 0x312;
|
||||||
|
|
||||||
|
public MessageWindow() {
|
||||||
|
_wnd = this;
|
||||||
|
_hwnd = Handle;
|
||||||
|
_windowReadyEvent.Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void WndProc(ref Message m) {
|
||||||
|
if (m.Msg == WM_HOTKEY) {
|
||||||
|
var e = new HotKeyEventArgs(m.LParam);
|
||||||
|
OnHotKeyPressed(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.WndProc(ref m);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SetVisibleCore(bool value) {
|
||||||
|
// Ensure the window never becomes visible
|
||||||
|
base.SetVisibleCore(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class HotKeyEventArgs : EventArgs {
|
||||||
|
public readonly Keys Key;
|
||||||
|
public readonly KeyModifiers Modifiers;
|
||||||
|
|
||||||
|
public HotKeyEventArgs(Keys key, KeyModifiers modifiers) {
|
||||||
|
Key = key;
|
||||||
|
Modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HotKeyEventArgs(IntPtr hotKeyParam) {
|
||||||
|
var param = (uint)hotKeyParam.ToInt64();
|
||||||
|
Key = (Keys)((param & 0xffff0000) >> 16);
|
||||||
|
Modifiers = (KeyModifiers)(param & 0x0000ffff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum KeyModifiers {
|
||||||
|
Alt = 1,
|
||||||
|
Control = 2,
|
||||||
|
Shift = 4,
|
||||||
|
Windows = 8,
|
||||||
|
NoRepeat = 0x4000
|
||||||
|
}
|
@@ -1,15 +1,9 @@
|
|||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace DD2Switcher;
|
namespace DD2Switcher;
|
||||||
|
|
||||||
public class Pixel {
|
public class Pixel {
|
||||||
private int x { get; set; }
|
|
||||||
private int y { get; set; }
|
|
||||||
private int R { get; set; }
|
|
||||||
private int G { get; set; }
|
|
||||||
private int B { get; set; }
|
|
||||||
|
|
||||||
public Pixel(int x, int y, int R, int G, int B) {
|
public Pixel(int x, int y, int R, int G, int B) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -18,8 +12,14 @@ public class Pixel {
|
|||||||
this.B = B;
|
this.B = B;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean ProcessBitmap(Bitmap bmp) {
|
private int x { get; }
|
||||||
Color tempPixel = bmp.GetPixel(x, y);
|
private int y { get; }
|
||||||
return tempPixel.R == R && tempPixel.B == B && tempPixel.G == G;
|
private int R { get; }
|
||||||
|
private int G { get; }
|
||||||
|
private int B { get; }
|
||||||
|
|
||||||
|
public bool ProcessBitmap(Bitmap bmp) {
|
||||||
|
var tempPixel = bmp.GetPixel(x, y);
|
||||||
|
return tempPixel.R >= R && tempPixel.B >= B && tempPixel.G >= G;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Media;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@@ -9,14 +10,22 @@ using System.Windows.Forms;
|
|||||||
namespace DD2Switcher;
|
namespace DD2Switcher;
|
||||||
|
|
||||||
internal static class Program {
|
internal static class Program {
|
||||||
private static Rectangle rect = new(0, 0, 1920, 1080);
|
private static Rectangle rect = new(0, 0, 2560, 1440);
|
||||||
private static readonly Process[] games = Process.GetProcessesByName("Dundefgame");
|
private static readonly Process[] games = Process.GetProcessesByName("Dundefgame");
|
||||||
|
|
||||||
|
private static readonly SoundPlayer beeper =
|
||||||
|
new(@"C:\Users\Administrator\RiderProjects\DD2Switcher\DD2Switcher\beep.wav");
|
||||||
|
|
||||||
private static Process activeGame = games[0];
|
private static Process activeGame = games[0];
|
||||||
private static Bitmap screenshot;
|
private static Bitmap screenshot;
|
||||||
private static Graphics graphics;
|
private static Graphics graphics;
|
||||||
private static readonly int defaultAffinity = 0b100000000000;
|
private static readonly IntPtr defaultAffinity = new(0xFF000000);
|
||||||
|
private static readonly IntPtr fullAffinity = new(0xFFFFFFFF);
|
||||||
private static bool paused = true;
|
private static bool paused = true;
|
||||||
|
|
||||||
|
private static List<Point> relevantPoints = new List<Point>();
|
||||||
|
private static List<Point> pointsToRemove = new List<Point>();
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
|
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
|
||||||
|
|
||||||
@@ -47,18 +56,10 @@ internal static class Program {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void AdjustAffinities() {
|
private static void AdjustAffinities() {
|
||||||
var fullAffinity = 0b111111111111;
|
|
||||||
var i = 0;
|
|
||||||
foreach (var game in games)
|
foreach (var game in games)
|
||||||
if (game != activeGame) {
|
if (game != activeGame)
|
||||||
// var processAffinty = defaultAffinity >> i;
|
game.ProcessorAffinity = defaultAffinity;
|
||||||
var processAffinty = defaultAffinity;
|
activeGame.ProcessorAffinity = fullAffinity;
|
||||||
fullAffinity = fullAffinity & ~processAffinty;
|
|
||||||
game.ProcessorAffinity = new IntPtr(processAffinty);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
activeGame.ProcessorAffinity = new IntPtr(fullAffinity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AdjustPriorities() {
|
private static void AdjustPriorities() {
|
||||||
@@ -67,11 +68,16 @@ internal static class Program {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void NerfAll() {
|
private static void NerfAll() {
|
||||||
var i = 0;
|
|
||||||
foreach (var game in games) {
|
foreach (var game in games) {
|
||||||
game.ProcessorAffinity = new IntPtr(defaultAffinity);
|
game.ProcessorAffinity = defaultAffinity;
|
||||||
game.PriorityClass = ProcessPriorityClass.Idle;
|
game.PriorityClass = ProcessPriorityClass.Idle;
|
||||||
i++;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void BuffAll() {
|
||||||
|
foreach (var game in games) {
|
||||||
|
game.ProcessorAffinity = fullAffinity;
|
||||||
|
game.PriorityClass = ProcessPriorityClass.Normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +112,13 @@ internal static class Program {
|
|||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main() {
|
private static void Main() {
|
||||||
|
var processes = Process.GetProcesses();
|
||||||
|
var currentProcess = Process.GetCurrentProcess();
|
||||||
|
|
||||||
|
foreach (var process in processes)
|
||||||
|
if (process.Id != currentProcess.Id && process.ProcessName == currentProcess.ProcessName)
|
||||||
|
process.Kill();
|
||||||
|
|
||||||
HotKeyManager.RegisterHotKey(Keys.D1, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.D1, KeyModifiers.Alt);
|
||||||
HotKeyManager.RegisterHotKey(Keys.D2, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.D2, KeyModifiers.Alt);
|
||||||
HotKeyManager.RegisterHotKey(Keys.D3, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.D3, KeyModifiers.Alt);
|
||||||
@@ -114,11 +127,12 @@ internal static class Program {
|
|||||||
HotKeyManager.RegisterHotKey(Keys.D6, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.D6, KeyModifiers.Alt);
|
||||||
HotKeyManager.RegisterHotKey(Keys.Q, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.Q, KeyModifiers.Alt);
|
||||||
HotKeyManager.RegisterHotKey(Keys.W, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.W, KeyModifiers.Alt);
|
||||||
|
HotKeyManager.RegisterHotKey(Keys.R, KeyModifiers.Alt);
|
||||||
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
|
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
|
||||||
|
|
||||||
List<Pixel> pixelList = new List<Pixel>();
|
var pixelList = new System.Collections.Generic.List<Pixel>();
|
||||||
pixelList.Add(new Pixel(108, 108, 0, 0, 0));
|
// pixelList.Add(new Pixel(1401, 1234, 224, 224, 224));
|
||||||
pixelList.Add(new Pixel(1062, 885, 255, 255, 255));
|
pixelList.Add(new Pixel(1359, 1235, 220, 220, 220));
|
||||||
|
|
||||||
static void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) {
|
static void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) {
|
||||||
switch (e.Key) {
|
switch (e.Key) {
|
||||||
@@ -140,15 +154,15 @@ internal static class Program {
|
|||||||
case Keys.D6:
|
case Keys.D6:
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
break;
|
break;
|
||||||
case Keys.Q:
|
|
||||||
NerfAll();
|
|
||||||
break;
|
|
||||||
case Keys.W:
|
case Keys.W:
|
||||||
if (paused) {
|
if (paused) {
|
||||||
Console.Beep(1500, 500);
|
beeper.Play();
|
||||||
paused = false;
|
paused = false;
|
||||||
} else {
|
}
|
||||||
Console.Beep(500, 500);
|
else {
|
||||||
|
beeper.Play();
|
||||||
|
Thread.Sleep(150);
|
||||||
|
beeper.Play();
|
||||||
paused = true;
|
paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,16 +171,51 @@ internal static class Program {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
bool runOnce = false;
|
||||||
|
bool AAA = false;
|
||||||
|
relevantPoints.Clear();
|
||||||
while (!paused) {
|
while (!paused) {
|
||||||
screenshot = CaptureWindow(games[0].MainWindowHandle);
|
screenshot = CaptureWindow(games[0].MainWindowHandle);
|
||||||
foreach (Pixel p in pixelList) {
|
// screenshot.Save("SS.png");
|
||||||
|
|
||||||
|
// if (!runOnce) {
|
||||||
|
// runOnce = true;
|
||||||
|
// for (var y = 0; y < screenshot.Height; y++)
|
||||||
|
// for (var x = 0; x < screenshot.Width; x++) {
|
||||||
|
// var pixelColor = screenshot.GetPixel(x, y);
|
||||||
|
// if (pixelColor.R > 220 && pixelColor.G > 220 && pixelColor.B > 220)
|
||||||
|
// relevantPoints.Add(new Point(x, y));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// pointsToRemove.Clear();
|
||||||
|
// foreach (var relevantPoint in relevantPoints) {
|
||||||
|
// var pixel = screenshot.GetPixel(relevantPoint.X, relevantPoint.Y);
|
||||||
|
// if (!(pixel.R > 220) || !(pixel.G > 220) || !(pixel.B > 220))
|
||||||
|
// pointsToRemove.Add(relevantPoint);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach (var point in pointsToRemove) {
|
||||||
|
// relevantPoints.Remove(point);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Debug.WriteLine(relevantPoints.Count);
|
||||||
|
|
||||||
|
foreach (var p in pixelList)
|
||||||
if (p.ProcessBitmap(screenshot)) {
|
if (p.ProcessBitmap(screenshot)) {
|
||||||
Console.Beep(1500, 850);
|
beeper.Play();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Thread.Sleep(250);
|
Thread.Sleep(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System.IO.TextWriter tw = new System.IO.StreamWriter("SavedList.txt");
|
||||||
|
// foreach (var point in relevantPoints) {
|
||||||
|
// tw.WriteLine(point.ToString());
|
||||||
|
// }
|
||||||
|
// tw.Close();
|
||||||
|
|
||||||
Thread.Sleep(250);
|
Thread.Sleep(250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
DD2Switcher/beep.wav
Normal file
BIN
DD2Switcher/beep.wav
Normal file
Binary file not shown.
@@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
Reference in New Issue
Block a user