Esempio n. 1
0
        /// <summary>
        /// Execute command.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void KeyboardHookKeyPressed(object sender, KeyPressedEventArgs e)
        {
            Process process = new System.Diagnostics.Process();

            try
            {
                string[] commandParts = command.Split(new Char[] { ' ', '\t' }, 2);

                switch (commandParts.Length)
                {
                    case 1:
                        process.StartInfo.FileName = commandParts[0];
                        break;
                    case 2:
                        process.StartInfo.Arguments = commandParts[1];
                        goto case 1;
                    default:
                        return;
                }

                process.Start();
            }
            catch (System.ComponentModel.Win32Exception)
            {
                MessageBox.Show("Can\'t run command \"" + command + "\"", "HotKey79", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Run command for hotkey.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void KeyboardHookKeyPressed(object sender, KeyPressedEventArgs e)
 {
     commands[e.Id].KeyboardHookKeyPressed(sender, e);
 }