Esempio n. 1
0
        void MoveCursorAbsolute(int x, int y)
        {
            WinCursorClient.POINT p = new WinCursorClient.POINT();

            p.x = Convert.ToInt16(x);
            p.y = Convert.ToInt16(y);

            WinCursorClient.ClientToScreen(WinCursorClient.GetDesktopWindow(), ref p);
            WinCursorClient.SetCursorPos(p.x, p.y);
        }
Esempio n. 2
0
        private void Form1_Load(object senderl, EventArgs el)
        {
            mgr = new MouseGestureRecognition2();
            doubleClickTimer = new System.Timers.Timer();
            loopTimer        = new System.Timers.Timer();
            stopwatchTimer   = new System.Diagnostics.Stopwatch();

            System.Console.Out.WriteLine("Started program.");

            wsHandle = new WebSocket("ws://167.114.242.19/");

            // dodanie funkcji callback
            wsHandle.OnMessage += OnMessage;
            wsHandle.OnClose   += OnClose;
            wsHandle.OnError   += OnError;
            wsHandle.OnOpen    += OnOpen;

            // pobranie pozycji myszy
            WinCursorClient.POINT cursorPos = new WinCursorClient.POINT();
            WinCursorClient.GetCursorPos(ref cursorPos);
            posX = (double)cursorPos.x;
            posY = (double)cursorPos.y;

            // połączenie z serwerem
            EstablishConnection();

            // timer obsługujący podwójne kliknięcie
            doubleClickTimer           = new System.Timers.Timer();
            doubleClickTimer.AutoReset = false;
            doubleClickTimer.Elapsed  += (object sender, System.Timers.ElapsedEventArgs e) =>
            {
                WinCursorClient.POINT p = new WinCursorClient.POINT();
                WinCursorClient.GetCursorPos(ref p);
                WinCursorClient.mouse_event(WinCursorClient.MOUSEEVENTF_LEFTDOWN | WinCursorClient.MOUSEEVENTF_LEFTUP, (uint)p.x, (uint)p.y, 0, (System.UIntPtr) 0);
            };

            // timer obsługujący usługę rozpoznawania gestów
            mgrTimer = new System.Timers.Timer();
            int delay = 2;

            mgrTimer.Interval = delay;
            mgrTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) =>
            {
                mgr.TimerTick(delay);
            };
            // mgrTimer.Enabled = true;

            // timer obsługujący wyliczanie prędkości
            loopTimer.Interval = 30;
            loopTimer.Elapsed += LoopTimerTick;
            loopTimer.Start();
            stopwatchTimer.Start();
            prevTicks = stopwatchTimer.ElapsedTicks;
        }
Esempio n. 3
0
        void TriggerClick(string type)
        {
            WinCursorClient.POINT p = new WinCursorClient.POINT();
            WinCursorClient.GetCursorPos(ref p);

            switch (type)
            {
            case "left":
                WinCursorClient.mouse_event(WinCursorClient.MOUSEEVENTF_LEFTDOWN | WinCursorClient.MOUSEEVENTF_LEFTUP, (uint)p.x, (uint)p.y, 0, (System.UIntPtr) 0);
                break;

            case "right":
                WinCursorClient.mouse_event(WinCursorClient.MOUSEEVENTF_RIGHTDOWN | WinCursorClient.MOUSEEVENTF_RIGHTUP, (uint)p.x, (uint)p.y, 0, (System.UIntPtr) 0);
                break;

            case "doubleLeft":
                WinCursorClient.mouse_event(WinCursorClient.MOUSEEVENTF_LEFTDOWN | WinCursorClient.MOUSEEVENTF_LEFTUP, (uint)p.x, (uint)p.y, 0, (System.UIntPtr) 0);
                doubleClickTimer.Start();
                break;
            }
        }