Exemplo n.º 1
0
 public CaptchaUtil(OrcUtil tips0, OrcUtil tips1, OrcUtil no)
 {
     this.orcNo = no;
     this.orcTips = new OrcUtil[]{ tips0, tips1 };
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建Orc实例(from Directory)
        /// </summary>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="resource"></param>
        /// <returns></returns>
        public static OrcUtil getInstance(int[] offsetX, int offsetY, int width, int height, String dictPath)
        {
            OrcUtil rtn = new OrcUtil();
            rtn.offsetX = offsetX;
            rtn.offsetY = offsetY;
            rtn.width = width;
            rtn.height = height;
            rtn.dict = new Dictionary<Bitmap, String>();

            String[] files = System.IO.Directory.GetFiles(dictPath);
            foreach (String file in files)
            {
                String name = new System.IO.FileInfo(file).Name;
                String[] array = name.Split(new char[] { '.' });
                Bitmap bitmap = new Bitmap(file);
                rtn.dict.Add(bitmap, array[0]);
            }
            return rtn;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建Orc实例(from Stream)
        /// </summary>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="resource"></param>
        /// <returns></returns>
        public static OrcUtil getInstance(int[] offsetX, int offsetY, int width, int height, Stream resource)
        {
            OrcUtil rtn = new OrcUtil();
            rtn.offsetX = offsetX;
            rtn.offsetY = offsetY;
            rtn.width = width;
            rtn.height = height;
            rtn.dict = new Dictionary<Bitmap, String>();

            System.Resources.ResXResourceReader resxReader = new System.Resources.ResXResourceReader(resource);
            IDictionaryEnumerator enumerator = resxReader.GetEnumerator();
            while (enumerator.MoveNext())
            {
                DictionaryEntry entry = (DictionaryEntry)enumerator.Current;
                rtn.dict.Add((Bitmap)entry.Value, (String)entry.Key);
            }
            return rtn;
        }
Exemplo n.º 4
0
 public static OrcUtil getInstance(int[] offsetX, int offsetY, int width, int height, IDictionary<Bitmap, String> dict)
 {
     OrcUtil rtn = new OrcUtil();
     rtn.offsetX = offsetX;
     rtn.offsetY = offsetY;
     rtn.width = width;
     rtn.height = height;
     rtn.dict = dict;
     return rtn;
 }
Exemplo n.º 5
0
 public SubmitPriceJob(String endPoint, OrcUtil orcPrice, OrcUtil orcLoading, CaptchaUtil captchaUtil)
 {
     this.EndPoint = endPoint;
     this.m_orcPrice = orcPrice;
     this.m_orcLoading = orcLoading;
     this.m_captchaUtil = captchaUtil;
 }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Quartz.Xml.XMLSchedulingDataProcessor processor = new Quartz.Xml.XMLSchedulingDataProcessor(new Quartz.Simpl.SimpleTypeLoadHelper());
            //schedulerFactory = new Quartz.Impl.StdSchedulerFactory();
            //scheduler = schedulerFactory.GetScheduler();
            //processor.ProcessFileAndScheduleJobs("~/quartz_jobs.xml", scheduler);
            //scheduler.Start();

            Form.CheckForIllegalCrossThreadCalls = false;
            this.timer.Enabled = true;
            this.timer.Interval = 500;
            this.timer.Start();
            this.timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);

            Hotkey.RegisterHotKey(this.Handle, 100, Hotkey.KeyModifiers.Ctrl, Keys.D3);
            Hotkey.RegisterHotKey(this.Handle, 101, Hotkey.KeyModifiers.Ctrl, Keys.D4);
            Hotkey.RegisterHotKey(this.Handle, 102, Hotkey.KeyModifiers.Ctrl, Keys.D5);
            Hotkey.RegisterHotKey(this.Handle, 103, Hotkey.KeyModifiers.Ctrl, Keys.D6);
            Hotkey.RegisterHotKey(this.Handle, 111, Hotkey.KeyModifiers.Ctrl, Keys.Left);
            Hotkey.RegisterHotKey(this.Handle, 110, Hotkey.KeyModifiers.Ctrl, Keys.Up);
            Hotkey.RegisterHotKey(this.Handle, 112, Hotkey.KeyModifiers.Ctrl, Keys.Right);
            Hotkey.RegisterHotKey(this.Handle, 155, Hotkey.KeyModifiers.Ctrl, Keys.Enter);

            Ini ini = new Ini(Directory.GetCurrentDirectory() + "/config.ini");
            String url = ini.ReadValue("GLOBAL", "URL");
            String debug = ini.ReadValue("GLOBAL", "DEBUG");

            this.textURL.Text = url;
            if("true".Equals(debug.ToLower())){

                //AllocConsole();
                //SetConsoleTitle("千万不要关掉我!");
                //IntPtr windowHandle = FindWindow(null, System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                //IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero);
                //uint SC_CLOSE = 0xF060;
                //RemoveMenu(closeMenu, SC_CLOSE, 0x0);
            }

            //加载配置项1
            IGlobalConfig configResource = Resource.getInstance(url);//加载配置

            this.Text = String.Format("虎牌帮帮忙 - {0}", configResource.tag);
            this.m_orcPrice = configResource.Price;//价格识别
            this.m_orcCaptchaLoading = configResource.Loading;//LOADING识别
            this.m_orcCaptchaTip = configResource.Tips;//验证码提示(文字)
            this.m_orcCaptchaTipNo = configResource.TipsNo;//验证码提示(数字)
            this.m_orcCaptchaTipsUtil = new CaptchaUtil(m_orcCaptchaTip[0], m_orcCaptchaTip[1], m_orcCaptchaTipNo);

            //加载配置项2
            KeepAliveJob keepAliveJob = new KeepAliveJob(url, new ReceiveOperation(this.receiveOperation));
            keepAliveJob.Execute();

            //this.m_orcPrice = OrcUtil.getInstance(new int[] { 0, 10, 20, 30, 40 }, 0, 8, 13, new FileStream("price.resx", FileMode.Open));
            //this.m_orcCaptchaLoading = OrcUtil.getInstance(new int[] { 0, 16, 32, 48, 64, 80, 96 }, 7, 15, 14, new FileStream("loading.resx", FileMode.Open));
            //this.m_orcCaptchaTip = OrcUtil.getInstance(new int[] { 0, 16, 32, 48 }, 0, 15, 16, new FileStream("captcha.tips.resx", FileMode.Open));
            //this.m_orcCaptchaTipNo = OrcUtil.getInstance(new int[] { 64, 88 }, 0, 7, 16, new FileStream("captcha.tips.no.resx", FileMode.Open));

            //this.m_orcPrice = OrcUtil.getInstance(new int[] { 0, 10, 20, 30, 40 }, 0, 8, 13, priceDict);
            //this.m_orcCaptchaLoading = OrcUtil.getInstance(new int[] { 0, 16, 32, 48, 64, 80, 96 }, 7, 15, 14, loadingDict);
            //this.m_orcCaptchaTip = OrcUtil.getInstance(new int[] { 0, 16, 32, 48 }, 0, 15, 16, tipDict);
            //this.m_orcCaptchaTipNo = OrcUtil.getInstance(new int[] { 64, 104 }, 0, 7, 16, tipDict + "/no");
            //this.m_orcCaptchaUtil = new CaptchaUtil(m_orcCaptchaTip, m_orcCaptchaTipNo);

            //keepAlive任务配置
            SchedulerConfiguration config5M = new SchedulerConfiguration(1000 * 60 * 1);
            config5M.Job = new KeepAliveJob(url, new ReceiveOperation(this.receiveOperation));
            m_schedulerKeepAlive = new Scheduler(config5M);

            //Action任务配置
            SchedulerConfiguration config1S = new SchedulerConfiguration(1000);
            config1S.Job = new SubmitPriceJob(url, this.m_orcPrice, this.m_orcCaptchaLoading, this.m_orcCaptchaTipsUtil);
            m_schedulerSubmit = new Scheduler(config1S);
        }