Пример #1
0
 public void Engage()
 {
     //MessageBox.Show("Engagged");
     Disengage();
     keyboardHook = new KeyboardHook();
     keyboardHook.KeyIntercepted += new KeyboardHook.KeyboardHookEventHandler(keyboardHook_KeyIntercepted);
 }
Пример #2
0
        public void Start()
        {
            Logger.LogInfo("Starting game: Path: '{0}', Arguments '{1}', Working Directory '{2}'", gamePath.Path, gamePath.Arguments, gamePath.WorkingDirectory);

            initProcess();
            OnStarting();
            runCommand(emulatorProfile.PreCommand, emulatorProfile.PreCommandWaitForExit, emulatorProfile.PreCommandShowWindow);

            if (!string.IsNullOrEmpty(emulatorProfile.LaunchedExe))
            {
                try { launchedExe = System.IO.Path.GetFileNameWithoutExtension(emulatorProfile.LaunchedExe); }
                catch { launchedExe = emulatorProfile.LaunchedExe; }
                ignoredProcessIds = Process.GetProcessesByName(launchedExe).Select(p => p.Id).ToList();
            }

            if (!tryStartProcess())
            {
                OnStartFailed();
                return;
            }

            if (mappedKeyData > 0)
            {
                Logger.LogDebug("Initialising keyboard hook, Process Id: {0}", process.Id);
                keyHook = new KeyboardHook(process.Id, onMappedKey); //setup hook and attach to emu process
            }

            OnStarted();
        }
Пример #3
0
            internal KeyWaitCommand(KeyboardHook keyboardHook)
            {
                if (keyboardHook == null)
                    throw new ArgumentNullException("keyboardHook");

                _keyboardHook = keyboardHook;
            }
Пример #4
0
 void keyboardHook_KeyIntercepted(KeyboardHook.KeyboardHookEventArgs e)
 {
     try
     {
         switch (e.KeyCode)
         {
             case 118://F7
                 voiceControl.OnRewindClick();
                 e.PassThrough = false;
                 break;
             case 119://F8
                 voiceControl.OnForwardClick();
                 e.PassThrough = false;
                 break;
             case 120://F9
                 if (voiceControl.CurrentState == VoiceControl.State.PLAY)
                     voiceControl.OnPauseClick();
                 else
                     voiceControl.OnPlayClick();
                 e.PassThrough = false;
                 break;
             default:
                 e.PassThrough = true;
                 break;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace);
     }
 }
Пример #5
0
 static Keyboard()
 {
     Hook = new KeyboardHook();
     Hook.Start();
     Application.ApplicationExit += new EventHandler(OnApplicationExit);
     AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
 }
Пример #6
0
        internal KeySetForm()
        {
            this.result = Result.CANCEL;
            this.keyType = KeyType.SINGLE;
            KeyPreview = true;
            InitializeComponent();

            this._keyboardHook = new KeyboardHook();
            this._keyboardHook.KeyboardHooked += KeyHookEvent;
        }
Пример #7
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            kh = new KeyboardHook();
            kh.SetHook();
            kh.OnKeyDownEvent += kh_OnKeyDownEvent;

            nowstate.TextColor = Color.Green;
            nowstate.Text = "Catching";
            timer.Interval = 1;
            timer.Enabled = true;
        }
Пример #8
0
		public GlobalHooks(IntPtr Handle)
		{
			_Handle = Handle;

			_CBT = new CBTHook(_Handle);
			_Shell = new ShellHook(_Handle);
			_Keyboard = new KeyboardHook(_Handle);
			_Mouse = new MouseHook(_Handle);
			_KeyboardLL = new KeyboardLLHook(_Handle);
			_MouseLL = new MouseLLHook(_Handle);
			_CallWndProc = new CallWndProcHook(_Handle);
			_GetMsg = new GetMsgHook(_Handle);
		}
Пример #9
0
        public MainWindow()
        {
            InitializeComponent();

            autoComplete = new ObservableCollection<Entry>();

            notifyIcon = new NotifyIcon();
            notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); // new System.Drawing.Icon(@"C:\icon.ico");
            notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyIcon_MouseClick);
            notifyIcon.MouseDoubleClick += notifyIcon_MouseDoubleClick;
            notifyIcon.Visible = true;
            hook = new KeyboardHook();
            hook.RegisterHotKey(ModifierKeys.Control, Keys.Space);
            hook.KeyPressed += hook_KeyPressed;

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMinutes(5);
            timer.Tick += timer_Tick;
            timer.Start();

            DataContext = this;

            load();

            autoComplete.CollectionChanged += AutoComplete_CollectionChanged;

            //Custom entries
            var c = new[] {
                new Entry() { Title = "Mouse", Command = "main.cpl" },
                new Entry() { Title = "Add/Remove Programs", Command = "appwiz.cpl" },
                new Entry() { Title = "Date/Time Properties", Command = "timedate.cpl" },
                new Entry() { Title = "Display Properties", Command = "desk.cpl" },
                new Entry() { Title = "Sound Properties", Command = "mmsys.cpl" },
             //   new Entry() { Title = "Sky Drive", Command = @"C:\Users\marpe\SkyDrive\Dokument" }, absolute paths won't turn out well...
            };

            var cm = new System.Windows.Forms.ContextMenu();
            cm.MenuItems.Add("Show Entries", (x, y) => { showList(); });
            cm.MenuItems.Add("Add File Entry", (x, y) => { AddNewFileEntry(); });
            cm.MenuItems.Add("Add Directory Entry", (x, y) => { AddNewDirectoryEntry(); });
            cm.MenuItems.Add("Close", (x, y) => { System.Windows.Application.Current.Shutdown(); });
            notifyIcon.ContextMenu = cm;

            foreach (var e in c)
                AddEntry(e, false);

            _instance = this;
        }
Пример #10
0
        public Shortcuts(string commandLists)
        {
            InitializeComponent();

            this.CommandLists = commandLists;

            this.ShowInTaskbar   = false;
            this.ShowIcon        = false;
            this.BackColor       = Color.Black;
            this.Opacity         = 0.7D;
            this.FormBorderStyle = FormBorderStyle.None;
            this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea; // For not covering the taskbar

            KeyboardHook.CreateHook();
            KeyboardHook.KeyPressed += KeyboardHook_KeyPressed;
        }
Пример #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            kh = new KeyboardHook();
            kh.Blocked_Keys.Add(key1);
            kh.Blocked_Keys.Add(key2);
            kh.OnKeyDownEvent += KeyDownX;
            kh.OnKeyUpEvent   += KeyUpX;
            new ConsoleHelper(this.textBox3);
            base_time = DateTime.Now;
            rce.ResultsCalculatedEvent += Recognized;
            rce.add_gesture("circle.xml");
            rce.add_gesture("N.xml");


            kh.SetHook();
        }
Пример #12
0
        //private const string KEY_ErrorStateText_NULL = "设备之间连接已被用户断开..";
        //private const string KEY_ErrorStateText_Normal = "打开手机进行投屏吧";
        //private const string KEY_ErrorStateText_Outtime = "因为超时断开连接...";
        //private const string KEY_ErrorStateText_MYdisconnect = "主动断开连接...";

        public MainViewModel(MainWindow view)
            : base(view)
        {
            // g_MainWindow = this;
            _view        = view;
            ComputerName = Dns.GetHostName();
            Start();

            _mainTimer           = new DispatcherTimer();
            _mainTimer.Interval  = TimeSpan.FromSeconds(5);
            _mainTimer.Tick     += new EventHandler(dTimer_Tick);
            _mainTimer.IsEnabled = true;
            k_hook = new KeyboardHook();
            k_hook.KeyDownEvent += new System.Windows.Forms.KeyEventHandler(hook_KeyDown); //钩住键按下
            k_hook.Start();                                                                //安装键盘钩子
        }
Пример #13
0
 private void RegisterMultimedaKeys()
 {
     _keyboardhook             = new KeyboardHook();
     _keyboardhook.KeyPressed += _keyboardhook_KeyPressed;
     try
     {
         _keyboardhook.RegisterHotKey(AppLib.Common.ModifierKeys.None, System.Windows.Forms.Keys.MediaPlayPause);
         _keyboardhook.RegisterHotKey(AppLib.Common.ModifierKeys.None, System.Windows.Forms.Keys.MediaStop);
         _keyboardhook.RegisterHotKey(AppLib.Common.ModifierKeys.None, System.Windows.Forms.Keys.MediaNextTrack);
         _keyboardhook.RegisterHotKey(AppLib.Common.ModifierKeys.None, System.Windows.Forms.Keys.MediaPreviousTrack);
     }
     catch (Exception ex)
     {
         Helpers.ErrorDialog(ex, Properties.Resources.MainWin_ErrorMediaKeys);
     }
 }
Пример #14
0
 public FrmMain()
 {
     InitializeComponent();
     btnRemoveAction.BackColor = btnAddAction.BackColor = System.Drawing.Color.Transparent;
     btnRemoveAction.Parent    = btnAddAction.Parent = lstActions;
     KeyboardHook             = new KeyboardHook();
     KeyboardHook.KeyPressed += KeyboardHook_KeyPressed;
     KeyboardHook.Start();
     MouseButtonHook             = new MouseHook(true);
     MouseButtonHook.MouseMoved += MouseButtonHook_MouseMoved;
     MouseButtonHook.Start();
     AudioDetect = new AudioDetect(0);
     AudioDetect.AudioDetected += AudioDetect_AudioDetected;
     AudioDetect.Start();
     IsActivated = false;
 }
        public botControl(string emRunning, string emControlSetting, string profile)
        {
            Console.WriteLine("Bot created..\r");

            //Adding keyboard event handlers and installing the hook
            KeyboardHook.KeyDown += new KeyboardHook.KeyDownEventHandler(KeyboardHook_KeyDown);
            KeyboardHook.KeyUp   += new KeyboardHook.KeyUpEventHandler(KeyboardHook_KeyUp);
            KeyboardHook.InstallHook();

            // Initalize random
            randnum = new Random();

            this.emulatorRunning        = emRunning;
            this.emulatorControlSetting = emControlSetting;
            this.profileName            = profile;

            if (this.emulatorControlSetting == "NES-NOSTART")
            {
                useStartButton = false;
                this.emulatorControlSetting = "NES";
            }
            if (this.emulatorControlSetting == "NES-START")
            {
                useStartButton = true;
                this.emulatorControlSetting = "NES";
            }


            if (this.emulatorRunning == "custom")
            {
                this.customEmulatorName = emControlSetting;
            }

            Console.WriteLine("emulator running: " + this.emulatorRunning + "\r");
            Console.WriteLine("emulator control setting: " + this.emulatorControlSetting + "\r");

            buildEmuControlList();
            getEmulatorHandle();

            Console.WriteLine("Handle: " + handle);


            botRun = new Thread(new ThreadStart(botCommandRun));

            // Begin the control.
            botRun.Start();
        }
Пример #16
0
        public ApplicationViewModel()
        {
            try
            {
                Load();
            }
            catch
            {
                ViewSettings = new ViewSettings();
            }

            Actions = Assembly.GetExecutingAssembly()
                      .GetTypes()
                      .Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(FlexAction <>))
                      .Select(type => type.GetConstructor(new Type[0]))
                      .Select(constructor => (IFlexAction)constructor.Invoke(new object[0]))
                      .ToList();

            foreach (var action in Actions)
            {
                foreach (var config in Configs)
                {
                    if (action.Config.GetType() == config.GetType())
                    {
                        action.Config = config;
                        break;
                    }
                }
            }
            Configs = Actions.Select(action => action.Config).ToList();

            keyboardHook          = new KeyboardHook();
            keyboardHook.KeyDown += (s, e) =>
            {
                foreach (var action in Actions)
                {
                    if (action.Config.Activator == e.KeyCode)
                    {
                        action.Toggle();
                    }
                }
            };

            keyboardHook.Hook();
            App.Current.Exit += (s, e) => Save();
        }
Пример #17
0
        public void EnableKeyboardHook(KeyboardShortcut shortcut)
        {
            if (shortcut.Enabled)
            {
                if (_hooks != null)
                {
                    _hooks.Dispose();
                }

                _hooks = KeyboardHook.Hook(shortcut, HandleShortcut);
            }
            else if (_hooks != null)
            {
                _hooks.Dispose();
                _hooks = null;
            }
        }
Пример #18
0
 public void AbreTela()
 {
     if (formo == true)
     {
     }
     else
     {
         formo = true;
         KeyboardHook kb = new KeyboardHook();
         kb.HookKeyboard();
         this.Show();
         richTextBox1.Refresh();
         textBox1.Refresh();
         button1.Refresh();
         label1.Refresh();
     }
 }
Пример #19
0
        private void SetupNavigation()
        {
            currentDispatcher = Dispatcher.CurrentDispatcher;
            openMenu          = (Storyboard)TryFindResource("MenuOpen");
            closeMenu         = (Storyboard)TryFindResource("MenuClose");
            noticeMe          = (Storyboard)TryFindResource("NoticeMe");

            searchPage = new SearchPage(this);
            searchPage.OcrFinishedEvent += OnSearchPageOcrFinishedEvent;
            contentFrame.Navigate(searchPage);

            ChangeReadMode();

            App.KeyboadHook             = KeyboardHook.GetInstance();
            App.KeyboadHook.KeyPressed += KeyPressed;
            SnippingTool.AreaSelected  += SnippingToolOnAreaSelected;
        }
Пример #20
0
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Microsoft.ApplicationInsights.TelemetryClient tc = new TelemetryClient(TelemetryConfiguration.CreateDefault());
            tc.InstrumentationKey = "0270dc4e-ba5a-48e2-9f1d-aac8a1b632c3";

            //TimeMarkerConfiguration = SkyhoshiApplicationConfigurationBuilder.CreateLoadSettingsFromDefaultLocations();



            TimeMarkerConfiguration.Load();


            KeyBindingHook = new KeyboardHook();
            frmSettingsMain mainForm = new frmSettingsMain();

            KeyBindingHook.RegisterHotKey(ModifierKeys.Control, Keys.K);
            KeyBindingHook.KeyPressed += (sender, args) =>
            {
                if (TimeMarkerConfiguration.BringAnyOpenWindowToFrontOnShortcutKeyPressed)
                {
                    mainForm.Activate();
                    mainForm.Focus();
                    mainForm.BringToFront();
                }

                if (TimeMarkerConfiguration.AllowAnyMessageBoxOnShortcutKeyPressed)
                {
                    Skyhoshi.Windows.Forms.Diagnostics.DebugMessageBox(mainForm);
                }
                System.Diagnostics.Debug.WriteLine($"Shortcut Key's pressed");
            };


            Application.Run(mainForm);
            Application.Idle += (sender, args) =>
            {
                //backup database
            };
            //Application.Run(new frmSettingsMain());
            //Application.Run(new frmSettingsMain());
            //Application.Run(new frmSettingsMain());
            Application.ApplicationExit += Application_ApplicationExit;
        }
Пример #21
0
        public MainForm()
        {
            InitializeComponent();

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            this.StartPosition = FormStartPosition.CenterScreen;

            hook       = new KeyboardHook();
            hotkeyDict = new Dictionary <string, int>();
            hotkeyDict.Add("Ctrl + Alt + C", (int)Keys.Control + (int)Keys.Alt);
            hotkeyDict.Add("Shift + Alt + C", (int)Keys.Shift + (int)Keys.Alt);
            hotkeyDict.Add("Shift + C", (int)Keys.Shift);
            hotkeyDict.Add("Alt + C", (int)Keys.Alt);

            // Upgrade Config
            if (Properties.Settings.Default.UpdateSettings)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpdateSettings = false;
                Properties.Settings.Default.Save();
            }

            // Set HotkeyComboBox Items
            foreach (string key in hotkeyDict.Keys)
            {
                this.hotkeyComboBox.Items.Add(key);
            }

            // Set HotkeyComboBox Key Actions
            this.hotkeyComboBox.KeyDown  += (s, e) => e.Handled = true;
            this.hotkeyComboBox.KeyPress += (s, e) => e.Handled = true;
            this.hotkeyComboBox.KeyUp    += (s, e) => e.Handled = true;

            // Get Settins
            this.bootCheckBox.Checked         = this.BootToolStripMenuItem.Checked = Properties.Settings.Default.boot;
            this.hotkeyComboBox.Text          = Properties.Settings.Default.hotkey;
            this.hotkeyCheckBox.Checked       = this.HotkeyToolStripMenuItem.Checked = Properties.Settings.Default.hotkeyCheck;
            this.urlText.Text                 = Properties.Settings.Default.url;
            this.titleTextBox.Text            = Properties.Settings.Default.title;
            this.defaultTitleCheckBox.Checked = Properties.Settings.Default.titleCheck;
            this.contentTextBox.Text          = Properties.Settings.Default.content;
            this.clipContentCheckBox.Checked  = Properties.Settings.Default.contentCheck;
            this.autoCopyCheckBox.Checked     = Properties.Settings.Default.autoCopyCheck;
            this.notifyCheckBox.Checked       = this.NotifyToolStripMenuItem.Checked = Properties.Settings.Default.notifyCheck;
        }
Пример #22
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            AudioManager.instance.Close();
            if (LoopbackRecorder.Recording)
            {
                LoopbackRecorder.StopRecording(false);
            }

            if (this.MuteOutput.IsChecked != null)
            {
                Properties.Settings.Default.Muted = (bool)this.MuteOutput.IsChecked;
            }
            KeyboardHook.Unhook();

            Properties.Settings.Default.Save = GenerateJson();
            Properties.Settings.Default.Save();
        }
Пример #23
0
        static void Main(string[] args)
        {
            var processLurker = new PathOfExileProcessLurker();
            var processId     = processLurker.WaitForProcess().Result;

            var hook = new KeyboardHook(processId);

            hook.AddHandler('F', Hook_MessageReceived);
            //hook.MessageReceived += Hook_MessageReceived;

            hook.InstallAsync().Wait();

            while (true)
            {
                Thread.Sleep(200);
            }
        }
Пример #24
0
 public static bool ToggleHotkey(Form which, bool onlyRemove = false)
 {
     for (var i = 0; i < hotkeys.Count; i++)
     {
         if (hotkeys[i].active)
         {
             hotkeys[i].active = false;
             KeyboardHook.UnregisterHotKey(which.Handle, hotkeys[i].id);
         }
         else if (!onlyRemove)
         {
             hotkeys[i].active = true;
             KeyboardHook.RegisterHotKey(which.Handle, hotkeys[i].id, (int)hotkeys[i].modifier, hotkeys[i].key.GetHashCode());
         }
     }
     return(true);
 }
Пример #25
0
        public MainWorkItem()
        {
            AMSetttingsFactory.WorkItem = this;
            _Settings = AMSetttingsFactory.DefaultSettingsBag.Settings;
            _Commands = new AppCommands(this);
            _KbrdHook = new KeyboardHook();

//#if RELEASE
            //_MsHook = new MouseHook();
//#endif
            _ImageLoader  = new AsyncImageLoader();
            _MainWindow   = new MainWindow(this);
            _TrayIcon     = new WinForms.NotifyIcon();
            _AppData      = new AppGroup();
            _RecycleBin   = new DeletedAppCollection();
            UpdateRunning = false;
        }
Пример #26
0
        private void MainFormFormClosing(object sender, FormClosingEventArgs e)
        {
            Settings.Default["Opacity"] = Opacity;
            Settings.Default.Save();
            Settings.Default.Upgrade();

            if (mouseHook != null)
            {
                mouseHook.Dispose();
                mouseHook = null;
            }
            if (keyboardHook != null)
            {
                keyboardHook.Dispose();
                keyboardHook = null;
            }
        }
Пример #27
0
        public MainWindow(string dataPath, string configPath)
        {
            if (!Directory.Exists(dataPath))
            {
                throw new FileNotFoundException(dataPath);
            }
            if (!File.Exists(configPath))
            {
                throw new FileNotFoundException(configPath);
            }

            DataPath   = dataPath;
            ConfigPath = configPath;

            InitializeComponent();

            CurrentTickTimeBadBrush  = new SolidColorBrush(Color.FromRgb(255, 0, 80));
            CurrentTickTimeGoodBrush = new SolidColorBrush(Color.FromRgb(160, 255, 0));
            DarkForegroundBrush      = new SolidColorBrush((Color)FindResource("DarkForeground"));
            DarkBackgroundBrush      = new SolidColorBrush((Color)FindResource("DarkBackground"));
            TextAccentBrush          = new SolidColorBrush((Color)FindResource("TextAccent"));

            NotificationGmBrush          = new(Colors.Cyan);
            NotificationBrush            = new(Colors.Pink);
            NotificationWhiteBrush       = new(Colors.White);
            NotificationTransparentBrush = new(Colors.Transparent);

            CurrentTickTimeBadBrush.Freeze();
            CurrentTickTimeGoodBrush.Freeze();
            DarkForegroundBrush.Freeze();
            DarkBackgroundBrush.Freeze();
            TextAccentBrush.Freeze();

            NotificationGmBrush.Freeze();
            NotificationBrush.Freeze();
            NotificationWhiteBrush.Freeze();
            NotificationTransparentBrush.Freeze();

            LabelUpdateEvent = new(TimeSpan.FromSeconds(1));

            RenderState = true;

            KeyboardHook = new KeyboardHook();
            KeyboardHook.Enable();
        }
Пример #28
0
        private async void keyboardButton_Click(object sender, EventArgs e)
        {
            if (!_keyboardHookInstalled)
            {
                if (_process == null || _process.HasExited)
                {
                    if (Environment.Is64BitOperatingSystem && (radio32bit.IsChecked ?? false))
                    {
                        _process = Process.Start(@"c:\windows\syswow64\notepad.exe");
                    }
                    else
                    {
                        _process = Process.Start(@"c:\windows\notepad.exe");
                    }
                }

                if (_keyboardHook == null)
                {
                    _keyboardHook = new KeyboardHook(_process.Id);
                }
                else
                {
                    _keyboardHook.RemoveAllHandlers();
                }

                _keyboardHook.MessageReceived += KeyboardHook_MessageReceived;
                _keyboardHook.AddHandler(KeyCode.F, KeyboardHook_Test);
                _keyboardHook.AddHandler(KeyCode.F, Modifiers.Shift, KeyboardHook_Test);
                _keyboardHook.AddHandler(KeyCode.Y, Modifiers.ControlShift, KeyboardHook_Test);
                _keyboardHook.AddHandler(KeyCode.U, Modifiers.Shift | Modifiers.RightControl, KeyboardHook_Test);
                _keyboardHook.AddHandler(KeyCode.N, Modifiers.AltControlShift, KeyboardHook_Test);
                _keyboardHook.AddHandler(KeyCode.T, KeyboardHook_Test);
                keyboardButton.Content = "Installing hook...";
                await _keyboardHook.InstallAsync();

                _keyboardHookInstalled = true;
                keyboardButton.Content = "Keyboard Unhook";
            }
            else
            {
                _keyboardHook.Uninstall();
                _keyboardHookInstalled = false;
                keyboardButton.Content = "Keyboard Hook";
            }
        }
Пример #29
0
        /// <summary> Sets app behaviour on tray icon click and hotkey  </summary>
        private void setWindowVisibilityBehaviour(bool toShowBalloonTip = false)
        {
            if (DataManager.Configuration.ToDisplayListOnHotkey)
            {
                if (_hook == null)
                {
                    try
                    {
                        _hook = new KeyboardHook();
                        // Register the event that is fired after the key press
                        _hook.KeyPressed += hook_KeyPressed;
                        // Register the Ctrl+Alt+S combination as hotkey (Alt Gr = Ctrl+Alt)
                        _hook.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Alt, Keys.S);
                    }
                    catch (InvalidOperationException exception)
                    {
                        MessageBox.Show(exception.Message);
                        LogHelper.SaveError(exception);
                    }
                }
            }
            else
            {
                if (_hook != null)
                {
                    _hook.Dispose();
                    _hook = null;
                }
            }

            if (toShowBalloonTip)
            {
                if (!DataManager.Configuration.ToDisplayListOnTextFocus)
                {
                    _notifyIcon.BalloonTipIcon  = ToolTipIcon.Info;
                    _notifyIcon.BalloonTipTitle = Constants.ProgramName;
                    _notifyIcon.BalloonTipText  = @"Word List will appear on tray icon click";
                    if (DataManager.Configuration.ToDisplayListOnHotkey)
                    {
                        _notifyIcon.BalloonTipText += @" or ""Ctrl+Alt+S"" hotkey";
                    }
                    _notifyIcon.ShowBalloonTip(3000);
                }
            }
        }
Пример #30
0
        private void ButtonConfig_Click(object sender, RoutedEventArgs e)
        {
            ConfigEditorWindow configWindow = new(DataPath, AmeisenBot, AmeisenBot.Config, AmeisenBot.AccountName);

            configWindow.ShowDialog();

            if (configWindow.SaveConfig)
            {
                AmeisenBot.ReloadConfig(configWindow.Config);
                File.WriteAllText(AmeisenBot.Config.Path, JsonSerializer.Serialize(configWindow.Config, new JsonSerializerOptions()
                {
                    WriteIndented = true
                }));

                KeyboardHook.Clear();
                LoadHotkeys();
            }
        }
        public static void Stop()
        {
            if (_IsRunning)
            {
                lock (_Accesslock)
                {
                    if (_kh != null)
                    {
                        _kh.KeyDown -= new RawKeyEventHandler(KListener);
                        _kh.Stop();
                        _kh = null;
                    }

                    _kQueue.Add(false);
                    _IsRunning = false;
                }
            }
        }
Пример #32
0
 private void Form1_Load(object sender, EventArgs e)
 {
     keyboardHook = new KeyboardHook();
     keyboardHook.KeyDownEvent  += new System.Windows.Forms.KeyEventHandler(hook_KeyDown);
     keyboardHook.KeyPressEvent += hook_KeyPressEvent;
     try
     {
         keyboardHook.Start();//安装键盘钩子
     }
     catch (Exception)
     {
         throw;
     }
     AddListView("Alt+R", "模拟一次 左 键按下并抬起");
     AddListView("Alt+S", "模拟一次 右 键按下并抬起");
     AddListView("Alt+F1", "记录当前鼠标位置并设置点击快捷方式");
     AddListView("Alt+F2", "按下快捷方式按键");
 }
Пример #33
0
        static void Main()
        {
            //Register our custom ogg reader
            CodecFactory.Instance.Register("ogg-vorbis", new CodecFactoryEntry(s => new NVorbisSource(s).ToWaveSource(), ".ogg"));

            using (FileManager.Instance = new FileManager())
                using (Player.MusicManager.Instance = new Player.MusicManager())
                    using (KeyboardHook hook = new KeyboardHook(Player.MusicManager.GetHookKeys()))
                    {
                        Playlist.PlaylistManager.Instance.Initialize();

                        hook.RegisteredKeyPressed += Player.MusicManager.Instance.RegisteredKeyPressed;

                        App app = new App();
                        app.InitializeComponent();
                        app.Run();
                    }
        }
Пример #34
0
        /// <summary>
        /// Stop watching
        /// </summary>
        public static void Stop()
        {
            if (isRunning)
            {
                lock (accesslock)
                {
                    if (keyboardHook != null)
                    {
                        keyboardHook.KeyDown -= new RawKeyEventHandler(KListener);
                        keyboardHook.Stop();
                        keyboardHook = null;
                    }

                    keyQueue.Add(false);
                    isRunning = false;
                }
            }
        }
Пример #35
0
        static void Main(string[] args)
        {
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                timer          = new Timer();
                timer.Interval = 1000;
                timer.Tick    += new EventHandler(OnTick);
                timer.Start();

                Console.WriteLine("Hiding taskbar");
                Console.WriteLine("Press ALT + T to toggle visiblilty or ALT + Q to exit ...");
                ShowTaskbar(visible);
                var kh = new KeyboardHook(true);
                kh.KeyDown += Kh_KeyDown;
                Application.Run();
                mutex.ReleaseMutex();
            }
        }
Пример #36
0
 protected virtual void Dispose(bool native)
 {
     if (Player.Instance != null)
     {
         Player.Instance.Dispose();
     }
     if (_keyboardhook != null)
     {
         _keyboardhook.Dispose();
         _keyboardhook = null;
     }
     if (App.NotifyIcon != null)
     {
         App.NotifyIcon.Dispose();
         App.NotifyIcon = null;
     }
     GC.SuppressFinalize(this);
 }
Пример #37
0
        private void fMediaPlayer_FormClosing(object sender, FormClosingEventArgs e)
        {
            PauseMusic();
            MediaPlayer.SaveSettings();
            MediaPlayer.SaveCustomSettings();

            if (MediaPlayer.list.Any())
            {
                MediaPlayer.currentPosition = WMP.Ctlcontrols.currentPosition;
                MediaPlayer.SaveListSettings();
                MediaPlayer.SaveList();
            }

            WMP.close();
            // HOOK SPACE
            KeyboardHook.UnInstallHook();
            MouseHook.UnInstallHook();
        }
Пример #38
0
        public MainFrm()
        {
            InitializeComponent();

            _connected    = Connected;
            _disconnected = Disconnected;
            _haltables    = new List <IHaltable>();
            _receivers    = new List <IReceiver>();
            _actions      = new Dictionary <Keys, Action>();
            _avatarCache  = new Dictionary <string, Bitmap>();
            _userCache    = new Dictionary <HHotel, Dictionary <string, HUser> >();

            In                       = new Incoming();
            Out                      = new Outgoing();
            GameData                 = new HGameData();
            Connection               = new HConnection();
            Connection.Connected    += Connected;
            Connection.DataOutgoing += HandleData;
            Connection.DataIncoming += HandleData;
            Connection.Disconnected += Disconnected;

            Hook = new KeyboardHook();
            Hook.HotkeyActivated += Hook_HotkeyActivated;

            ConnectionPg = new ConnectionPage(this, ConnectionTab);
            InjectionPg  = new InjectionPage(this, InjectionTab);
            ToolboxPg    = new ToolboxPage(this, ToolboxTab);
            ModulesPg    = new ModulesPage(this, ModulesTab);
            AboutPg      = new AboutPage(this, AboutTab);

            PacketLoggerUI = new PacketLoggerFrm(this);

            _haltables.Add(ModulesPg);
            _haltables.Add(PacketLoggerUI);
            _haltables.Add(InjectionPg.FiltersPg);
            _haltables.Add(InjectionPg.SchedulerPg);

            _receivers.Add(ModulesPg);
            _receivers.Add(InjectionPg.FiltersPg);
            _receivers.Add(ConnectionPg);
            _receivers.Add(PacketLoggerUI);

            Connection.ListenPort = (int)Program.Settings["ConnectionListenPort"];
        }
        private void SetupNavigation()
        {
            currentDispatcher = Dispatcher.CurrentDispatcher;
            openMenu          = (Storyboard)TryFindResource("MenuOpen");
            closeMenu         = (Storyboard)TryFindResource("MenuClose");
            noticeMe          = (Storyboard)TryFindResource("NoticeMe");

            searchPage = new SearchPage(this);
            searchPage.OcrFinishedEvent += OnSearchPageOcrFinishedEvent;
            contentFrame.Navigate(searchPage);

            ChangeReadMode();

            App.KeyboadHook             = KeyboardHook.GetInstance();
            App.KeyboadHook.KeyPressed += KeyPressed;
            SnippingTool.AreaSelected  += SnippingToolOnAreaSelected;

            App.NlpJdictService = NetTcp.NetTcpHelper.CreateNetNamedPipeServer(SearchTextFromAnotherProcess);
        }
Пример #40
0
 static void Main()
 {
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         //Application.Run(new frm_Splash());
         using (kh = new KeyboardHook())
         {
             Application.Run(new MainForm());
         }
         Fonction.blocageGestionnaireDesTaches(false);
         Fonction.blocageChangementMotDePasse(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Program : plantage !!" + ex.ToString());
     }
 }
Пример #41
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var hook = new KeyboardHook();

            try
            {
                hook.KeyPressed += (_, __) =>
                {
                    // Activate it if it's already there, otherwise create a new one.
                    if (RunWindow != null)
                    {
                        RunWindow.Activate();
                    }
                    else
                    {
                        RunWindow = new Run();
                        RunWindow.ShowDialog();
                        RunWindow = null;
                    }
                };

                hook.RegisterHotKey(ModifierKeys.Win, GetHotkey(args));
            }
            catch
            {
                MessageBox.Show("Unable to register the global hotkey Win+" + GetHotkey(args) + ".\r\n\r\nCheck to " +
                                "make sure that the key combination is not already in use by " +
                                "Windows or another application, and that PSRunner is not " +
                                "already running. Only one instance of PSRunner may run at a time.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }

            Application.Run();

            hook.Dispose();
        }
Пример #42
0
    public main()
    {
        //constructor.
        //dont delete this line. It creates all the GUI stuff.
        //Check the main.designer.cs to see GUI code.
        InitializeComponent();

        //The following sets up a hook as soon as the program is launched.
        KeyboardHookInstance = new KeyboardHook();
        KeyboardHookInstance.KeyIntercepted += new KeyboardHookCaptureHandler(KeyboardHookInstance_KeyIntercepted);

        //Create a timer for checking for updates
        System.Threading.Timer tm = new System.Threading.Timer(new TimerCallback(timerProcCallBack));
        tm.Change(10000, 600000);

        //Configure the background worker.
        bg = new BackgroundWorker();
        bg.WorkerReportsProgress = false;
        bg.DoWork += new DoWorkEventHandler(bg_DoWork);
    }
Пример #43
0
 private void setupHook()
 {
     hook = new KeyboardHook();
     hook.RegisterHotKey(ModifierKeys.Control, Keys.Space);
     hook.KeyPressed += hook_KeyPressed;
 }
Пример #44
0
        /// <summary>
        /// コンストラクタ
        /// コンポーネント初期化のほかに、変数の初期化、設定リストの読み込み、タイマーのスタート、キーフックのスタートを行う
        /// </summary>
        internal MainForm()
        {
            InitializeComponent();
            this._logging = new Common.Logging( "main.log" );
            this._hotKeys = new Dictionary<byte, string>();

            LoadSettingList();

            if( Properties.Settings.Default.activeWindowMonitoring ) {
                this.timerActiveWindowCheck.Interval = Properties.Settings.Default.activeWindowMonitoringinterval;
                this.timerActiveWindowCheck.Start();
            }

            var keyboardHook = new KeyboardHook();
            keyboardHook.KeyboardHooked += KeyHookEvent;

            Application.ApplicationExit += Application_ApplicationExit;
            this._massLoaded = true;
            this._formLoaded = true;
        }
Пример #45
0
    // Use this for initialization
    void Start()
    {
        UnityEngine.Screen.showCursor = false;
        try{
            configFile = ReadJson(localJsonPath);
        } catch (Exception e){

            guiTexture.texture = errorTex;
            errorGUIText.text = e.Message;
        }

        foreach (Game game in configFile.games) {
            StartCoroutine(game.LoadTexture());
        }

        currentGameI = 0;

        hook = new KeyboardHook();
        // register the event that is fired after the key press.
        hook.KeyPressed +=
            new EventHandler<KeyPressedEventArgs>(hook_KeyPressed);
        // register the control + alt + F12 combination as hot key.
        hook.RegisterHotKey(ModifierKeys.None,
            Keys.F11);

        //LaunchFile( "C:\\Windows\\system32\\calc.exe");
    }
Пример #46
0
 public void getKeyboardHandle(KeyboardHook inKey)
 {
     keyboard = inKey;
 }
Пример #47
0
 public void Dispose()
 {
     if (process != null)
     {
         process.Dispose();
         process = null;
     }
     if (keyHook != null)
     {
         keyHook.Dispose();
         keyHook = null;
     }
 }