« 大安寺 | メイン | Outlookセキュリティダイアログ自動はい選択ツール »

自動クリックツールの作成

特定の場所を指定秒ごとにクリックし続けるツール「AutoClick2」を作成しました。自動処理のために使用できます。(ただし、DoS攻撃等には使用しないでください。)


https://github.com/mfright/AutoClick2/releases/

ソースコードごと、上記GitHubに保管しておきます。お好きに改造して使ってください。

【起動時の注意】

初回起動時に以下のようなセキュリティ警告が出ますが、これは本ツールがWin32 APIへアクセスするためです。初回のみ「実行する」を選択してください。






以下Readmeです。

/**************************************************/

Auto Click
2014/05/10
http://www.ddhost.jp

/**************************************************/

本ツールは、指定した場所を5秒ごとにクリックし続けるだけのソフトです。
本ツール動作中にカーソルを動かしても、クリックし続ける座標は変化しません。

【現在のカーソル位置で自動クリック開始】
自動クリックさせたい位置へカーソルを持っていき、[Alt]+[Tab]と[Space]を用いて「自動クリック開始」ボタンを押すと、5秒ごとにその場所をクリックし続けます。

【カーソル位置を指定して自動クリック】
自動クリックさせたいカーソルの座標を入力し、「上記座標で自動クリック開始」を押すと、5秒ごとにその場所をクリックし続けます。
クリックしたい場所の座標を知るには、その場所へカーソルを持っていき、本ツールのステータスバーの「現在のカーソル位置」を確認します。













【ソースコード】

/*
* AutoClick2
* 2014/05
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Runtime.InteropServices;


namespace AutoClick2
{

public partial class Form1 : Form
{
[DllImport("USER32.DLL")]
private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

int pointX=0, pointY=0, currentPointX, currentPointY; //マウスカーソル位置の設定先
Color buttonColor;

public Form1()
{
InitializeComponent();

buttonColor = btnLockAndClick.BackColor;
}

private void timer1_Tick(object sender, EventArgs e)
{
currentPointX = System.Windows.Forms.Cursor.Position.X;
currentPointY = System.Windows.Forms.Cursor.Position.Y;

setPoint(pointX, pointY);
doClick();

setPoint(currentPointX, currentPointY);

}

void doClick()
{
//[System.Runtime.InteropServices.DllImport("USER32.DLL")]
int MOUSEEVENTF_LEFTDOWN = 0x2;
int MOUSEEVENTF_LEFTUP = 0x4;
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}

void setPoint(int newX, int newY)
{
System.Windows.Forms.Cursor.Position = new System.Drawing.Point(newX, newY);
}

private void btnLockAndClick_Click(object sender, EventArgs e)
{
if (btnLockAndClick.BackColor != Color.Yellow)
{
pointX = System.Windows.Forms.Cursor.Position.X;
pointY = System.Windows.Forms.Cursor.Position.Y;

txtPointX.Text = pointX + "";
txtPointY.Text = pointY + "";

timerAutoClick.Start();
btnLockAndClick.BackColor = Color.Yellow;
btnLockAndClick.Text = "自動クリック実行中。\r\n止めるにはここをクリック";
btnStartAtEditedPoint.Enabled = false;
}
else
{
timerAutoClick.Stop();
btnLockAndClick.BackColor = buttonColor;
btnLockAndClick.Text = "自動クリック開始";
btnStartAtEditedPoint.Enabled = true;
}

}

private void btnStartAtEditedPoint_Click(object sender, EventArgs e)
{
if (btnStartAtEditedPoint.BackColor != Color.Yellow)
{

try
{
// カーソルを置くべきポイントを取得する
pointX = int.Parse(txtPointX.Text);
pointY = int.Parse(txtPointY.Text);
}
catch (Exception ex)
{
return;
}

timerAutoClick.Start();
btnStartAtEditedPoint.Text = "自動クリック実行中。\r\n止めるにはここをクリック";
btnStartAtEditedPoint.BackColor = Color.Yellow;
btnLockAndClick.Enabled = false;
}
else
{
timerAutoClick.Stop();
btnStartAtEditedPoint.Text = "上記座標を自動クリック開始";
btnStartAtEditedPoint.BackColor = buttonColor;
btnLockAndClick.Enabled = true;
}
}

private void timerGetPoint_Tick(object sender, EventArgs e)
{
currentPointX = System.Windows.Forms.Cursor.Position.X;
currentPointY = System.Windows.Forms.Cursor.Position.Y;
//txtPointX.Text = pointX + "";
//txtPointY.Text = pointY + "";
toolStripPoint.Text = "現在のカーソル位置 X: " + currentPointX + " Y: " + currentPointY;
}


}
}


トラックバック

このエントリーのトラックバックURL:
http://www.ddhost.jp/mt/mt-tb.cgi/909

About

2014年07月06日 20:10に投稿されたエントリーのページです。

ひとつ前の投稿は「大安寺」です。

次の投稿は「Outlookセキュリティダイアログ自動はい選択ツール」です。

他にも多くのエントリーがあります。メインページアーカイブページも見てください。