728x90
스타하다가 수건돌리기를 하는데 오토마우스 쓰는 사람들이 있고 다른사람들은 프로그램은 믿기 어려워 직접 제작해 보았다
결과창

사용방법 :
1. On을 누르면 오토마우스 사용 준비가 되고 numpad0을 누르면 오토 클릭이 된다 다시 numpad0을 누르면 오토클릭이 해제된다.
2. 숫자는 시간당 원하는 클릭회수로 0 ~ 1000까지 ms로 조절가능하다 1000이면 1초에 1번 1이번 1초에 대략 100번클릭이다.
WindowForm이용
1. program.cs
간단하게 설명하면 윈도우 차으이 auto를 세팅하고 numpad0을 누르면 오토마우스가 on 다시 numpad0을 누르면 오토마우스가 off된다
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace AutoMouse
{
internal static class Program
{
[DllImport("user32.dll", SetLastError = true)]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
[DllImport("user32.dll")]
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
private static extern int GetCursorPos(int x, int y);
[DllImport("kernel32.dll")]
private static extern IntPtr GetModuleHandle(string lpModuleName);
private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
private const uint MOUSEEVENTF_LEFTUP = 0x04;
private const int WH_KEYBOARD_LL = 13;
private const int WM_KEYDOWN = 0x0100;
private static LowLevelMouseProc _proc;
public static IntPtr _hookID = IntPtr.Zero;
public static bool isAutoClick = false;
public static event Action programStatus;
/// <summary>
/// 해당 애플리케이션의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
_proc = HookCallback;
_hookID = SetHook(_proc);
Application.Run(new Form1());
}
public static IntPtr SetHook(LowLevelMouseProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
}
}
public delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
{
int vkCode = Marshal.ReadInt32(lParam);
Keys key = (Keys)vkCode;
if (key == Keys.NumPad0)
{
isAutoClick = !isAutoClick;
programStatus?.Invoke();
}
}
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}
public static void PerformMouseClick()
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
}
}
2. Form1
시간당 클릭을 몇번할지 설정해 준다
시간은 ms로 100으로 설정하면 1초당 10번 정도 클릭한다
using System;
using System.Windows.Forms;
namespace AutoMouse
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Program.programStatus += () =>
{
programCheckBox.Checked = Program.isAutoClick;
};
}
private void OnButton_Click(object sender, EventArgs e)
{
statusCheckBox.Checked = true;
clickTimer.Start();
}
private void OffButton_Click(object sender, EventArgs e)
{
statusCheckBox.Checked = false;
clickTimer.Stop();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Program.UnhookWindowsHookEx(Program._hookID);
}
private void ClickTimer_Tick(object sender, EventArgs e)
{
if (!Program.isAutoClick)
return;
PerformMouseClick();
}
private void PerformMouseClick()
{
Console.WriteLine("Click");
Program.PerformMouseClick();
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
clickTimer.Interval = (int)numericUpDown1.Value;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}
3. Form1 디자인
using System.Windows.Forms;
namespace AutoMouse
{
partial class Form1
{
private Button onButton;
private Button offButton;
private CheckBox statusCheckBox;
private Timer clickTimer;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.onButton = new System.Windows.Forms.Button();
this.offButton = new System.Windows.Forms.Button();
this.statusCheckBox = new System.Windows.Forms.CheckBox();
this.clickTimer = new System.Windows.Forms.Timer(this.components);
this.programCheckBox = new System.Windows.Forms.CheckBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// onButton
//
this.onButton.Location = new System.Drawing.Point(20, 20);
this.onButton.Name = "onButton";
this.onButton.Size = new System.Drawing.Size(75, 23);
this.onButton.TabIndex = 0;
this.onButton.Text = "On";
this.onButton.Click += new System.EventHandler(this.OnButton_Click);
//
// offButton
//
this.offButton.Location = new System.Drawing.Point(100, 20);
this.offButton.Name = "offButton";
this.offButton.Size = new System.Drawing.Size(75, 23);
this.offButton.TabIndex = 1;
this.offButton.Text = "Off";
this.offButton.Click += new System.EventHandler(this.OffButton_Click);
//
// statusCheckBox
//
this.statusCheckBox.Location = new System.Drawing.Point(20, 60);
this.statusCheckBox.Name = "statusCheckBox";
this.statusCheckBox.Size = new System.Drawing.Size(100, 24);
this.statusCheckBox.TabIndex = 2;
this.statusCheckBox.Text = "Active";
//
// clickTimer
//
this.clickTimer.Interval = 5;
this.clickTimer.Tick += new System.EventHandler(this.ClickTimer_Tick);
//
// programCheckBox
//
this.programCheckBox.Enabled = false;
this.programCheckBox.Location = new System.Drawing.Point(20, 90);
this.programCheckBox.Name = "programCheckBox";
this.programCheckBox.Size = new System.Drawing.Size(114, 24);
this.programCheckBox.TabIndex = 3;
this.programCheckBox.Text = "ProgramOn";
this.programCheckBox.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// numericUpDown1
//
this.numericUpDown1.Increment = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDown1.Location = new System.Drawing.Point(100, 60);
this.numericUpDown1.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(120, 25);
this.numericUpDown1.TabIndex = 4;
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(220, 140);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.programCheckBox);
this.Controls.Add(this.onButton);
this.Controls.Add(this.offButton);
this.Controls.Add(this.statusCheckBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "Auto Clicker";
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
private CheckBox programCheckBox;
private NumericUpDown numericUpDown1;
}
}
아 스타하는데 이번엔 채팅 매크로 쓰는애들이 있는데 이거나 만들어봐야겠당
AutoMouse.exe
0.01MB
728x90
'심심해서 만들어 보는것들' 카테고리의 다른 글
티스토리 반 자동 커밋 - selenium 사용 (0) | 2025.03.20 |
---|---|
Unity - 포켓몬 이미지 가져오는 방법 (0) | 2024.08.25 |
유튜브 댓글 자동생성 - 댓글 매크로 기능(Youtube API사용) (16) | 2024.08.14 |
포켓로그 - 티켓 복사 치트, 이로치 치트 or 치트로 알 빠르게 부활시키고 싶은경우 (83) | 2024.07.07 |