之前帮朋友写的一个小工具-征途2新浪卡全自动淘号工具+按钮精灵脚本

 

比较简单的小工具

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.Net;
using System.Text.RegularExpressions;
using System.IO;

namespace Zt2SinaTaoKaTool
{
    public partial class MainForm : Form
    {
        public MainForm()
        {

            InitializeComponent();

        }
        private int ka_ren_count = 10;
        private WebClient client = null;
        private StreamWriter sw = new StreamWriter("ka.txt", true);

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button2.Enabled = true;
            textBox1.Enabled = false;
            try
            {
                ka_ren_count = Int32.Parse(textBox1.Text);
            }
            catch (Exception)
            {
                ka_ren_count = 10;
            }


            //开始任务

            if (client == null)
            {
                client = new WebClient();
            }
            else
            {
                if (client.IsBusy)
                {
                    client.Dispose();
                }
                client = new WebClient();

            }
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            // Add a user agent header in case the 
            // requested URI contains a query.

            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            timer1.Start();
        }
        private int tao_count = 0;
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            MainForm pThis = sender as MainForm;
            if (e.Result != null)
            {
                using (e.Result)
                {

                    StreamReader reader = new StreamReader(e.Result);
                    string s = reader.ReadToEnd();
                    reader.Close();

                    Regex reg = new Regex(@"本组卡号已经被[\d]{0,4}人淘过");
                    Match match = reg.Match(s);
                    if (match.Success)
                    {
                        string value = match.Value;
                        string int_value = value.Replace("本组卡号已经被", "").Replace("人淘过", "").Trim();
                        if (int_value != "")
                        {
                            int ren = Convert.ToInt32(int_value);
                            if (ren <= ka_ren_count)
                            {
                                Regex reg_ka = new Regex("(.){5}-(.){5}-(.){5}-(.){5}");
                                MatchCollection ka_matchs = reg_ka.Matches(s);
                                if (ka_matchs.Count > 0)
                                {
                                    StreamWriter sw_single = new StreamWriter(string.Format("ka_{0}_{1}.txt", DateTime.Now.Ticks, int_value), true);

                                    string _tempLastKa = "";
                                    foreach (Match item in ka_matchs)
                                    {
                                        string _ka = item.Value;
                                        if (_tempLastKa == _ka)
                                        {
                                            continue;
                                        }
                                        _tempLastKa = _ka;
                                        sw.WriteLine(_ka);
                                        sw.Flush();

                                        sw_single.WriteLine(_ka);
                                        listBox1.Items.Add(_ka);
                                    }
                                    sw_single.Close();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("网络请求出错了,重新打开试试!");
                    }
                }
                tao_count++;
                label2.Text = tao_count.ToString();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            client.OpenReadCompleted -= client_OpenReadCompleted;
            button1.Enabled = true;
            button2.Enabled = false;
            textBox1.Enabled = true;


        }

        private int timer_count = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer_count++;
            label4.Text = timer_count.ToString();
            if (timer_count >= 20)
            {
                timer_count = 0;


                try
                {

                    client.OpenReadAsync(new Uri("http://ka.sina.com.cn/index.php/request/pickNum/gid/722/itemId/3843/1371195204095"), this);

                }
                catch (Exception)
                {

                    MessageBox.Show("网络异常,关了重试!");
                }
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

            //System.Collections.Specialized.StringCollection s = new System.Collections.Specialized.StringCollection();
            //MessageBox.Show(listBox1.SelectedItem as string);
            //s.Add(listBox1.SelectedItem as string);
            Clipboard.SetDataObject(listBox1.SelectedItem as string);

        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            sw.Close();
        }
    }
}

 

按钮精灵的脚本

Dim a
SetSimMode 2


VBS Dim fso,ts,text
VBS Const ForReading = 1
VBS Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("e:\ka_tool\ka.txt", ForReading)


Rem Read_1
VBS kaTest=ts.ReadLine
if kaTest="" or ts.AtEndOfStream
    Goto Read_Over
End If

    

    
    LeftClick 1    /*左键,这是点NPC的*/

 '==========以下是按键精灵录制的内容==========
Delay 100
MoveTo 456, 337
Delay 30
MoveTo 452, 337
Delay 10
MoveTo 450, 337
Delay 30
MoveTo 442, 337
Delay 10
MoveTo 438, 337
Delay 30
MoveTo 431, 335
Delay 10
MoveTo 426, 335
Delay 30
MoveTo 424, 335
Delay 10
MoveTo 422, 334
Delay 30
MoveTo 419, 333
Delay 10
MoveTo 416, 333
Delay 30
MoveTo 414, 332
MoveTo 412, 331
Delay 20
MoveTo 408, 330
Delay 10
MoveTo 398, 328
Delay 10
MoveTo 385, 325
Delay 20
MoveTo 374, 321
Delay 100
MoveTo 357, 320
Delay 100
MoveTo 349, 319
Delay 200
MoveTo 342, 318
Delay 200
MoveTo 338, 318
MoveTo 336, 318
Delay 500
LeftDown 1
LeftClick 1
LeftUp 1
Delay 500
'==========以上是按键精灵录制的内容==========

  
    a = left(kaTest, 23)
    
    //Plugin.Sys.SetCLB (a)


//Delay 240
//KeyDown "Ctrl", 1
//Delay 150
//KeyDown "V", 1
//Delay 100
//KeyUp "V", 1
//Delay 30
//KeyUp "Ctrl", 1

SayString a
KeyPress 13,1
    
    Delay 1000       /*延迟1秒*/
    KeyPress "Enter", 1   /*回车兑换*/
    Delay 2000    /*延迟1秒*/


    //下面这句在屏幕区域范围内截图保存到("C:\PIC.bmp")里
    //Call Plugin.Pic.PrintScreen(369,274,716,422, "C:\PIC.bmp")    
    FindPic 369,274,716,422,"Attachment:\2013621113659.bmp",0.9,intX,intY
    If intX > 0 And intY > 0 Then 
        Call Plugin.File.WriteFileEx("E:\ka_tool\ka_error.txt", a)
    Else 
        Call Plugin.File.WriteFileEx("E:\ka_tool\ka_ok.txt", a)
                    
    End If
    
    KeyPress "Enter", 1  /*把弹出的那个兑换成功啊还有卡号错误那个框框按掉*/
    Delay 500

 '==========以下是按键精灵录制的内容==========
 Delay 100
 MoveTo 336, 318
 MoveTo 338, 318
 Delay 20
 MoveTo 342, 318
 Delay 20
 MoveTo 349, 319
 Delay 10
 MoveTo 357, 320
 Delay 10
 MoveTo 374, 321
 Delay 20
 MoveTo 385, 325
 Delay 10
 MoveTo 398, 328
 Delay 10
 MoveTo 408, 330
 Delay 20
 MoveTo 412, 331
 Delay 30
 MoveTo 416, 333
 Delay 10
 MoveTo 419, 333
 Delay 30
 MoveTo 422, 334
 Delay 10
 MoveTo 424, 335
 Delay 30
 MoveTo 426, 335
 Delay 10
 MoveTo 431, 335
 Delay 30
 MoveTo 438, 337
 Delay 10
 MoveTo 442, 337
 Delay 30
 MoveTo 450, 337
 Delay 10
 MoveTo 452, 337
Delay 30
MoveTo 456, 337
Delay 100


'==========以上是按键精灵录制的内容==========

Goto Read_1
Rem Read_Over

VBS ts.Close

 

posted @ 2013-07-02 08:36  MokLiu  阅读(1744)  评论(0编辑  收藏  举报