private void Reset()
        {
            KeyboardMouseSimulateDriverAPI.Uninitialize();
            Application.DoEvents();

            m_bInitialized = false;
        }
        private void Test_SetCursorPosition()
        {
            Position cp = new Position();

            cp.m_nX = (int)nudCursorPositionX.Value;
            cp.m_nY = (int)nudCursorPositionY.Value;
            KeyboardMouseSimulateDriverAPI.CursorPosition(ref cp, false);
        }
        private void MouseOperate(object obj)
        {
            if (!m_bInitialized)
            {
                int nReturn = KeyboardMouseSimulateDriverAPI.Initialize((uint)m_nSimulateWay);
                m_bInitialized = (0 == nReturn);
                ShowInfoBoard("Initialize", nReturn, m_bInitialized);
                System.Threading.Thread.Sleep(1000);
            }

            ShowInfoBoard("Ready...");
            System.Threading.Thread.Sleep(1000);
            ShowInfoBoard("Go ! ! !");
            System.Threading.Thread.Sleep(1000);

            if (m_bInitialized)
            {
                bool       bResult     = false;
                Parameters stParameter = (Parameters)obj;

                if (KeyboardMouseSimulatorDemo.MouseButtons.LeftDown == (KeyboardMouseSimulatorDemo.MouseButtons.LeftDown & stParameter.m_nMouseButtons))
                {
                    bResult  = KeyboardMouseSimulateDriverAPI.MouseDown((uint)KeyboardMouseSimulatorDemo.MouseButtons.LeftDown);
                    bResult &= KeyboardMouseSimulateDriverAPI.MouseUp((uint)KeyboardMouseSimulatorDemo.MouseButtons.LeftUp);

                    ShowInfoBoard(KeyboardMouseSimulatorDemo.MouseButtons.LeftDown, bResult);
                }
                else if (KeyboardMouseSimulatorDemo.MouseButtons.RightDown == (KeyboardMouseSimulatorDemo.MouseButtons.RightDown & stParameter.m_nMouseButtons))
                {
                    bResult  = KeyboardMouseSimulateDriverAPI.MouseDown((uint)KeyboardMouseSimulatorDemo.MouseButtons.RightDown);
                    bResult &= KeyboardMouseSimulateDriverAPI.MouseUp((uint)KeyboardMouseSimulatorDemo.MouseButtons.RightUp);

                    ShowInfoBoard(KeyboardMouseSimulatorDemo.MouseButtons.RightDown, bResult);
                }
                else //Move Checked
                {
                    if (chkbxAbsolute.Checked)
                    {
                        bResult = KeyboardMouseSimulateDriverAPI.MouseMove(stParameter.m_nCursorPositionX, stParameter.m_nCursorPositionY, true);
                    }
                    else if (chkbxRelative.Checked)
                    {
                        bResult = KeyboardMouseSimulateDriverAPI.MouseMove(stParameter.m_nCursorPositionX, stParameter.m_nCursorPositionY, false);
                    }

                    ShowInfoBoard(KeyboardMouseSimulatorDemo.MouseButtons.Move, bResult);
                }
            }

            ButtonControl(btnMouseOperate, true, "Mouse");
        }
        private void frmGlobalKeyboardSet_Load(object sender, EventArgs e)
        {
            //MessageBox.Show(KeyboardMouseSimulateDriverAPI.MouseWheel().ToString());
            m_bChecking = true;

            System.Threading.ThreadPool.QueueUserWorkItem((ojb) =>
            {
                Position cp = new Position();
                while (m_bChecking)
                {
                    ShowCheckout(KeyboardMouseSimulateDriverAPI.Checkout());

                    KeyboardMouseSimulateDriverAPI.CursorPosition(ref cp, true);
                    ShowCursorPosition(cp.m_nX, cp.m_nY);

                    System.Threading.Thread.Sleep(50);
                }
            });
        }
        private void Simulate(object obj)
        {
            if (!m_bInitialized)
            {
                int nReturn = KeyboardMouseSimulateDriverAPI.Initialize((uint)m_nSimulateWay);
                m_bInitialized = (0 == nReturn);
                ShowInfoBoard("Initialize", nReturn, m_bInitialized);
                System.Threading.Thread.Sleep(1000);
            }

            ShowInfoBoard("Ready...");
            System.Threading.Thread.Sleep(1000);
            ShowInfoBoard("Go ! ! !");
            System.Threading.Thread.Sleep(1000);

            if (m_bInitialized)
            {
                Parameters stParameter = (Parameters)obj;
                for (int i = 0; i < stParameter.m_nPeriod; i++)
                {
                    int      nTimes  = 1;
                    DateTime dtStart = DateTime.Now;
                    while (stParameter.m_nDuration > (DateTime.Now - dtStart).TotalSeconds)
                    {
                        ShowInfoBoard(nTimes, KeyboardMouseSimulateDriverAPI.KeyDown(stParameter.m_nKeyCode));
                        ShowInfoBoard(nTimes++, KeyboardMouseSimulateDriverAPI.KeyUp(stParameter.m_nKeyCode));

                        if (0 < stParameter.m_nInterval)
                        {
                            System.Threading.Thread.Sleep(stParameter.m_nInterval);
                        }
                    }
                }
            }

            ButtonControl(btnSimulate, true, "Simulate");
        }