SendInput() 개인적인 메소드

private SendInput ( Int32 nInputs, INPUT pInputs, Int32 cbSize ) : Int32
nInputs System.Int32
pInputs INPUT
cbSize System.Int32
리턴 System.Int32
예제 #1
0
        void ReplayThread()
        {
            var inputs =
                from x in this.keys
                select x.ToInput();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            foreach (var input in inputs)
            {
                while (input.ki.time > sw.ElapsedMilliseconds)
                {
                    Thread.Sleep(1);
                    //this.Dispatch(() => { this.labelDebug.Content = string.Format("{0} : {1}", input.ki.time, sw.ElapsedMilliseconds); });
                }

                Win32.SendInput(input);

                if (!this.isReplayAlive)
                {
                    break;
                }
            }

            sw.Stop();

            this.Dispatch(() =>
            {
                this.buttonReplay.IsEnabled = true;
                this.replay        = null;
                this.isReplayAlive = false;
            });
        }
예제 #2
0
        void ReplayThread()
        {
            var inputs =
                from x in this.keys
                select new INPUT
            {
                type = type.INPUT_KEYBOARD,
                ki   = new KEYBDINPUT
                {
                    time    = (int)x.Elapsed,
                    wVk     = (wVk)x.Code,
                    dwFlags = x.Type == EventType.KeyDown ? dwFlags.KEYEVENTF_KEYDOWN : dwFlags.KEYEVENTF_KEYUP,
                },
            };

            Stopwatch sw = new Stopwatch();

            sw.Start();

            foreach (var input in inputs)
            {
                while (input.ki.time > sw.ElapsedMilliseconds)
                {
                    Thread.Sleep(1);
                    //this.Dispatch(() => { this.labelDebug.Content = string.Format("{0} : {1}", input.ki.time, sw.ElapsedMilliseconds); });
                }

                Win32.SendInput(input);

                if (!this.isReplayAlive)
                {
                    break;
                }
            }

            sw.Stop();

            this.Dispatch(() =>
            {
                this.buttonReplay.IsEnabled = true;
                this.replay        = null;
                this.isReplayAlive = false;
            });
        }