using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication5
    class Program
        public static extern bool SetWindowText(IntPtr hwnd, string title);

        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
        //Mouse actions
        private const int MOUSEEVENTF_LEFTDOWN = 0x02;
        private const int MOUSEEVENTF_LEFTUP = 0x04;
        private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
        private const int MOUSEEVENTF_RIGHTUP = 0x10;

        static void Main(string[] args)
            while (true)

        private static void CheckProcess()
            Process[] processlist = Process.GetProcessesByName("chrome");

            foreach (Process process in processlist)
                String windowTitle = process.MainWindowTitle;
                if (windowTitle.Contains("watch_chrome_position"))
                    String[] Titles = Regex.Split(windowTitle, "watch_chrome_position");
                    String windowTitleStart = Titles[0];
                    String position_str = Regex.Match(Titles[1], "[\\w]*").ToString();
                    String[] positions = Regex.Split(position_str, "_");
                    uint X = Convert.ToUInt32(positions[0]);
                    uint Y = Convert.ToUInt32(positions[1]);
                    //DoMouseClick(200, 200);
                    SetWindowText(process.MainWindowHandle, "333333");

        private static void DoMouseClick(uint X, uint Y)
            //Call the imported function with the cursor's current position
            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);