public Register ( Control windowControl ) : bool | ||
windowControl | Control | |
return | bool |
public GBGMain() { InitializeComponent(); ttUpdater.Interval = 500; ttUpdater.Tick += new EventHandler((o, e) => { long mil = totalRunTime.ElapsedMilliseconds, seconds = mil / 1000, minutes = seconds / 60 % 60, hours = minutes / 60, days = hours / 24; lblTotalRunTime.Text = "Approx. " + days + "d " + (hours % 24) + "h " + (minutes % 60) + "m " + (seconds % 60) + "s"; }); bgw.WorkerSupportsCancellation = true; bgw.WorkerReportsProgress = true; bgw.DoWork += new DoWorkEventHandler(RunBot_Work); bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ProgressChanged); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted); Hotkey hkRunBot = new Hotkey(Keys.F12, false, true, true, false); hkRunBot.Pressed += delegate { if(btnStopBot.Enabled) StopBot(); else if(btnRunBot.Enabled) RunBot(); }; hkRunBot.Register(this); }
public ToolForm() { InitializeComponent(); SetProcessDPIAware(); Config.SyncSettings(); try { magicBox = new MagicBox(); } catch (Exception ex) { magicBox = null; } Hotkey hk = new Hotkey(); hk.KeyCode = Keys.F2; hk.Windows = true; hk.Pressed += delegate { showMagicBox(); }; hk.Register(this); Config.notifyIcon = notifyIcon; }
static void Main() { System.Threading.Mutex Mu = new System.Threading.Mutex(false, "{ed4a1d54-416d-47eb-adb6-9a2d47e96774}"); if (Mu.WaitOne(0, false)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Settings settings = new Settings(); Writer log = new Writer(settings); ForegroundWindow foregroundWindow = new ForegroundWindow(); #region NotifyIconMenu ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); NotifyIconMenu notifyIconMenu = new NotifyIconMenu(contextMenuStrip, settings); notifyIconMenu.FocusHandler = foregroundWindow; notifyIconMenu.AddMenuItem(new TextEimer.Windows.MenuItems.Separator()); notifyIconMenu.AddMenuItem(new TextEimer.Windows.MenuItems.Options("Optionen", settings)); notifyIconMenu.AddMenuItem(new TextEimer.Windows.MenuItems.QuitItem("Beenden", "quit")); notifyIconMenu.LogWriter = log; #endregion #region NotifyIcon NotifyIcon notifyIcon = new NotifyIcon(); notifyIcon.ContextMenuStrip = notifyIconMenu.contextMenuStrip; notifyIcon.Icon = (System.Drawing.Icon)TextEimer.Properties.Resources.ResourceManager.GetObject("bucket"); notifyIcon.Text = "TextEimer"; notifyIcon.Visible = true; notifyIcon.Click += delegate { notifyIconMenu.BuildContextMenuStrip(); }; NotifyIconSymbol notifyIconSymbol = new NotifyIconSymbol(notifyIcon, notifyIconMenu); #endregion ClipboardHandler clipboardHandler = new ClipboardHandler(notifyIconMenu); clipboardHandler.LogWriter = log; #region global Hotkey Hotkey hk = new Hotkey(); hk.KeyCode = Keys.V; hk.Windows = true; hk.Pressed += delegate { notifyIconSymbol.ShowNotifyIconMenu(); }; hk.Register(notifyIconMenu.contextMenuStrip); Application.ApplicationExit += delegate { if (hk.Registered) { hk.Unregister(); } }; #endregion Application.Run(); } }
internal SUApplicationContext() { // только создаем форму, она все равно нужна // чтобы слушать хоткеи form = new Form(); // создаем и регистрируем глобайльный хоткей hk = new Hotkey(Keys.A, false, false, false, true); hk.Pressed += delegate { SendSwitchCommand(); }; if (hk.GetCanRegister(form)) hk.Register(form); // Вешаем событие на выход Application.ApplicationExit += Application_ApplicationExit; }
public Notes() { InitializeComponent(); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //this.ShowInTaskbar = false; Rectangle screenSize = Screen.FromControl(this).Bounds; this.Location = new Point(0, 0); this.Size = new Size(screenSize.Width, screenSize.Height / 2); ReadFromFile(); Hotkey hk = new Hotkey(); hk.KeyCode = Keys.A; hk.Alt = true; hk.Pressed += delegate { this.Visible = !this.Visible; }; hk.Register(this); }
private void RegisterHotKey() { // Enable alt + space hotkey. // This should be an option in future versions. var hk = new Hotkey(); hk.Alt = true; hk.KeyCode = Keys.Space; hk.Pressed += HotKey_Pressed; if (hk.GetCanRegister(this)) { hk.Register(this); } else { Debug.WriteLine("Could not register hotkey."); } }
private void GBGMain_Load(Object sender, EventArgs e) { ttUpdater.Interval = 500; ttUpdater.Tick += new EventHandler((o, ev) => { long mil = totalRunTime.ElapsedMilliseconds, seconds = mil / 1000, minutes = seconds / 60 % 60, hours = minutes / 60, days = hours / 24; lblCurrentRunTime.Text = "Approx. " + days + "d " + (hours % 24) + "h " + (minutes % 60) + "m " + (seconds % 60) + "s"; }); bgw.WorkerSupportsCancellation = true; bgw.WorkerReportsProgress = true; bgw.DoWork += new DoWorkEventHandler(RunBot_Work); bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ProgressChanged); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted); Hotkey hkRunBot = new Hotkey(Keys.F12, false, true, true, false); hkRunBot.Pressed += delegate { if (btnStopBot.Enabled) StopBot(); else if (btnRunBot.Enabled) RunBot(); }; hkRunBot.Register(this); Text += ASMVersion; WriteLogLine("Version: ", ASMVersion); WriteLogLine("Disclaimer: if you get caught, it's not my nor anyone else's problem. " + "This understanding should be tacit. Deal with it (or don't use the " + "program). By using this program you are agreeing to hold no one " + "other than your cheating self responsible if anything goes wrong. " + "Don't even attempt to contact me."); WriteLogLine("Oh, and you should probably consider disabling the UAC when running ", "this bot, especially if you're encountering problems."); WriteLogLine("Finishing initialization..."); ResetRunStatistics(); long frequency = Stopwatch.Frequency; long nanosecPerTick = (1000L * 1000L * 1000L) / frequency; WriteLogLine("**Timer frequency in ticks per second = ", frequency); WriteLogLine("*-*Duration stopwatch estimated to be accurate to within ", nanosecPerTick, " nanoseconds on this system"); // Load/Save dialogs saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "Choose Profile Location..."; openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select Profile..."; saveFileDialog.InitialDirectory = openFileDialog.InitialDirectory = profileController.DefaultSaveDirectory; saveFileDialog.DefaultExt = openFileDialog.DefaultExt = Properties.Settings.Default.ProfileFileExtension; saveFileDialog.Filter = openFileDialog.Filter = "profiles (*." + Properties.Settings.Default.ProfileFileExtension + ")|*." + Properties.Settings.Default.ProfileFileExtension + "|All files (*.*)|*.*"; // Set up MouseTracker Timer mouseTrackerTimer = new Timer(); mouseTrackerTimer.Interval = 200; mouseTrackerTimer.Tick += new EventHandler(mouseTrackerTimer_Tick); // Set up events profileController.Profiles.ListChanged += new ListChangedEventHandler((o, ev) => { if(profileController.Profiles.Count > 0) cbProfileSelector.Enabled = true; else cbProfileSelector.Enabled = false; }); lbNodesListChangedEventHandler = new ListChangedEventHandler(nodeList_ListChanged); // ListControls cbProfileSelector.DataSource = profileController.Profiles; lbNodes.DisplayMember = "Display"; cbProfileSelector.DisplayMember = "Display"; // Load/Create the default profile profileController.ProfileControllerAction += new ProfileController.ProfileControllerActionHandler(profileController_ProfileControllerAction); String errpath = "(unknown location)"; mouseTrackerTimer.Enabled = true; try { EnableInitialControls(); if(File.Exists(profileController.PathOfDefaultProfile)) profileController.LoadProfile(errpath = profileController.PathOfDefaultProfile); else { NodeProfile profile = new NodeProfile("default", profileController.DefaultSaveDirectory, new BindingList<GenericNode>()); errpath = profile.FilePath; profileController.SaveProfile(profile); profileController.LoadProfile(profile.FilePath); } SetCurrentAction("Idle (fully initialized)"); elbNodes = new ExtendedListControl<GenericNode>(lbNodes); profileController.Profiles.ResetBindings(); } catch(System.Runtime.Serialization.SerializationException ouch) { WriteLogLine( "ERROR: Failed to mutate your default profile.", "If you continue to see this error, please ", "delete the following file: \"", errpath, "\"."); WriteLogLine("WARNING: Due to Profile functionality being unavailable for the duration ", "of this session, program functionality has become limited."); menuStripMain.Enabled = false; SetCurrentAction("Idle (bad startup; check logs)"); } }
private void ResetCatchToggle() { //hotkey.Unregister(); if (hotkey.Registered) { hotkey.Unregister(); } hotkey = new Hotkey(); hotkey.Control = Properties.Settings.Default.Control; hotkey.Shift = Properties.Settings.Default.Shift; hotkey.Alt = Properties.Settings.Default.Alt; hotkey.KeyCode = (Keys)(byte)char.ToUpper(Properties.Settings.Default.Key[0]); hotkey.Pressed += delegate { Follow(); }; hotkey.Register(this); }
private void ToolForm_Load(object sender, EventArgs e) { Hotkey hk = new Hotkey(); hk.KeyCode = Keys.F2; hk.Pressed += delegate { SendKeys.SendWait("^a"); System.Threading.Thread.Sleep(50); SendKeys.SendWait("^c"); this.Show(); this.WindowState = FormWindowState.Normal; this.TopMost = true; this.Focus(); this.BringToFront(); this.TopMost = false; this.Activate(); }; hk.Register(this); this.StartPosition = FormStartPosition.Manual; this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height); this.KeyPreview = true; }
public static IEnumerator<object> OnConfigurationChanged() { #if !MONO if (Hotkey_Search_Files != null) { if (Hotkey_Search_Files.Registered) Hotkey_Search_Files.Unregister(); } Keys keyCode, modifiers; Future<string> f; yield return Database.GetPreference("Hotkeys.SearchFiles.Key").Run(out f); keyCode = (Keys)Enum.Parse(typeof(Keys), f.Result ?? "None", true); yield return Database.GetPreference("Hotkeys.SearchFiles.Modifiers").Run(out f); modifiers = (Keys)Enum.Parse(typeof(Keys), f.Result ?? "None", true); Hotkey_Search_Files = new Hotkey(keyCode, modifiers); if (!Hotkey_Search_Files.Empty) { Hotkey_Search_Files.Pressed += (s, e) => { Scheduler.Start(ShowFullTextSearchTask(), TaskExecutionPolicy.RunAsBackgroundTask); }; Hotkey_Search_Files.Register(HotkeyWindow); } #endif yield break; }
static void Main() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; if (!mutexCreated) { if (MessageBox.Show( "JediConcentrate2 is already running. Hotkeys cannot be shared between different instances. Are you sure you wish to run this second instance?", "JediConcentrate2 already running", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { mutex.Close(); return; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frm = new frmJedi(); frm.Show(); frm.Hide(); ContextMenu menu = new ContextMenu(); menu.MenuItems.Add(new MenuItem("About")); menu.MenuItems.Add(new MenuItem("Exit")); menu.MenuItems[0].Click += About_Click; menu.MenuItems[1].Click += Exit_Click; menu.Popup += Menu_Popup; icon = new NotifyIcon() { Icon = Properties.Resources.yoda, Visible = true, ContextMenu = menu }; hk = new Hotkey(); hk.KeyCode = Keys.J; hk.Windows = true; hk.Pressed += delegate { ToggleConcentrate(); }; if (hk.GetCanRegister(frm)) { hk.Register(frm); } thPoll = new Thread(new ThreadStart(Poll)); thPoll.Start(); Application.Run(); }
private void applyShortcutButton_Click(object sender, EventArgs e) { try { int notMetaCount = shortcutKeys.Count(k => !IsMetaKey(k)); if (notMetaCount == 0) { ShowErrorMessage("You should also choose one character that is not CTRL, SHIFT, ALT or WIN"); return; } bool ctrl = false; bool shift = false; bool alt = false; bool win = false; Keys key = Keys.F19; foreach (Keys item in shortcutKeys) { if (item == Keys.ControlKey) { ctrl = true; } else if (item == Keys.ShiftKey) { shift = true; } else if (item == Keys.LWin || item == Keys.RWin) { win = true; } else if (item == Keys.Alt || item == Keys.Menu) { alt = true; } else { key = item; } } if (hotKey != null && hotKey.Registered) { hotKey.Unregister(); } hotKey = new Hotkey(key, shift, ctrl, alt, win); hotKey.Pressed += (hkSender, hkArgs) => ShowScreenShotForm(); if (hotKey.GetCanRegister(shortcut)) { hotKey.Register(shortcut); new UserSettings().Shortcut = shortcutKeys; } else { MessageBox.Show(this, "There is another application using this combination already. Please choose another one", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { ShowErrorMessage(ex.Message); } }
// Register hotkeys private void RegisterHotKeys() { Object s = null; EventArgs e = null; playhotkey = new Hotkey(); playhotkey.Alt = true; playhotkey.KeyCode = Keys.P; playhotkey.Pressed += delegate { btnPlay_Click(s, e); }; prevhotkey = new Hotkey(); prevhotkey.Alt = true; prevhotkey.KeyCode = Keys.Left; prevhotkey.Pressed += delegate { btnPrev_Click(s, e); }; nexthotkey = new Hotkey(); nexthotkey.Alt = true; nexthotkey.KeyCode = Keys.Right; nexthotkey.Pressed += delegate { btnNext_Click(s, e); }; stophotkey = new Hotkey(); stophotkey.Alt = true; stophotkey.KeyCode = Keys.S; stophotkey.Pressed += delegate { btnStop_Click(s, e); }; hidehotkey = new Hotkey(); hidehotkey.Alt = true; hidehotkey.KeyCode = Keys.H; hidehotkey.Pressed += delegate { HideMe(); }; try { if (!playhotkey.GetCanRegister(this)) { MessageBox.Show("Failed to register hotkey!\nPlay"); } else { playhotkey.Register(this); } if (!prevhotkey.GetCanRegister(this)) { MessageBox.Show("Failed to register hotkey!\nPrev"); } else { prevhotkey.Register(this); } if (!nexthotkey.GetCanRegister(this)) { MessageBox.Show("Failed to register hotkey!\nNext"); } else { nexthotkey.Register(this); } if (!stophotkey.GetCanRegister(this)) { MessageBox.Show("Failed to register hotkey!\nStop"); } else { stophotkey.Register(this); } if (!hidehotkey.GetCanRegister(this)) { MessageBox.Show("Failed to register hotkey!\nHide"); } else { hidehotkey.Register(this); } } catch { } }