Пример #1
0
            // }}}
            // private
            public UInt64 _proceed(UInt64 time) // {{{
            {
                List <SpecialKeyPlayer.KMH_INPUT> inputList = new List <SpecialKeyPlayer.KMH_INPUT>();

                bool use_scancode = ((macro.macroType & Macro.MACRO_TYPE.USE_SCANCODE) != 0);

                for (; tickNum < macro.macroEvents.Length; tickNum++)
                {
                    // DUE LATER, STOP THERE {{{
                    MacroEvent macroEvent = macro.macroEvents[tickNum];
                    if (launchTime + macroEvent.time > time)
                    {
                        break;
                    }

                    //}}}
                    // KEYBOARD {{{
                    SpecialKeyPlayer.KMH_INPUT input = new SpecialKeyPlayer.KMH_INPUT();
                    if (macroEvent.keyType != 2)
                    {
                        //....type.........KEYBOARD
                        input.type = INPUT_KEYBOARD;

                        //.....scancode.............SC-VK .....................keyCode............dwFlags.............. keyUp...............keyDown..............SCANCODE
                        if (use_scancode)
                        {
                            input.ki.wScan = (ushort)macroEvent.keyCode;  input.ki.dwFlags = (macroEvent.keyUp ? KEYEVENTF_KEYUP : 0) | KEYEVENTF_SCANCODE;
                        }
                        else
                        {
                            input.ki.wVk = macroEvent.keyCode;  input.ki.dwFlags = (macroEvent.keyUp ? KEYEVENTF_KEYUP : 0);
                        }
                    }
                    //}}}
                    // MOUSE {{{
                    else
                    {
                        input.type         = INPUT_MOUSE;
                        input.mi.dx        = 0;
                        input.mi.dy        = 0;
                        input.mi.mouseData = 0;
                        input.mi.dwFlags   = (uint)macroEvent.keyCode;
                    }
                    //}}}
                    inputList.Add(input);
                }
                // SEND INPUT {{{
                SpecialKeyPlayer.KMH_INPUT[] inputArray = inputList.ToArray();
                if (inputArray.Length > 0)
                {
                    int size = Marshal.SizeOf(inputArray[0]);
                    NativeMethods.SendInput((uint)inputArray.Length, inputArray, size);
                } //}}}

                return(tickNum < macro.macroEvents.Length
            ? launchTime + macro.macroEvents[tickNum].time
            : MACRO_TIME_DONE
                       );
            }
Пример #2
0
        // }}}

        public List <SpecialKeyPlayer.KMH_INPUT> getInputList(bool keyUp) // {{{
        {
            // Invert order for Key up

            List <SpecialKeyPlayer.KMH_INPUT> inputs = new List <SpecialKeyPlayer.KMH_INPUT>();

            int start, done, step;

            if (keyUp)
            {
                start = macroEvents.Length - 1;
                step  = -1;
                done  = -1;
            }
            else
            {
                start = 0;
                step  = 1;
                done  = macroEvents.Length;
            }

            for (int i = start; i != done; i += step)
            {
                MacroEvent macroEvent            = macroEvents[i];
                SpecialKeyPlayer.KMH_INPUT input = new SpecialKeyPlayer.KMH_INPUT();
                input.type = SpecialKeyPlayer.INPUT_KEYBOARD;

                if ((macroType & Macro.MACRO_TYPE.USE_SCANCODE) != 0)
                {
                    input.ki.wScan = (ushort)macroEvent.keyCode;          // Note scan codes send a different value for key up
                    if (keyUp)
                    {
                        input.ki.dwFlags = SpecialKeyPlayer.KEYEVENTF_SCANCODE | SpecialKeyPlayer.KEYEVENTF_KEYUP;
                    }
                    else
                    {
                        input.ki.dwFlags = SpecialKeyPlayer.KEYEVENTF_SCANCODE;
                    }
                }
                else
                {
                    input.ki.wVk = macroEvent.keyCode;
                    if (keyUp)
                    {
                        input.ki.dwFlags = SpecialKeyPlayer.KEYEVENTF_KEYUP;
                    }
                    else
                    {
                        input.ki.dwFlags = 0;
                    }
                }

                inputs.Add(input);
            }
            return(inputs);
        }
Пример #3
0
        // }}}
        public void RebuildFromMacroDefinition(Macro macro) // {{{
        {
            MacroCommands.Items.Clear();
            if (macro.macroEvents != null)
            {
                for (int i = 0; i < macro.macroEvents.Length; i++)
                {
                    MacroEvent   macroEvent = macro.macroEvents[i];
                    ListViewItem item       = new ListViewItem("" + macroEvent.time);
                    if (macroEvent.keyUp)
                    {
                        item.SubItems.Add("KeyUp");
                    }
                    else
                    {
                        switch (macroEvent.keyType)
                        {
                        case  1: item.SubItems.Add("KeyUp"); break;

                        case  2: item.SubItems.Add("Mouse"); break;

                        default: item.SubItems.Add("KeyDown"); break;
                        }
                    }
                    item.SubItems.Add("" + macroEvent.keyCode);

                    MacroCommands.Items.Add(item);
                }
            }
            MacroName.Text = macro.name;

            ME_C_UseScanCodes.Checked = ((macro.macroType & Macro.MACRO_TYPE.USE_SCANCODE) != 0);

            // either multi-key or timed macro
            ME_R_TimedMacro.Checked    = ((macro.macroType & Macro.MACRO_TYPE.MULTI_KEY) == 0);
            ME_R_MultikeyMacro.Checked = !ME_R_TimedMacro.Checked;
        }