天猫 刷红包
今天刚做的,很简单 直接看代码:我的电脑是1280*800的,不知道在别的电脑上有没问题
因为刷的时候会弹出各种原因的对话框,都是找到那个关闭按钮坐标,模拟点击关闭的
有兴趣自己耍耍,不要搞别的!
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
namespace ControlMouseOver
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool GetCursorPos(ref POINT pt);
[DllImport("user32.dll")]
public static extern int SetCursorPos(int x, int y);
[DllImport("user32")]
private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
DispatcherTimer timer = new DispatcherTimer();
DispatcherTimer timer2 = new DispatcherTimer();
DispatcherTimer time3 = new DispatcherTimer();
public MainWindow()
{
InitializeComponent();
timer.Tick += timer_Tick;
timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
timer2.Tick += timer2_Tick;
timer2.Interval = new TimeSpan(0, 0, 0, 0, 1);
time3.Interval = new TimeSpan(0, 0, 0, 3);
time3.Tick += time3_Tick;
}
void time3_Tick(object sender, EventArgs e)
{
POINT p = new POINT();
p.x = 838;
p.y = 361;
SetCursorPos(p.x, p.y);
mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
}
void timer2_Tick(object sender, EventArgs e)
{
POINT p = new POINT();
mouse_event(MOUSEEVENTF_MOVE, p.x + 20, p.y, 0, 0);
temp += 10;
if (temp == 210)
{
timer2.Stop();
timer.Start();
temp = 0;
}
}
int temp = 0;
void timer_Tick(object sender, System.EventArgs e)
{
POINT p = new POINT();
mouse_event(MOUSEEVENTF_MOVE, p.x - 20, p.y, 0, 0);
temp += 10;
if (temp == 210)
{
timer.Stop();
temp = 0;
timer2.Start();
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
timer.Start();
time3.Start();
POINT p = new POINT();
p.x = 645;
p.y = 311;
SetCursorPos(p.x, p.y);
mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
}
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if ( e.Key == Key.Escape)
{
Application.Current.Shutdown();
}
}
//private void Button_Click_1(object sender, RoutedEventArgs e)
//{
// // POINT p = new POINT();
// // //p.x = 888;
// // //p.y = 50;
// //// SetCursorPos(p.x, p.y);
// // GetCursorPos(ref p);
// // //mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
// // //mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
// // MessageBox.Show(p.x.ToString() + " " + p.y.ToString());
//}
}
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int x, y;
}
}
posted on 2013-06-15 14:15 Breeze-Chen 阅读(1266) 评论(0) 收藏 举报
浙公网安备 33010602011771号