| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- using DreamCheeky;
- using WindowsInput;
- using WindowsInput.Native;
- namespace Test.Application
- {
- class Program
- {
- [DllImport("user32.dll")]
- private static extern bool SetForegroundWindow(IntPtr hWnd);
- static void Main()
- {
- InputSimulator inputSimulator = new InputSimulator();
- using (var bigRedButton = new BigRedButton())
- {
- bigRedButton.LidOpen += (sender, args) => {
- var prc = Process.GetProcessesByName("idea64");
- if (prc.Length > 0)
- {
- SetForegroundWindow(prc[0].MainWindowHandle);
- }
- };
- bigRedButton.ButtonPressed += (sender, args) =>
- {
- var prc = Process.GetProcessesByName("idea64");
- if (prc.Length > 0)
- {
- SetForegroundWindow(prc[0].MainWindowHandle);
- inputSimulator.Keyboard.KeyDown(VirtualKeyCode.SHIFT);
- inputSimulator.Keyboard.KeyPress(VirtualKeyCode.F9);
- inputSimulator.Keyboard.KeyUp(VirtualKeyCode.SHIFT);
- }
-
- };
- bigRedButton.LidClosed += (sender, args) =>
- {
- var prc = Process.GetProcessesByName("idea64");
- if (prc.Length > 0)
- {
- inputSimulator.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
- inputSimulator.Keyboard.KeyPress(VirtualKeyCode.F2);
- inputSimulator.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
- }
- };
- bigRedButton.Start();
- Console.WriteLine("Press ENTER to exit");
- Console.ReadLine();
- }
- }
- }
-
- }
|