예제 #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);
        }