private void buttonGetColor_Click(object sender, EventArgs e)
        {
            IntPtr windowHandler = Module.FindWindowByName("CYBOS Starter");

            Win32.Rect rect = Module.WindowPosisionByName(windowHandler);
            //Ut.Log("top:" + rect.Top + " left:" + rect.Left + " bottom:" + rect.Bottom + " right:" + rect.Right);

            // 685, 715
            // 6, 15

            double argb    = 0;
            int    counter = 0;

            for (int i = 6; i < 16; i++)
            {
                for (int j = 685; j < 716; j++)
                {
                    int x = rect.Left + j;
                    int y = rect.Top + i;
                    argb = argb + Win32.GetPixelColor(x, y).ToArgb();
                    counter++;
                }
            }

            Ut.Log((argb / Convert.ToDouble(counter)).ToString());

            return;
        }
        // 해당 좌표에 클릭 버튼
        public static bool Click(Win32.Rect location)
        {
            Ut.Log("X : " + location.Left + " Y : " + location.Top + " 에 클릭");

            Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN, (uint)location.Left, (uint)location.Top, 0, new IntPtr());
            Win32.mouse_event(Win32.MOUSEEVENTF_LEFTUP, (uint)location.Left, (uint)location.Top, 0, new IntPtr());
            return(true);
        }
        // 모의투자 버튼이 눌려있는지를 판단.
        public static bool CheckVirtualBtnClicked()
        {
            IntPtr windowHandler = Module.FindWindowByName("CYBOS Starter");

            Win32.Rect rect = Module.WindowPosisionByName(windowHandler);
            //Ut.Log("top:" + rect.Top + " left:" + rect.Left + " bottom:" + rect.Bottom + " right:" + rect.Right);

            // 685, 715
            // 6, 15

            double argb    = 0;
            int    counter = 0;

            for (int i = 6; i < 16; i++)
            {
                for (int j = 685; j < 716; j++)
                {
                    int x = rect.Left + j;
                    int y = rect.Top + i;
                    argb = argb + Win32.GetPixelColor(x, y).ToArgb();
                    counter++;
                }
            }

            double avgPxl = argb / Convert.ToDouble(counter);

            if (avgPxl < -9000000)
            {
                // avgPxl : -10287651 --> 모의투자버튼 눌러져 있음.
                return(true);
            }
            else
            {
                // avgPxl : -8949047 --> 모의투자버튼 눌러져 있지 않음
                return(false);
            }
        }
 // 윈도우 좌표를 가져온다.
 public static Win32.Rect WindowPosisionByName(IntPtr wdwHandler)
 {
     Win32.Rect rect = new Win32.Rect();
     Win32.GetWindowRect(wdwHandler, ref rect);
     return rect;
 }
 // 윈도우 좌표를 가져온다.
 public static Win32.Rect WindowPosisionByName(IntPtr wdwHandler)
 {
     Win32.Rect rect = new Win32.Rect();
     Win32.GetWindowRect(wdwHandler, ref rect);
     return(rect);
 }
        public void Action()
        {
            string id       = Setting.ReadIniValueByKey(@"C:\settings\cybos.ini", "id");
            string password = Setting.ReadIniValueByKey(@"C:\settings\cybos.ini", "password");

            Module.KillProcess();
            Module.Pause(2000);

            System.Diagnostics.Process.Start(@"C:\DAISHIN\STARTER\ncStarter.exe", "/prj:cp");

            Module.Pause(3000);

            if (Module.CheckWindowIsExist("대신증권 CYBOS FAMILY"))
            {
                // 대신증권 CYBOS FAMILY 화면 존재
                // 보안프로그램이 사용하지 않음으로 선택되어 있습니다.
                Module.ButtonClick(Module.FindWindowByName("대신증권 CYBOS FAMILY"), 6);
            }
            ;

            Module.Pause(2000);

            IntPtr windowHandler = Module.FindWindowByName("CYBOS Starter");

            mainWndHandler = windowHandler; // 메인 윈도우 핸들러 등록 (WinEventProc에서 사용해야되기 때문)

            Ut.Log("메인핸들러 : " + mainWndHandler.ToString("X8"));

            if (Module.CheckVirtualBtnClicked())
            {
                // 모의투자 버튼 눌러져 있음.
            }
            else
            {
                // 모의투자 버튼 눌러져 있지 않음. 눌러야함.
                Module.ButtonClick(mainWndHandler, 327);
            }

            Module.mainWndHander = mainWndHandler;
            Ut.Log("메인핸들러 : " + mainWndHandler.ToString("X8"));

            //IntPtr hhook = Win32.SetWinEventHook(Win32.EVENT_SYSTEM_FOREGROUND, Win32.EVENT_SYSTEM_FOREGROUND,
            //   IntPtr.Zero, new Win32.WinEventDelegate(Module.WinEventProc), 0, 0, Win32.WINEVENT_OUTOFCONTEXT);

            Module.Pause(2000);
            Module.SetTextInEdit(windowHandler, 156, id);
            Module.Pause(500);
            Module.SetTextInEdit(windowHandler, 157, password);
            Module.Pause(500);
            Module.ButtonClick(windowHandler, 203);
            Module.Pause(20000);

            Win32.Rect rec = Module.WindowPosisionByName(mainWndHandler);
            rec.Top  = rec.Top + 128 + 10;
            rec.Left = rec.Left + 492 + 10;

            Win32.POINT p = new Win32.POINT();
            p.x = rec.Left;
            p.y = rec.Top;

            Win32.SetCursorPos(p.x, p.y);
            Win32.SetCursorPos(p.x, p.y);

            Module.Click(rec);
            Module.Click(rec);
            Module.Click(rec);

            Ut.Log(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle.ToString("X8"));
        }