public static List <IMaster> LoadPlugins(out IContainer _components) { var tools = new List <IMaster>(); _components = new Container(); // we extract all the IAttributeDefinition implementations foreach (var filename in Directory.GetFiles(Application.StartupPath, "*.dll")) { var assembly = System.Reflection.Assembly.LoadFrom(filename); foreach (var type in assembly.GetTypes()) { var plugin = type.GetInterface("Handyman.Framework.Interfaces.IMaster"); if (plugin != null) { var tool = (IMaster)Activator.CreateInstance(type); tool.Initialize(); var hotkey = new SystemHotkey(_components) { Shortcut = tool.HotKey }; hotkey.Pressed += delegate { tool.Execute(null, Launcher.Current.ShowData); }; tools.Add(tool); } } } return(tools); }
private void ALPHA_Pressed(SystemHotkey p) { //LOG("Alpha_Pressed(" + p.Char.ToString() + ")"); //MessageBox.Show("OK"); if (p.Char != 0) { m_SelectForm.Input_TextBox.Text += p.Char; } if (Regex.IsMatch(m_SelectForm.Input_TextBox.Text, @"(^|[^/])[+\-]$")) { NONALPHA_Pressed(p); return; } if (m_SelectForm.SelectListBox.SelectedIndex > 0) { LOG(">" + m_SelectForm.Input_TextBox.Text + "=>" + selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", "") + "(" + m_SelectForm.SelectListBox.SelectedIndex.ToString() + ")"); } LOG(":" + p.Char.ToString()); SystemHotkey.RegisterHotKey(true, t_key_type.ALPHA | t_key_type.NONALPHA); //ALPHA_Thread(); /*try * { * alphaThread.Abort(); * } * catch { } alphaThread = new Thread(new ThreadStart(ALPHA_Thread)); * alphaThread.Start();*/ ALPHA_Thread(); //LOG("~Alpha_Pressed(" + p.Char.ToString()+ ")"); }
//public System.ComponentModel.IContainer Components //{ // get // { // this.components; // } //} /// <summary> /// Create the NotifyIcon UI, the ContextMenu for the NotifyIcon and an Exit menu item. /// </summary> private void InitializeContext() { this.components = new System.ComponentModel.Container(); this.m_NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.m_SystemHotkey = new SystemHotkey(this.components); this.m_AddWordSystemHotkey = new SystemHotkey(this.components); // // m_NotifyIcon // //this.m_NotifyIcon.ContextMenuStrip = this.m_NotifyIconContextMenu; this.m_NotifyIcon.DoubleClick += new System.EventHandler(this.OnNotifyIconDoubleClick); this.m_NotifyIcon.Icon = Properties.Resources.App;//new Icon(typeof(LauncherApplicationContext), "CLOCK05.ICO"); this.m_NotifyIcon.Text = "Handymans"; this.m_NotifyIcon.Visible = true; // // m_SystemHotkey // m_SystemHotkey.Shortcut = Properties.Settings.Default.TypeWordHotKey; //Shortcut.CtrlF12; m_SystemHotkey.Pressed += new EventHandler(OnSystemHotkeyPressed); // // m_AddWordSystemHotkey // m_AddWordSystemHotkey.Shortcut = Properties.Settings.Default.AddWordHotKey;//Shortcut.CtrlF11; m_AddWordSystemHotkey.Pressed += new EventHandler(OnAddWordSystemHotkeyPressed); Application.ApplicationExit += new EventHandler(OnApplicationExit); }
private void ALPHA_Pressed(SystemHotkey p) { //Show(); if (p.Char != 0) { m_SelectForm.Input_TextBox.Text += p.Char; } if (Regex.IsMatch(m_SelectForm.Input_TextBox.Text, @"(^|[^/])[+\-]$")) { NONALPHA_Pressed(p); return; } selections_strings.Clear(); selections_words = word.Selections(m_SelectForm.Input_TextBox.Text); foreach (word w in selections_words) { selections_strings.Add(Converter.getKaputa(w.ToString().Replace("|", ""))); } //if (selections_words.Count == 0) //selections_strings.Add(Converter.getKaputa(m_SelectForm.Input_TextBox.Text.ToString().Replace("|", ""))); Reread(); m_SelectForm.SelectListBox.SelectedIndex = 0; SystemHotkey.RegisterHotKey(true, t_key_type.ALPHA | t_key_type.NONALPHA); m_SelectForm.Show(); User32.SetForegroundWindow(LastActiveWindow); }
public FormMain() { InitializeComponent(); this.TopMost = true; SystemHotkey sSol = new SystemHotkey(this.components); sSol.Shortcut = Shortcut.AltLeftArrow; sSol.Pressed += sSol_Pressed; SystemHotkey sSag = new SystemHotkey(this.components); sSag.Shortcut = Shortcut.AltRightArrow; sSag.Pressed += sSag_Pressed; SystemHotkey sAsagi = new SystemHotkey(this.components); sAsagi.Shortcut = Shortcut.AltDownArrow; sAsagi.Pressed += sAsagi_Pressed; SystemHotkey sYukari = new SystemHotkey(this.components); sYukari.Shortcut = Shortcut.AltUpArrow; sYukari.Pressed += sYukari_Pressed; }
private void CTRL_Pressed(SystemHotkey p) { m_SelectForm.Input_TextBox.Text = ""; SystemHotkey.RegisterHotKey(false, t_key_type.NONALPHA); if (p != null) { if (!Active) { ActiveWNDsList.Add(User32.GetForegroundWindow()); } else { ActiveWNDsList.Remove(User32.GetForegroundWindow()); } } SystemHotkey.RegisterHotKey(!Active, t_key_type.ALPHA); }
//Thread pos_thread; public MainForm() { //word.Initialize(); SystemHotkey.Pressed[t_key_type.CTRL] = new PressedDelegate(CTRL_Pressed); SystemHotkey.Pressed[t_key_type.ALPHA] = new PressedDelegate(ALPHA_Pressed); SystemHotkey.Pressed[t_key_type.NONALPHA] = new PressedDelegate(NONALPHA_Pressed); new SystemHotkey(VK.VK_F8, 0).Key_Type = t_key_type.CTRL; for (int i = 'A'; i <= 'Z'; i++) { HotKeys[i] = new SystemHotkey((VK)i, RegisterHotKeyModifiers.MOD_NONE); HotKeys[(int)RegisterHotKeyModifiers.MOD_SHIFT * 0x100 + i] = new SystemHotkey((VK)i, RegisterHotKeyModifiers.MOD_SHIFT); } foreach (VK i in nonalphas) { HotKeys[(int)i] = new SystemHotkey(i, 0); } foreach (VK i in nonalphas) { HotKeys[(int)RegisterHotKeyModifiers.MOD_SHIFT * 0x100 + (int)i] = new SystemHotkey(i, RegisterHotKeyModifiers.MOD_SHIFT); } input_method = Method.SriShell_Guess; output_method = Method.kaputadotcom; menu_method = Method.kaputadotcom; m_SettingsForm = new SettingsForm(this); m_SelectForm = new SelectForm(this); m_SriWordForm = new SriWordForm(this); SystemHotkey.RegisterHotKey(true, t_key_type.CTRL); InitializeComponent(); //File.WriteAllText("sri shell guess.log", ""); //pos_thread = new Thread(GetCursorPosition); //pos_thread.Start(); }
public static List <IMaster> LoadPlugins(out IContainer _components, out List <string> sgs) { var tools = new List <IMaster>(); _components = new Container(); // we extract all the IMaster implementations sgs = new List <string>(); foreach (var filename in Directory.GetFiles(Application.StartupPath, Res.DLL)) { var assembly = System.Reflection.Assembly.LoadFrom(filename); foreach (var type in assembly.GetTypes()) { var plugin = type.GetInterface(typeof(IMaster).FullName); if (plugin != null) { var tool = (IMaster)Activator.CreateInstance(type); tool.Initialize(); sgs.Add(tool.Alias); sgs.Add($"{Res.HELP} {tool.Alias}"); if (tool.Suggestions != null) { sgs.AddRange(tool.Suggestions); } var hotkey = new SystemHotkey(_components) { Shortcut = tool.HotKey }; hotkey.Pressed += delegate { tool.Execute(null, Launcher.Current.ShowData); }; tools.Add(tool); } } } return(tools); }
/// <summary> /// Create the NotifyIcon UI, the ContextMenu for the NotifyIcon and an Exit menu item. /// </summary> private void InitializeContext() { _components = new System.ComponentModel.Container(); _notifyIcon = new NotifyIcon(_components); _systemHotkey = new SystemHotkey(_components); _addWord = new SystemHotkey(_components); _notifyIcon.DoubleClick += OnNotifyIconDoubleClick; _notifyIcon.Icon = Properties.Resources.if_robot_88068; _notifyIcon.Text = "Handymans Master at your service!"; _notifyIcon.Visible = true; // m_SystemHotkey _systemHotkey.Shortcut = Properties.Settings.Default.TypeWordHotKey; //Shortcut.AltBcksp; _systemHotkey.Pressed += OnSystemHotkeyPressed; // m_AddWordSystemHotkey _addWord.Shortcut = Properties.Settings.Default.AddWordHotKey; //Shortcut.CtrlF11; _addWord.Pressed += OnAddWordSystemHotkeyPressed; Application.ApplicationExit += OnApplicationExit; }
private void NONALPHA_Pressed(SystemHotkey p) { switch ((VK)(p.VirtualKey)) { case VK.VK_DOWN: m_SelectForm.SelectListBox.SelectedIndex++; m_SelectForm.Input_TextBox.Text = selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", ""); Reread(); return; case VK.VK_UP: m_SelectForm.SelectListBox.SelectedIndex--; m_SelectForm.Input_TextBox.Text = selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", ""); Reread(); return; case VK.VK_BACK: if (m_SelectForm.Input_TextBox.Text.Length > 0) { m_SelectForm.Input_TextBox.Text = m_SelectForm.Input_TextBox.Text.Substring(0, m_SelectForm.Input_TextBox.Text.Length - 1); } ALPHA_Pressed(HotKeys[(int)VK.VK_BACK]); return; } SystemHotkey.RegisterHotKey(false, t_key_type.NONALPHA | t_key_type.ALPHA);//ALPHA added //MessageBox.Show("OK"); //UpdateWord(m_SelectForm.SelectListBox.SelectedItem.ToString()); if (m_SelectForm.SelectListBox.SelectedIndex >= 0)// && selections_words.Count>m_SelectForm.SelectListBox.SelectedIndex) { UpdateWord(getter(selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", ""))); } m_SelectForm.Input_TextBox.Text = ""; m_SelectForm.Hide(); User32.keybd_event((byte)p.VirtualKey, 0, 0, 0); selections_strings.Clear(); Reread(); SystemHotkey.RegisterHotKey(false, t_key_type.NONALPHA); SystemHotkey.RegisterHotKey(true, t_key_type.ALPHA);//Added }
private void CTRL_Pressed(SystemHotkey p) { m_SelectForm.Input_TextBox.Text = ""; SystemHotkey.RegisterHotKey(false, t_key_type.NONALPHA); if (p != null) { if (!Active) { ActiveWNDsList.Add(User32.GetForegroundWindow()); } else { ActiveWNDsList.Remove(User32.GetForegroundWindow()); } } SystemHotkey.RegisterHotKey(!Active, t_key_type.ALPHA); //if (Active) ALPHA_Pressed(null); //try { pos_thread.Abort(); } //catch { } //pos_thread = new Thread(GetCursorPosition); //pos_thread.Start(); }
public Engine() { word.Initialize(); SystemHotkey.Pressed[t_key_type.CTRL] = new PressedDelegate(CTRL_Pressed); SystemHotkey.Pressed[t_key_type.ALPHA] = new PressedDelegate(ALPHA_Pressed); SystemHotkey.Pressed[t_key_type.NONALPHA] = new PressedDelegate(NONALPHA_Pressed); new SystemHotkey(VK.VK_F8, 0).Key_Type = t_key_type.CTRL; for (int i = 'A'; i <= 'Z'; i++) { HotKeys[i] = new SystemHotkey((VK)i, RegisterHotKeyModifiers.MOD_NONE); HotKeys[(int)RegisterHotKeyModifiers.MOD_SHIFT * 0x100 + i] = new SystemHotkey((VK)i, RegisterHotKeyModifiers.MOD_SHIFT); } foreach (VK i in nonalphas) { HotKeys[(int)i] = new SystemHotkey(i, 0); } foreach (VK i in nonalphas) { HotKeys[(int)RegisterHotKeyModifiers.MOD_SHIFT * 0x100 + (int)i] = new SystemHotkey(i, RegisterHotKeyModifiers.MOD_SHIFT); } input_method = Method.SriShell_Guess; output_method = Method.kaputadotcom; m_SettingsForm = new SettingsForm(this); m_SelectForm = new SelectForm(this); SystemHotkey.RegisterHotKey(true, t_key_type.CTRL); //InitializeComponent(); }
private void NONALPHA_Pressed(SystemHotkey p) { switch ((VK)(p.VirtualKey)) { case VK.VK_DOWN: m_SelectForm.SelectListBox.SelectedIndex++; //m_SelectForm.Input_TextBox.Text = selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", ""); Reread(); return; case VK.VK_UP: m_SelectForm.SelectListBox.SelectedIndex--; //m_SelectForm.Input_TextBox.Text = selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", ""); Reread(); return; case VK.VK_BACK: LOG("BACK"); if (m_SelectForm.Input_TextBox.Text == "") { goto N_ALPHA; } if (m_SelectForm.Input_TextBox.Text.Length > 0) { m_SelectForm.Input_TextBox.Text = m_SelectForm.Input_TextBox.Text.Substring(0, m_SelectForm.Input_TextBox.Text.Length - 1); } ALPHA_Pressed(HotKeys[(int)VK.VK_BACK]); return; case VK.VK_0: case VK.VK_1: case VK.VK_2: case VK.VK_3: case VK.VK_4: case VK.VK_5: case VK.VK_6: case VK.VK_7: case VK.VK_8: m_SelectForm.SelectListBox.SelectedIndex = (VK)p.VirtualKey == VK.VK_0 ? selections_strings.Count - 1 : p.VirtualKey - (int)VK.VK_1; return; } //alphaThread.Join(); //MessageBox.Show("OK"); trie.word w = selections_words[m_SelectForm.SelectListBox.SelectedIndex]; string parse = variations.Parse2String( m_SelectForm.Input_TextBox.Text, variations.SplitIntoChars(w.ToString().Replace(" ", ""))); List <trie.word> tmp = trie.TRIE.findAll(m_SelectForm.Input_TextBox.Text, true); /*foreach (trie.word iw in tmp) * iw.TravelProbability = double.NegativeInfinity; * tmp.Sort();*/ int old_selection = tmp.IndexOf(w); if (old_selection == -1) { for (int i = 0; i < tmp.Count; i++) { if (tmp[i].ToString() == w.ToString()) { old_selection = i; break; } } } LOG(parse + "=>" + selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString() + "(" + m_SelectForm.SelectListBox.SelectedIndex.ToString() + ")" + "[" + old_selection.ToString() + "]" ); trie.TRIE.FeedBack(m_SelectForm.Input_TextBox.Text, selections_words[m_SelectForm.SelectListBox.SelectedIndex]); //MessageBox.Show("NONALPHA"); SystemHotkey.RegisterHotKey(false, t_key_type.NONALPHA | t_key_type.ALPHA);//ALPHA added //UpdateWord(m_SelectForm.SelectListBox.SelectedItem.ToString()); if (m_SelectForm.SelectListBox.SelectedIndex >= 0) { UpdateWord(getter(selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString().Replace("|", ""))); previous_seleted_word = selections_words[m_SelectForm.SelectListBox.SelectedIndex].ToString(); } N_ALPHA: m_SelectForm.Input_TextBox.Text = ""; #if !BI m_SelectForm.Hide(); #endif #if !DEBUGING User32.keybd_event((byte)p.VirtualKey, 0, 0, 0); #endif selections_strings.Clear(); Reread(); SystemHotkey.RegisterHotKey(true, t_key_type.ALPHA);//Added #if !BI SystemHotkey.RegisterHotKey(false, t_key_type.NONALPHA); #else SystemHotkey.RegisterHotKey(true, t_key_type.NONALPHA); ALPHA_Thread(); #endif }