Example #1
0
        public static void testfunc(object args)
        {
            CallbackParameter Argument = (CallbackParameter)args;
            MainGUI           f        = (MainGUI)Argument.args[0];

            try
            {
                var d = "Console write text";
                f.Invoke(f.Con_Write, d);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace);
            }
        }
Example #2
0
 public static void test2func(object args)
 {
     CallbackParameter Argument = (CallbackParameter)args;
     MainGUI           f        = (MainGUI)Argument.args[0];
 }
Example #3
0
        private void AsyncCapture(object input)
        {
            AsyncCaptureInfo info = (AsyncCaptureInfo)input;
            /**********************************************/

            List <Keys> pKeys  = new List <Keys>();                                     // Latest Shortcut Combination
            List <Keys> values = Enum.GetValues(typeof(Keys)).OfType <Keys>().ToList(); // Detectable keys

            Keys[] lastCombDetected = null;

            // prepare keys array
            for (int i = 0; i < values.Count; i++)
            {
                if (values[i] == Keys.ControlKey)
                {
                    values.RemoveAt(i);
                }
                if (values[i] == Keys.Menu)
                {
                    values.RemoveAt(i);
                }
            }

            // check for shortcuts
            while (info.GetCapturing())
            {
                foreach (Keys key in values)
                {
                    unchecked
                    {
                        // Get status of key
                        bool kStatus = GetAsyncKeyState((int)key) == (short)0x8000;

                        if (pKeys.Count > 0)
                        {
                            int keyPos = -1;
                            for (int i = 0; i < pKeys.Count; i++) // find pos of current key
                            {
                                if (key == pKeys[i])
                                {
                                    keyPos = i;
                                    break;
                                }
                            }

                            if (keyPos == -1 && kStatus)
                            {// Key is now up, add it
                                pKeys.Add(key);
                            }
                            else if (keyPos != -1 && !kStatus)
                            {// Key is now down, remove it
                                lastCombDetected = null;
                                pKeys.RemoveAt(keyPos);
                            }
                        }
                        else
                        {
                            if (kStatus)
                            {
                                pKeys.Add(key);
                            }
                        }
                    }
                }

                //Debug.WriteLine("Comb: " + String.Join("+", pKeys));

                // check if combination matches any added shortcuts
                string lastComb = String.Join(".", pKeys);
                if (lastCombDetected == null || String.Join(".", lastCombDetected.ToList()) != lastComb)
                {
                    foreach (ShortcutInfo shortcut in info.Shortcuts)
                    {
                        string comb = String.Join(".", shortcut.Shortcut);
                        if (comb == lastComb)
                        {
                            lastCombDetected = shortcut.Shortcut;
                            Thread t = new Thread(new ParameterizedThreadStart(shortcut.Callback));

                            CallbackParameter cp = new CallbackParameter();
                            cp.args = shortcut.Arguments;

                            t.Start(cp);

                            break;
                        }
                    }
                }

                //Debug.WriteLine("0x" + GetAsyncKeyState((int)Keys.F10).ToString("X"));
            }

            /***********************/
            //info.SetCapturing(false);
        }