private void Button_Info_Click(object sender, EventArgs e) { if (MessageBox.Show(Translations.Get("info_instructions"), Translations.Get("info_title"), MessageBoxButtons.OKCancel) == DialogResult.OK) { testing = true; } }
private void List_Macros_SelectedIndexChanged(object sender, EventArgs e) { if (previousindex != List_Macros.SelectedIndex && VerifyChanges()) { try { previousindex = List_Macros.SelectedIndex; string name = List_Macros.SelectedItem.ToString(); Button_Delete.Enabled = true; Text_MacroTitle.Text = name; previousMacroName = name; Text_MacroContent.Text = File.ReadAllText(MacroFiles.MacrosDir + Path.DirectorySeparatorChar + name + MacroFiles.MacrosExt); Button_Add.Enabled = false; Button_Disable.Enabled = true; if (name.Length < MacroFiles.DisablePrefix.Length || name.Substring(0, MacroFiles.DisablePrefix.Length) != MacroFiles.DisablePrefix) { Button_Disable.Text = Translations.Get("disable"); } else { Button_Disable.Text = Translations.Get("enable"); } somethingToSave = false; } catch (NullReferenceException) { } } }
private bool VerifyChanges() { if (somethingToSave && Text_MacroTitle.Text != "" && Text_MacroContent.Text != "") { DialogResult result = MessageBox.Show( String.Format( Translations.Get("save_confirm"), Text_MacroTitle.Text + MacroFiles.MacrosExt ), Translations.Get("save_title"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Button_Add_Click(new object(), EventArgs.Empty); } else if (result == DialogResult.Cancel) { List_Macros.SelectedIndex = previousindex; return(false); } } return(true); }
private void Item_About_Click(object sender, EventArgs e) { MessageBox.Show(String.Format("{0}\n\n{1}\n\n{2}", Translations.Get("about_description"), Translations.Get("about_text_year"), Translations.Get("about_website")), Translations.Get("about_title_dialog"), MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void Button_Delete_Click(object sender, EventArgs e) { if (List_Macros.SelectedItem != null) { string name = List_Macros.SelectedItem.ToString(); if (name != null && File.Exists(MacroFiles.MacrosDir + Path.DirectorySeparatorChar + name + MacroFiles.MacrosExt) && MessageBox.Show(String.Format(Translations.Get("delete_confirm"), name + MacroFiles.MacrosExt), Translations.Get("delete_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { File.Delete(MacroFiles.MacrosDir + Path.DirectorySeparatorChar + name + MacroFiles.MacrosExt); Button_New_Click(sender, e); RefreshFiles(); } } }
private void Buton_ActivateKey_Click(object sender, EventArgs e) { if (MessageBox.Show( Translations.Get("activate_key_prompt"), Translations.Get("activate_key_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (MessageBox.Show( Translations.Get("activate_key_instructions"), Translations.Get("activate_key_instructions_title"), MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { MacroActivateChanging = true; } } }
public bool Nouvelle_Macro() { bool confirm = VerifyChanges(); if (confirm) { previousMacroName = ""; previousindex = -1; List_Macros.SelectedIndex = -1; Button_Delete.Enabled = false; Text_MacroTitle.Text = Translations.Get("new_macro"); Text_MacroContent.Text = ""; Button_Add.Enabled = false; Button_Disable.Enabled = false; somethingToSave = false; } return(confirm); }
private void Button_Help_Click(object sender, EventArgs e) { if (File.Exists(Translations.Get("about_readme_file"))) { Process.Start(Translations.Get("about_readme_file")); } else { MessageBox.Show( String.Format( Translations.Get("about_readme_file_not_found_text"), Translations.Get("about_readme_file") ), Translations.Get("about_readme_file_not_found_title"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); } }
private void OnUserKeyboardRelease(object sender, KeyEventArgs e) { idletime = 0; if (MacroActivateChanging) { ActivateKey = (int)e.KeyCode; MessageBox.Show(Translations.Get("activate_key_changed")); SettingsFile.Save(ActivateKey); MacroActivateChanging = false; } switch (e.KeyCode) { case System.Windows.Forms.Keys.F5: if (ShowInTaskbar) { previousindex = List_Macros.SelectedIndex; RefreshFiles(); List_Macros.SelectedIndex = previousindex; } break; case System.Windows.Forms.Keys.LShiftKey: case System.Windows.Forms.Keys.RShiftKey: case System.Windows.Forms.Keys.Shift: case System.Windows.Forms.Keys.ShiftKey: shift = false; break; } if ((int)e.KeyCode == ActivateKey) { MacroActivate = false; } while (PressedKeys.Contains(e.KeyCode)) { PressedKeys.Remove(e.KeyCode); } ProceedOtherMacros(e.KeyCode, MacroType.Keyboard); }
public FormMain() { if (!WindowManager.IsSingleInstance) { MessageBox.Show(Translations.Get("already_running")); Environment.Exit(0); } PressedKeys = new List <Keys>(); InitializeComponent(); HideMainForm(); this.Text = Translations.Get("about_text"); this.Item_Title.Text = Translations.Get("about_title"); Input = new GlobalHooker(); KInput = new KeyboardHookListener(Input); MInput = new MouseHookListener(Input); KInput.Enabled = true; MInput.Enabled = true; MInput.MouseDown += new MouseEventHandler(OnUserMouseInteraction); MInput.MouseUp += new MouseEventHandler(OnUserMouseInteraction); MInput.MouseMove += new MouseEventHandler(OnUserMouseInteraction); MInput.MouseClick += new MouseEventHandler(OnUserMouseClick); KInput.KeyDown += new KeyEventHandler(OnUserKeyboardPress); KInput.KeyUp += new KeyEventHandler(OnUserKeyboardRelease); KeySender.KeyStroke(KeySender.VkKeyScan('^')); if (File.Exists(SettingsFile.SaveFile)) { SettingsFile.Load(ref ActivateKey); } else { SettingsFile.Save(ActivateKey); if (MessageBox.Show( String.Format( "{0}\n\n{1}\n{2}\n\n{3}", Translations.Get("welcome_text_1"), Translations.Get("welcome_text_2"), Translations.Get("welcome_text_3"), Translations.Get("welcome_text_4") ), Translations.Get("welcome_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question ) == DialogResult.Yes) { Button_Help_Click(new object(), EventArgs.Empty); } } RefreshFiles(); WqlEventQuery query = new WqlEventQuery("Select * From __InstanceCreationEvent Within 2 Where TargetInstance Isa 'Win32_Process'"); watcher = new ManagementEventWatcher(query); watcher.EventArrived += new EventArrivedEventHandler(OnWindowOpen); watcher.Start(); ProceedOtherMacros(Keys.None, MacroType.Startup); timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick += new EventHandler(OnIDLETick); timer.Start(); }
private void OnUserKeyboardPress(object sender, KeyEventArgs e) { idletime = 0; if ((int)e.KeyCode == ActivateKey) { MacroActivate = true; if (testing) { string name = WindowManager.GetActiveWindowTitle(); string exe = WindowManager.GetActiveWindowExename(); TopMostMessageBox.Show( String.Format(Translations.Get("window_info_result_text"), name, exe), Translations.Get("window_info_result_title")); testing = false; } } switch (e.KeyCode) { case System.Windows.Forms.Keys.LShiftKey: case System.Windows.Forms.Keys.RShiftKey: case System.Windows.Forms.Keys.Shift: case System.Windows.Forms.Keys.ShiftKey: shift = true; break; } while (PressedKeys.Contains(e.KeyCode)) { PressedKeys.Remove(e.KeyCode); } PressedKeys.Add(e.KeyCode); if (KeyHelper.Form_Visible) { KeyHelper.BoxContent += KeyConverter.WinFormKey2Name(e.KeyCode) + "\n"; e.Handled = true; } else if (ProceedRewriteMacros(e.KeyCode)) { e.Handled = true; } //Handle french ^ and ¨ key modifiers: êâôëü if ((int)e.KeyCode == 221 && !circumflex) { circumflex = true; e.Handled = true; if (shift) { diaeresis = true; } } else if (circumflex && !circumflexOn) { circumflexOn = true; switch (e.KeyCode) { case (System.Windows.Forms.Keys) 221: circumflex = false; diaeresis = false; if (diaeresis) { KeySender.KeyPress(KeyConverter.Name2Key("Shift")); KeySender.KeyStroke(KeySender.VkKeyScan('^')); KeySender.KeyStroke(KeySender.VkKeyScan('^')); KeySender.KeyRelease(KeyConverter.Name2Key("Shift")); } else { KeySender.KeyStroke(KeySender.VkKeyScan('^')); KeySender.KeyStroke(KeySender.VkKeyScan('^')); } break; case System.Windows.Forms.Keys.A: case System.Windows.Forms.Keys.E: case System.Windows.Forms.Keys.I: case System.Windows.Forms.Keys.O: case System.Windows.Forms.Keys.U: case System.Windows.Forms.Keys.Y: if (diaeresis) { KeySender.KeyPress(KeyConverter.Name2Key("Shift")); KeySender.KeyStroke(KeySender.VkKeyScan('^')); KeySender.KeyRelease(KeyConverter.Name2Key("Shift")); } else { KeySender.KeyStroke(KeySender.VkKeyScan('^')); } circumflex = false; diaeresis = false; break; default: circumflex = false; diaeresis = false; break; } circumflexOn = false; } }