Example #1
0
        private static void playTask(int hwnd)
        {
            var rectangle = new Rectangle(810, 184, 168, 86);
            var bitmap    = Capture.CaptureWindowRectangle((IntPtr)hwnd, rectangle);

            System.IO.MemoryStream ms = new MemoryStream();
            bitmap.Save(ms, ImageFormat.Png);
            bitmap.Save("test.png");
            byte[] byteImage = ms.ToArray();
            var    base64    = Convert.ToBase64String(byteImage);
            var    text      = AIService.commonOcr(base64);
            var    taskText  = text.GetValues()["itemstring"];

            Console.WriteLine("task-title:" + taskText);
            if (taskText.Contains("20级"))
            {
                Click((IntPtr)hwnd, 856, 324);
                Console.WriteLine("已经满了16级,进行第二个任务");
            }
            else
            {
                Click((IntPtr)hwnd, 1000, 240);
                Console.WriteLine("OK, test event is fired at: " + DateTime.Now.ToString());
            }
            foreach (var key in text.GetValues().Keys)
            {
                Console.WriteLine("key:" + key);
            }
        }
Example #2
0
        public object commonOCR()
        {
            var gameProcesses = Finder.findGameProcesses("梦幻西游");
            var hwnd          = gameProcesses[0]?.hwnd;
            var rectangle     = new Rectangle(810, 184, 168, 86);
            var bitmap        = Capture.CaptureWindowRectangle((IntPtr)hwnd, rectangle);

            System.IO.MemoryStream ms = new MemoryStream();
            bitmap.Save(ms, ImageFormat.Png);
            bitmap.Save("test.png");
            byte[] byteImage = ms.ToArray();
            var    base64    = Convert.ToBase64String(byteImage);
            var    text      = AIService.commonOcr(base64);

            Console.WriteLine(text);
            return(text);
        }