Exemplo n.º 1
0
        private IntPtr captureKey(int nCode, IntPtr wp, IntPtr lp)
        {
            if (nCode >= 0)
            {
                KBDLLHOOKSTRUCT objKeyInfo = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lp, typeof(KBDLLHOOKSTRUCT));
                if (objKeyInfo.key == System.Windows.Forms.Keys.Right)
                {
                    System.Windows.Forms.Cursor.Position = new System.Drawing.Point(
                        MonitorManager.getMonitorCordX(0) + (int)(MonitorManager.getMonitorCord(0).Size.X / 2)
                        , MonitorManager.getMonitorCordY(0) + (int)(MonitorManager.getMonitorCord(0).Size.Y / 2));
                }
                if (objKeyInfo.key == System.Windows.Forms.Keys.Left)
                {
                    System.Windows.Forms.Cursor.Position = new System.Drawing.Point(MonitorManager.getMonitorCordX(1) + (int)(MonitorManager.getMonitorCord(1).Size.X / 2),
                                                                                    MonitorManager.getMonitorCordY(1) + (int)(MonitorManager.getMonitorCord(1).Size.Y / 2));
                }
            }


            return(CallNextHookEx(ptrHook, nCode, wp, lp));
        }