From 2dc47c8cac2794049e6e3888b9dec9bc9e3ce143 Mon Sep 17 00:00:00 2001 From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com> Date: Sun, 10 Nov 2019 12:13:07 +0100 Subject: [PATCH] Some fixes --- CC-Clicker 2.0/MainForm.Designer.cs | 9 +++-- CC-Clicker 2.0/MainForm.cs | 60 ++++++++++++++--------------- CC-Clicker 2.0/MainForm.resx | 3 ++ 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/CC-Clicker 2.0/MainForm.Designer.cs b/CC-Clicker 2.0/MainForm.Designer.cs index 1b3c3de..38bb02c 100644 --- a/CC-Clicker 2.0/MainForm.Designer.cs +++ b/CC-Clicker 2.0/MainForm.Designer.cs @@ -39,11 +39,13 @@ this.delmVal = new System.Windows.Forms.TextBox(); this.fixBox = new System.Windows.Forms.CheckBox(); this.fixButton = new System.Windows.Forms.Button(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.SuspendLayout(); // // clickBox // this.clickBox.AutoSize = true; + this.clickBox.Enabled = false; this.clickBox.Location = new System.Drawing.Point(12, 14); this.clickBox.Name = "clickBox"; this.clickBox.Size = new System.Drawing.Size(49, 17); @@ -71,7 +73,7 @@ this.timeBox.Size = new System.Drawing.Size(100, 20); this.timeBox.TabIndex = 2; this.timeBox.Text = "100"; - this.timeBox.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + this.timeBox.TextChanged += new System.EventHandler(this.timeBox_TextChanged); // // keyButton // @@ -97,7 +99,7 @@ // // timer // - this.timer.Tick += new System.EventHandler(this.timer1_Tick); + this.timer.Tick += new System.EventHandler(this.timer_Tick); // // delmVal // @@ -149,10 +151,10 @@ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MaximumSize = new System.Drawing.Size(229, 165); + this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(229, 165); this.Name = "MainForm"; this.Text = "CC-Clicker 2.0"; - this.Resize += new System.EventHandler(this.Form1_Resize); this.ResumeLayout(false); this.PerformLayout(); @@ -169,6 +171,7 @@ private System.Windows.Forms.TextBox delmVal; private System.Windows.Forms.CheckBox fixBox; private System.Windows.Forms.Button fixButton; + private System.Windows.Forms.ToolTip toolTip; } } diff --git a/CC-Clicker 2.0/MainForm.cs b/CC-Clicker 2.0/MainForm.cs index 4fba34b..4a6b2a2 100644 --- a/CC-Clicker 2.0/MainForm.cs +++ b/CC-Clicker 2.0/MainForm.cs @@ -12,10 +12,18 @@ namespace CC_Clicker_2._0 { Point loc = Point.Empty; OvPForm ov; + public static Button _keyButton; + public static bool _isSettingKey = false; + public static Keys _key = Keys.LShiftKey; + public static bool _isClicking = false; + public static int _setDelay = 100; + public static int _delmVal = 4; + public static CheckBox _clickBox; public MainForm() { InitializeComponent(); - SessionData.keyButton = keyButton; + _keyButton = keyButton; + _clickBox = clickBox; ov = new OvPForm(loc.X, loc.Y); } @@ -24,17 +32,18 @@ namespace CC_Clicker_2._0 if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { int vkCode = Marshal.ReadInt32(lParam); - if (SessionData.isSettingKey) + if (_isSettingKey) { - SessionData.key = (Keys)vkCode; - SessionData.keyButton.BackColor = Color.FromArgb(224, 224, 224); - SessionData.keyButton.Text = ((Keys)vkCode).ToString(); - SessionData.isSettingKey = false; + _key = (Keys)vkCode; + _keyButton.BackColor = Color.FromArgb(224, 224, 224); + _clickBox.Enabled = true; + _keyButton.Text = ((Keys)vkCode).ToString(); + _isSettingKey = false; } else { - if ((Keys)vkCode == SessionData.key) - SessionData.isClicking = !SessionData.isClicking; + if ((Keys)vkCode == _key) + _isClicking = !_isClicking; } } return CallNextHookEx(_hookID, nCode, wParam, lParam); @@ -42,15 +51,15 @@ namespace CC_Clicker_2._0 private void clickBox_CheckedChanged(object sender, EventArgs e) { - SessionData.isClicking = false; + _isClicking = false; timer.Enabled = clickBox.Checked; } - private void textBox1_TextChanged(object sender, EventArgs e) + private void timeBox_TextChanged(object sender, EventArgs e) { if (int.TryParse(timeBox.Text, out int re) && re > 0) { - SessionData.setDelay = re; + _setDelay = re; timer.Interval = re; timeBox.BackColor = Color.White; } @@ -64,7 +73,7 @@ namespace CC_Clicker_2._0 { if (int.TryParse(delmVal.Text, out int re) && re > 0 && re % 2 == 0) { - SessionData.delmVal = re; + _delmVal = re; delmVal.BackColor = Color.White; } else @@ -75,22 +84,19 @@ namespace CC_Clicker_2._0 private void keyButton_Click(object sender, EventArgs e) { - SessionData.isSettingKey = true; + _isSettingKey = true; keyButton.BackColor = Color.FromArgb(128, 255, 128); } - private void timer1_Tick(object sender, EventArgs e) + private void timer_Tick(object sender, EventArgs e) { - if (SessionData.isClicking) + if (_isClicking) { - uint X = (uint)Cursor.Position.X; - uint Y = (uint)Cursor.Position.Y; - if (rightBox.Checked) - mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, X, Y, 0, 0); - else - mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0); + if (fixBox.Checked) + 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); if (delmBox.Checked) - timer.Interval = Math.Max(SessionData.setDelay + (new Random().Next(0, SessionData.delmVal) - (SessionData.delmVal / 2)), 1); + timer.Interval = Math.Max(_setDelay + (new Random().Next(0, _delmVal) - (_delmVal / 2)), 1); } } @@ -116,7 +122,6 @@ namespace CC_Clicker_2._0 } } - private void Form1_Resize(object sender, EventArgs e) => WindowState = FormWindowState.Normal; private void fixButton_MouseEnter(object sender, EventArgs e) { ov.setPos(loc.X, loc.Y); @@ -151,15 +156,6 @@ namespace CC_Clicker_2._0 const int WM_KEYDOWN = 0x0100; public static LowLevelKeyboardProc _proc = HookCallback; public static IntPtr _hookID = IntPtr.Zero; - static class SessionData - { - public static Button keyButton; - public static bool isSettingKey = false; - public static Keys key = Keys.LShiftKey; - public static bool isClicking = false; - public static int setDelay = 100; - public static int delmVal = 4; - } #endregion } } diff --git a/CC-Clicker 2.0/MainForm.resx b/CC-Clicker 2.0/MainForm.resx index 3dd32a0..0574a03 100644 --- a/CC-Clicker 2.0/MainForm.resx +++ b/CC-Clicker 2.0/MainForm.resx @@ -120,6 +120,9 @@ 17, 17 + + 97, 17 +