我正在嘗試在C#中創建一個自動化的Clicker程序,以便使某些管理任務更快。總之,我將使用一個程序(Firefox),並且需要一個程序來自動移動鼠標並單擊我所告訴的地方。以編程方式在Firefox中自動執行鼠標移動和點擊操作
目前我有這樣的代碼,儘管我覺得我離實際解決方案還很遙遠。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
namespace Clicker
{
public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
Cursor.Position = new Point((int)10, (int)10);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, Cursor.Position.X, Cursor.Position.Y, 0, 0);
}
public Form1()
{
//InitializeComponent();
}
}
}
我希望我的程序能夠在Firefox上運行,並且一旦它已經加載,立即開始點擊我告訴它的位置。它需要點擊13個30x30像素按鈕,然後停下來,讓我完成任務。
我該怎麼去做這樣的工作?
編輯:我忘了提到,前端是在Flash中。奇怪,我知道。無論哪種方式,這意味着像Selenium這樣的程序不會像軌道頁面移動和點擊鏈接一樣工作。
完美。謝謝! – 2009-10-07 18:26:40