private void Process(Keys key) { if (m_Display != null) { Screen s = null; if (key == Keys.D1 || key == Keys.NumPad1) { if (Screen.AllScreens.Length >= 0) { s = Screen.AllScreens[0]; } } if (key == Keys.D2 || key == Keys.NumPad2) { if (Screen.AllScreens.Length >= 1) { s = Screen.AllScreens[1]; } } if (key == Keys.D3 || key == Keys.NumPad3) { if (Screen.AllScreens.Length >= 2) { s = Screen.AllScreens[2]; } } if (key == Keys.D4 || key == Keys.NumPad4) { if (Screen.AllScreens.Length >= 3) { s = Screen.AllScreens[3]; } } if (key == Keys.D5 || key == Keys.NumPad5) { if (Screen.AllScreens.Length >= 4) { s = Screen.AllScreens[4]; } } if (key == Keys.D6 || key == Keys.NumPad6) { if (Screen.AllScreens.Length >= 5) { s = Screen.AllScreens[5]; } } if (key == Keys.D7 || key == Keys.NumPad7) { if (Screen.AllScreens.Length >= 6) { s = Screen.AllScreens[6]; } } if (key == Keys.D8 || key == Keys.NumPad8) { if (Screen.AllScreens.Length >= 7) { s = Screen.AllScreens[7]; } } if (key == Keys.D9 || key == Keys.NumPad9) { if (Screen.AllScreens.Length >= 8) { s = Screen.AllScreens[8]; } } CreateSplash(s.WorkingArea.Location.X, s.WorkingArea.Location.Y, s.WorkingArea.Width, s.WorkingArea.Height); m_Display.Dispose(); m_Display = null; } else if (m_F != null) { //Do not use Form width/height below. Need to use BackgroundImage.Width/Height instead. // float v1 = m_F.BackgroundImage.Width * (1.0F / 3.0F); float v2 = m_F.BackgroundImage.Width * (2.0F / 3.0F); float h1 = m_F.BackgroundImage.Height * (1.0F / 3.0F); float h2 = m_F.BackgroundImage.Height * (2.0F / 3.0F); if (key == Keys.D7 || key == Keys.NumPad7) { int x = (int)(v1 / 2.0F); int y = (int)(h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X, m_F.Location.Y, (int)v1, (int)h1); } else if (key == Keys.D8 || key == Keys.NumPad8) { int x = (int)(v1 + v1 / 2.0F); int y = (int)(h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X + (int)v1, m_F.Location.Y, (int)v1, (int)h1); } else if (key == Keys.D9 || key == Keys.NumPad9) { int x = (int)(v2 + v1 / 2.0F); int y = (int)(h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X + (int)v2, m_F.Location.Y, (int)v1, (int)h1); } else if (key == Keys.D4 || key == Keys.NumPad4) { int x = (int)(v1 / 2.0F); int y = (int)(h1 + h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X, m_F.Location.Y + (int)h1, (int)v1, (int)h1); } else if (key == Keys.D5 || key == Keys.NumPad5) { int x = (int)(v1 + v1 / 2.0F); int y = (int)(h1 + h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X + (int)v1, (int)m_F.Location.Y + (int)h1, (int)v1, (int)h1); } else if (key == Keys.D6 || key == Keys.NumPad6) { int x = (int)(v2 + v1 / 2.0F); int y = (int)(h1 + h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X + (int)v2, m_F.Location.Y + (int)h1, (int)v1, (int)h1); } else if (key == Keys.D1 || key == Keys.NumPad1) { int x = (int)(v1 / 2.0F); int y = (int)(h2 + h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X, m_F.Location.Y + (int)h2, (int)v1, (int)h1); } else if (key == Keys.D2 || key == Keys.NumPad2) { int x = (int)(v1 + v1 / 2.0F); int y = (int)(h2 + h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X + (int)v1, m_F.Location.Y + (int)h2, (int)v1, (int)h1); } else if (key == Keys.D3 || key == Keys.NumPad3) { int x = (int)(v2 + v1 / 2.0F); int y = (int)(h2 + h1 / 2.0F); SetCursorPos(m_F.Location.X + x, m_F.Location.Y + y); CreateSplash(m_F.Location.X + (int)v2, m_F.Location.Y + (int)h2, (int)v1, (int)h1); } else if (key == Keys.Return) { m_F.Close(); m_F.Dispose(); m_F = null; sendMouseDown(); } } if (key == Keys.LControlKey && m_LastKeyPressed == Keys.LControlKey) { m_LastKeyPressed = key; if (DateTime.Compare(m_LastKeyPressedTimeStamp.AddSeconds(1), DateTime.Now) < 0) { m_LastKeyPressedTimeStamp = DateTime.Now; } else { if (Screen.AllScreens.Length > 1) { m_Display = new OverLayDisplay(); m_Display.Show(); } else { CreateSplash(0, 0, Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height); } } } else { m_LastKeyPressed = key; m_LastKeyPressedTimeStamp = DateTime.Now; } }
private void HookManager_KeyUp(object sender, KeyEventArgs e) { Console.WriteLine(e.KeyCode.ToString()); if (m_Display != null) { if (e.KeyCode == Keys.D1 || e.KeyCode == Keys.NumPad1) { e.Handled = true; } else if (e.KeyCode == Keys.D2 || e.KeyCode == Keys.NumPad2) { e.Handled = true; } else if (e.KeyCode == Keys.D3 || e.KeyCode == Keys.NumPad3) { e.Handled = true; } else if (e.KeyCode == Keys.D4 || e.KeyCode == Keys.NumPad4) { e.Handled = true; } else if (e.KeyCode == Keys.D5 || e.KeyCode == Keys.NumPad5) { e.Handled = true; } else if (e.KeyCode == Keys.D6 || e.KeyCode == Keys.NumPad6) { e.Handled = true; } else if (e.KeyCode == Keys.D7 || e.KeyCode == Keys.NumPad7) { e.Handled = true; } else if (e.KeyCode == Keys.D8 || e.KeyCode == Keys.NumPad8) { e.Handled = true; } else if (e.KeyCode == Keys.D9 || e.KeyCode == Keys.NumPad9) { e.Handled = true; } else if (e.KeyCode == Keys.Return) { e.Handled = true; } else { m_Display.Dispose(); m_Display = null; } } else if (m_F != null) { if (e.KeyCode == Keys.D1 || e.KeyCode == Keys.NumPad1) { e.Handled = true; } else if (e.KeyCode == Keys.D2 || e.KeyCode == Keys.NumPad2) { e.Handled = true; } else if (e.KeyCode == Keys.D3 || e.KeyCode == Keys.NumPad3) { e.Handled = true; } else if (e.KeyCode == Keys.D4 || e.KeyCode == Keys.NumPad4) { e.Handled = true; } else if (e.KeyCode == Keys.D5 || e.KeyCode == Keys.NumPad5) { e.Handled = true; } else if (e.KeyCode == Keys.D6 || e.KeyCode == Keys.NumPad6) { e.Handled = true; } else if (e.KeyCode == Keys.D7 || e.KeyCode == Keys.NumPad7) { e.Handled = true; } else if (e.KeyCode == Keys.D8 || e.KeyCode == Keys.NumPad8) { e.Handled = true; } else if (e.KeyCode == Keys.D9 || e.KeyCode == Keys.NumPad9) { e.Handled = true; } else if (e.KeyCode == Keys.Return) { e.Handled = true; } else { m_F.Dispose(); m_F = null; } } Process(e.KeyCode); }