Esempio n. 1
0
        public static void ReleaseKey(Process proc, Keycombo_t key)
        {
            if (key.Shift)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYDOWN, (int)Keys.ShiftKey, 0);
            }
            if (key.Control)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYDOWN, (int)Keys.ControlKey, 0);
            }
            if (key.Alt)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYDOWN, (int)Keys.Menu, 0);
            }

            PostMessage(proc.MainWindowHandle, WM_KEYUP, (int)key.KeyCode, 0);

            if (key.Alt)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYUP, (int)Keys.Menu, 0);
            }
            if (key.Control)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYUP, (int)Keys.ControlKey, 0);
            }
            if (key.Shift)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYUP, (int)Keys.ShiftKey, 0);
            }
        }
Esempio n. 2
0
        private int SaveKeyBind(Keybind_t keybind)
        {
            Keycombo_t    key  = keybind.m_key;
            SQLiteCommand lcmd = new SQLiteCommand(m_db);

            try
            {
                lcmd.CommandText = "INSERT INTO ActionKey (keycode, shift, control, alt) VALUES (@keycode, @shift, @control, @alt)";
                lcmd.Parameters.AddWithValue("@keycode", (int)key.KeyCode);
                lcmd.Parameters.AddWithValue("@shift", key.Shift ? 1 : 0);
                lcmd.Parameters.AddWithValue("@control", key.Control ? 1 : 0);
                lcmd.Parameters.AddWithValue("@alt", key.Alt ? 1 : 0);
                lcmd.Prepare();
                lcmd.ExecuteNonQuery();
            }
            catch { }

            lcmd.CommandText = "SELECT id FROM ActionKey WHERE keycode=@keycode AND shift=@shift AND control=@control AND alt=@alt";
            lcmd.Prepare();
            return(Convert.ToInt32(lcmd.ExecuteScalar().ToString()));
        }