CC-Functions.W32

This commit is contained in:
CreepyCrafter24 2020-03-11 18:53:32 +01:00
parent 2873d9cbeb
commit 2c04098405
9 changed files with 112 additions and 275 deletions

View File

@ -1,109 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<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> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>netcoreapp3.0</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{61B4565A-608D-4107-8656-3B24F5C61997}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>CC_Clicker_2._0</RootNamespace> <RootNamespace>CC_Clicker_2._0</RootNamespace>
<AssemblyName>CC-Clicker 2.0</AssemblyName> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <UseWindowsForms>true</UseWindowsForms>
<FileAlignment>512</FileAlignment> <Deterministic>false</Deterministic>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup>
<PlatformTarget>AnyCPU</PlatformTarget> <PostBuildEvent>if exist "$(SolutionDir)Data\pkgtool.exe" ($(SolutionDir)Data\pkgtool.exe build --noLogo --noShortcuts --binDir .) else if exist "%appdata%\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app\pkgtool.exe" ("%appdata%\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app\pkgtool.exe" build --noLogo --noShortcuts --binDir .) else echo Cound not find Package build tools, skipping</PostBuildEvent>
<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>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>C_64.ico</ApplicationIcon> <ApplicationIcon>C_64.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="LocForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LocForm.Designer.cs">
<DependentUpon>LocForm.cs</DependentUpon>
</Compile>
<Compile Include="OvPForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OvPForm.Designer.cs">
<DependentUpon>OvPForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="LocForm.resx">
<DependentUpon>LocForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="OvPForm.resx">
<DependentUpon>OvPForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="C_64.ico" /> <Content Include="C_64.ico" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ItemGroup>
<PackageReference Include="CC-Functions.W32" Version="1.0.7" />
</ItemGroup>
</Project> </Project>

View File

@ -32,10 +32,10 @@
// //
// LocForm // LocForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(933, 519);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "LocForm"; this.Name = "LocForm";
this.Opacity = 0.5D; this.Opacity = 0.5D;
@ -46,7 +46,6 @@
this.Load += new System.EventHandler(this.LocForm_Load); this.Load += new System.EventHandler(this.LocForm_Load);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.LocForm_MouseClick); this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.LocForm_MouseClick);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion

View File

@ -1,40 +1,26 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using CC_Functions.W32;
namespace CC_Clicker_2._0 namespace CC_Clicker_2._0
{ {
public partial class LocForm : Form public partial class LocForm : Form
{ {
private bool _close;
public int X; public int X;
public int Y; public int Y;
public LocForm() => InitializeComponent(); public LocForm() => InitializeComponent();
bool close; private void LocForm_FormClosing(object sender, FormClosingEventArgs e) => e.Cancel = !_close;
private void LocForm_FormClosing(object sender, FormClosingEventArgs e) => e.Cancel = !close;
private void LocForm_MouseClick(object sender, MouseEventArgs e) private void LocForm_MouseClick(object sender, MouseEventArgs e)
{ {
X = Cursor.Position.X; X = Cursor.Position.X;
Y = Cursor.Position.Y; Y = Cursor.Position.Y;
close = true; _close = true;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); private void LocForm_Load(object sender, EventArgs e) => this.GetWnd32().Overlay = true;
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOMOVE = 0x0002;
const uint TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private void LocForm_Load(object sender, EventArgs e) => SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
} }
} }

View File

@ -16,7 +16,7 @@
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
ov.Dispose(); _ov.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
@ -30,7 +30,8 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); System.ComponentModel.ComponentResourceManager resources =
new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.clickBox = new System.Windows.Forms.CheckBox(); this.clickBox = new System.Windows.Forms.CheckBox();
this.rightBox = new System.Windows.Forms.CheckBox(); this.rightBox = new System.Windows.Forms.CheckBox();
this.timeBox = new System.Windows.Forms.TextBox(); this.timeBox = new System.Windows.Forms.TextBox();
@ -47,9 +48,9 @@
// //
this.clickBox.AutoSize = true; this.clickBox.AutoSize = true;
this.clickBox.Enabled = false; this.clickBox.Enabled = false;
this.clickBox.Location = new System.Drawing.Point(12, 14); this.clickBox.Location = new System.Drawing.Point(14, 16);
this.clickBox.Name = "clickBox"; this.clickBox.Name = "clickBox";
this.clickBox.Size = new System.Drawing.Size(49, 17); this.clickBox.Size = new System.Drawing.Size(52, 19);
this.clickBox.TabIndex = 0; this.clickBox.TabIndex = 0;
this.clickBox.Text = "Click"; this.clickBox.Text = "Click";
this.toolTip.SetToolTip(this.clickBox, "Check to start listening for the activation sequence"); this.toolTip.SetToolTip(this.clickBox, "Check to start listening for the activation sequence");
@ -59,9 +60,9 @@
// rightBox // rightBox
// //
this.rightBox.AutoSize = true; this.rightBox.AutoSize = true;
this.rightBox.Location = new System.Drawing.Point(12, 42); this.rightBox.Location = new System.Drawing.Point(14, 48);
this.rightBox.Name = "rightBox"; this.rightBox.Name = "rightBox";
this.rightBox.Size = new System.Drawing.Size(51, 17); this.rightBox.Size = new System.Drawing.Size(54, 19);
this.rightBox.TabIndex = 1; this.rightBox.TabIndex = 1;
this.rightBox.Text = "Right"; this.rightBox.Text = "Right";
this.toolTip.SetToolTip(this.rightBox, "Check to use right clicks instead of left clicks"); this.toolTip.SetToolTip(this.rightBox, "Check to use right clicks instead of left clicks");
@ -69,23 +70,28 @@
// //
// timeBox // timeBox
// //
this.timeBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.timeBox.Anchor =
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Right)));
this.timeBox.BackColor = System.Drawing.Color.White; this.timeBox.BackColor = System.Drawing.Color.White;
this.timeBox.Location = new System.Drawing.Point(101, 12); this.timeBox.Location = new System.Drawing.Point(118, 14);
this.timeBox.Name = "timeBox"; this.timeBox.Name = "timeBox";
this.timeBox.Size = new System.Drawing.Size(100, 20); this.timeBox.Size = new System.Drawing.Size(116, 23);
this.timeBox.TabIndex = 2; this.timeBox.TabIndex = 2;
this.timeBox.Text = "100"; this.timeBox.Text = "100";
this.toolTip.SetToolTip(this.timeBox, "Base delay between clicks in milliseconds. Must be an even number above 0"); this.toolTip.SetToolTip(this.timeBox,
"Base delay between clicks in milliseconds. Must be an even number above 0");
this.timeBox.TextChanged += new System.EventHandler(this.timeBox_TextChanged); this.timeBox.TextChanged += new System.EventHandler(this.timeBox_TextChanged);
// //
// keyButton // keyButton
// //
this.keyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.keyButton.Anchor =
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Right)));
this.keyButton.BackColor = System.Drawing.Color.Red; this.keyButton.BackColor = System.Drawing.Color.Red;
this.keyButton.Location = new System.Drawing.Point(101, 38); this.keyButton.Location = new System.Drawing.Point(118, 44);
this.keyButton.Name = "keyButton"; this.keyButton.Name = "keyButton";
this.keyButton.Size = new System.Drawing.Size(100, 23); this.keyButton.Size = new System.Drawing.Size(117, 27);
this.keyButton.TabIndex = 3; this.keyButton.TabIndex = 3;
this.keyButton.Text = "Click to set key"; this.keyButton.Text = "Click to set key";
this.toolTip.SetToolTip(this.keyButton, "Click and press a key to set it as the (de-)activation sequence"); this.toolTip.SetToolTip(this.keyButton, "Click and press a key to set it as the (de-)activation sequence");
@ -95,12 +101,13 @@
// delmBox // delmBox
// //
this.delmBox.AutoSize = true; this.delmBox.AutoSize = true;
this.delmBox.Location = new System.Drawing.Point(12, 69); this.delmBox.Location = new System.Drawing.Point(14, 80);
this.delmBox.Name = "delmBox"; this.delmBox.Name = "delmBox";
this.delmBox.Size = new System.Drawing.Size(69, 17); this.delmBox.Size = new System.Drawing.Size(75, 19);
this.delmBox.TabIndex = 4; this.delmBox.TabIndex = 4;
this.delmBox.Text = "DelayMix"; this.delmBox.Text = "DelayMix";
this.toolTip.SetToolTip(this.delmBox, "Check to generate more human clicks by waiting a random amount of time instead of" + this.toolTip.SetToolTip(this.delmBox,
"Check to generate more human clicks by waiting a random amount of time instead of" +
" a fixed amount"); " a fixed amount");
this.delmBox.UseVisualStyleBackColor = true; this.delmBox.UseVisualStyleBackColor = true;
// //
@ -111,9 +118,9 @@
// delmVal // delmVal
// //
this.delmVal.BackColor = System.Drawing.Color.White; this.delmVal.BackColor = System.Drawing.Color.White;
this.delmVal.Location = new System.Drawing.Point(101, 67); this.delmVal.Location = new System.Drawing.Point(118, 77);
this.delmVal.Name = "delmVal"; this.delmVal.Name = "delmVal";
this.delmVal.Size = new System.Drawing.Size(100, 20); this.delmVal.Size = new System.Drawing.Size(116, 23);
this.delmVal.TabIndex = 5; this.delmVal.TabIndex = 5;
this.delmVal.Text = "4"; this.delmVal.Text = "4";
this.toolTip.SetToolTip(this.delmVal, "Maximum Delay that will be randomly added by DelayMix"); this.toolTip.SetToolTip(this.delmVal, "Maximum Delay that will be randomly added by DelayMix");
@ -122,9 +129,9 @@
// fixBox // fixBox
// //
this.fixBox.AutoSize = true; this.fixBox.AutoSize = true;
this.fixBox.Location = new System.Drawing.Point(12, 97); this.fixBox.Location = new System.Drawing.Point(14, 112);
this.fixBox.Name = "fixBox"; this.fixBox.Name = "fixBox";
this.fixBox.Size = new System.Drawing.Size(79, 17); this.fixBox.Size = new System.Drawing.Size(87, 19);
this.fixBox.TabIndex = 6; this.fixBox.TabIndex = 6;
this.fixBox.Text = "Fix Position"; this.fixBox.Text = "Fix Position";
this.toolTip.SetToolTip(this.fixBox, "Check to use a fixed click position instead of the Cursors position"); this.toolTip.SetToolTip(this.fixBox, "Check to use a fixed click position instead of the Cursors position");
@ -133,9 +140,9 @@
// //
// fixButton // fixButton
// //
this.fixButton.Location = new System.Drawing.Point(101, 93); this.fixButton.Location = new System.Drawing.Point(118, 107);
this.fixButton.Name = "fixButton"; this.fixButton.Name = "fixButton";
this.fixButton.Size = new System.Drawing.Size(100, 23); this.fixButton.Size = new System.Drawing.Size(117, 27);
this.fixButton.TabIndex = 7; this.fixButton.TabIndex = 7;
this.fixButton.Text = "Set Position"; this.fixButton.Text = "Set Position";
this.toolTip.SetToolTip(this.fixButton, "Set the location where clicks will be simulated"); this.toolTip.SetToolTip(this.fixButton, "Set the location where clicks will be simulated");
@ -146,9 +153,9 @@
// //
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(213, 126); this.ClientSize = new System.Drawing.Size(260, 157);
this.Controls.Add(this.fixButton); this.Controls.Add(this.fixButton);
this.Controls.Add(this.fixBox); this.Controls.Add(this.fixBox);
this.Controls.Add(this.delmVal); this.Controls.Add(this.delmVal);
@ -160,14 +167,13 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(229, 165); this.MaximumSize = new System.Drawing.Size(266, 186);
this.MinimizeBox = false; this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(229, 165); this.MinimumSize = new System.Drawing.Size(266, 186);
this.Name = "MainForm"; this.Name = "MainForm";
this.Text = "CC-Clicker 2.0"; this.Text = "CC-Clicker 2.0";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
#endregion #endregion

View File

@ -1,52 +1,41 @@
using System; using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing; using System.Drawing;
using System.Threading; using System.Windows.Forms;
using CC_Functions.W32;
using CC_Functions.W32.Hooks;
#pragma warning disable IDE1006
namespace CC_Clicker_2._0 namespace CC_Clicker_2._0
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
Point loc = Point.Empty; private static bool _isSettingKey;
readonly OvPForm ov; private const Keys Key = Keys.LShiftKey;
public static Button _keyButton; private static bool _isClicking;
public static bool _isSettingKey = false; private static int _setDelay = 100;
public static Keys _key = Keys.LShiftKey; private static int _delmVal = 4;
public static bool _isClicking = false; private readonly OvPForm _ov;
public static int _setDelay = 100; private Point _loc = Point.Empty;
public static int _delmVal = 4;
public static CheckBox _clickBox; public MainForm(KeyboardHook hook)
public MainForm()
{ {
InitializeComponent(); InitializeComponent();
_keyButton = keyButton; Button keyButton1 = keyButton;
_clickBox = clickBox; _ov = new OvPForm(_loc.X, _loc.Y);
ov = new OvPForm(loc.X, loc.Y); hook.OnKeyPress += (e) =>
}
public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{ {
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
{
int vkCode = Marshal.ReadInt32(lParam);
if (_isSettingKey) if (_isSettingKey)
{ {
_key = (Keys)vkCode; keyButton1.BackColor = Color.FromArgb(224, 224, 224);
_keyButton.BackColor = Color.FromArgb(224, 224, 224); clickBox.Enabled = true;
_clickBox.Enabled = true; keyButton1.Text = e.Key.ToString();
_keyButton.Text = ((Keys)vkCode).ToString();
_isSettingKey = false; _isSettingKey = false;
} }
else else
{ {
if ((Keys)vkCode == _key) if (e.Key == Key)
_isClicking = !_isClicking; _isClicking = !_isClicking;
} }
} };
return CallNextHookEx(_hookID, nCode, wParam, lParam);
} }
private void clickBox_CheckedChanged(object sender, EventArgs e) private void clickBox_CheckedChanged(object sender, EventArgs e)
@ -90,74 +79,38 @@ namespace CC_Clicker_2._0
private void timer_Tick(object sender, EventArgs e) private void timer_Tick(object sender, EventArgs e)
{ {
if (_isClicking) if (!_isClicking) return;
{
if (fixBox.Checked) if (fixBox.Checked)
Cursor.Position = loc; Cursor.Position = _loc;
mouse_event((uint)(rightBox.Checked ? (MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP) : (MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP)), (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0); Mouse.Click(rightBox.Checked);
if (delmBox.Checked) if (delmBox.Checked)
timer.Interval = Math.Max(_setDelay + (new Random().Next(0, _delmVal) - (_delmVal / 2)), 1); timer.Interval = Math.Max(_setDelay + (new Random().Next(0, _delmVal) - (_delmVal / 2)), 1);
} }
}
private void fixButton_Click(object sender, EventArgs e) private void fixButton_Click(object sender, EventArgs e)
{ {
ov.Hide(); _ov.Hide();
using (LocForm frm = new LocForm()) using LocForm frm = new LocForm();
{ if (frm.ShowDialog() != DialogResult.OK) return;
if (frm.ShowDialog() == DialogResult.OK) _loc = new Point(frm.X, frm.Y);
{
loc = new Point(frm.X, frm.Y);
fixBox.Checked = true; fixBox.Checked = true;
fixButton.BackColor = Color.Green; fixButton.BackColor = Color.Green;
fixButton.Text = loc.ToString(); fixButton.Text = _loc.ToString();
}
}
} }
private void fixBox_CheckedChanged(object sender, EventArgs e) private void fixBox_CheckedChanged(object sender, EventArgs e)
{ {
if (loc == Point.Empty) if (_loc != Point.Empty) return;
{
fixBox.Checked = false; fixBox.Checked = false;
fixButton.BackColor = Color.Red; fixButton.BackColor = Color.Red;
} }
}
private void fixButton_MouseEnter(object sender, EventArgs e) private void fixButton_MouseEnter(object sender, EventArgs e)
{ {
ov.setPos(loc.X, loc.Y); _ov.SetPos(_loc.X, _loc.Y);
ov.Show(); _ov.Show();
} }
private void fixButton_MouseLeave(object sender, EventArgs e) => ov.Hide(); private void fixButton_MouseLeave(object sender, EventArgs e) => _ov.Hide();
#region DllImports
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern IntPtr GetModuleHandle(string lpModuleName);
public static IntPtr SetHook(LowLevelKeyboardProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
}
}
public delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
const int WH_KEYBOARD_LL = 13;
const int WM_KEYDOWN = 0x0100;
public static LowLevelKeyboardProc _proc = HookCallback;
public static IntPtr _hookID = IntPtr.Zero;
#endregion
} }
} }

View File

@ -32,18 +32,19 @@
// //
// OvPForm // OvPForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); this.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (192)))), ((int) (((byte) (192)))),
this.ClientSize = new System.Drawing.Size(30, 30); ((int) (((byte) (0)))));
this.ClientSize = new System.Drawing.Size(35, 35);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "OvPForm"; this.Name = "OvPForm";
this.Text = "OvPForm"; this.Text = "OvPForm";
this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); this.TransparencyKey = System.Drawing.Color.FromArgb(((int) (((byte) (192)))), ((int) (((byte) (192)))),
((int) (((byte) (0)))));
this.Load += new System.EventHandler(this.OvPForm_Load); this.Load += new System.EventHandler(this.OvPForm_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.OvPForm_Paint); this.Paint += new System.Windows.Forms.PaintEventHandler(this.OvPForm_Paint);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion

View File

@ -1,13 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using CC_Functions.W32;
namespace CC_Clicker_2._0 namespace CC_Clicker_2._0
{ {
@ -16,9 +10,10 @@ namespace CC_Clicker_2._0
public OvPForm(int x, int y) public OvPForm(int x, int y)
{ {
InitializeComponent(); InitializeComponent();
setPos(x, y); SetPos(x, y);
} }
public void setPos(int x, int y) => Location = new Point(x - (Width / 2), y - (Height / 2));
public void SetPos(int x, int y) => Location = new Point(x - (Width / 2), y - (Height / 2));
private void OvPForm_Paint(object sender, PaintEventArgs e) private void OvPForm_Paint(object sender, PaintEventArgs e)
{ {
@ -26,13 +21,6 @@ namespace CC_Clicker_2._0
e.Graphics.DrawLine(new Pen(Color.Black, 2), Width / 2, (Height / 2) - 15, Width / 2, (Height / 2) + 15); e.Graphics.DrawLine(new Pen(Color.Black, 2), Width / 2, (Height / 2) - 15, Width / 2, (Height / 2) + 15);
} }
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); private void OvPForm_Load(object sender, EventArgs e) => this.GetWnd32().Overlay = true;
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOMOVE = 0x0002;
const uint TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private void OvPForm_Load(object sender, EventArgs e) => SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
} }
} }

View File

@ -1,26 +1,18 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using CC_Functions.W32.Hooks;
namespace CC_Clicker_2._0 namespace CC_Clicker_2._0
{ {
static class Program internal static class Program
{ {
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool UnhookWindowsHookEx(IntPtr hhk);
[STAThread] [STAThread]
static void Main() private static void Main()
{ {
using KeyboardHook hook = new KeyboardHook();
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
MainForm._hookID = MainForm.SetHook(MainForm._proc); Application.Run(new MainForm(hook));
Application.Run(new MainForm());
UnhookWindowsHookEx(MainForm._hookID);
} }
} }
} }

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following