コード例 #1
0
        /// <summary>
        /// Process arm turning. Currently set to fast turn speed only.
        /// </summary>
        /// <param name="shoulder"></param>
        /// <param name="rightHand"></param>
        /// <param name="rightElbow"></param>
        /// <param name="leftHand"></param>
        /// <param name="leftElbow"></param>
        /// <returns></returns>
        private Boolean detectArmTurning(Joint shoulder, Joint rightHand, Joint rightElbow, Joint leftHand, Joint leftElbow)
        {
            double diffHandShoulderRight = Math.Abs(rightHand.Position.Y - shoulder.Position.Y);
            double diffHandShoulderLeft  = Math.Abs(leftHand.Position.Y - shoulder.Position.Y);

            // right hand
            if (diffHandShoulderRight < armTurnThresh && rightHand.Position.X > rightElbow.Position.X)
            {
                InputSimulator.SimulateKeyDown(VirtualKeyCode.OEM_PERIOD);
                return(true);
            }
            // left hand
            else if (diffHandShoulderLeft < armTurnThresh && leftHand.Position.X < leftElbow.Position.X)
            {
                InputSimulator.SimulateKeyDown(VirtualKeyCode.OEM_COMMA);
                return(true);
            }
            // neither right nor left hand
            else
            {
                if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_PERIOD))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.OEM_PERIOD);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_COMMA))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.OEM_COMMA);
                }
                return(false);
            }
        }
コード例 #2
0
        private void detectBirdwatcher(Joint head, Joint rightHand, Joint rightElbow, Joint rightShoulder)
        {
            //Calculate how far our right hand is from head in both x and y directions
            double deltaX = Math.Abs(rightHand.Position.X - head.Position.X);
            double deltaY = Math.Abs(rightHand.Position.Y - head.Position.Y);

            double headelbowXDifferential = rightElbow.Position.X - head.Position.X;

            if (deltaY < 0.05 &&
                rightHand.Position.Y > rightElbow.Position.Y &&
                rightElbow.Position.Y > rightShoulder.Position.Y &&
                deltaX < 0.3 &&
                headelbowXDifferential > 0.2)
            {
                // Birdwatcher!
                InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_Y); // show augmented reality (twitter layer)
            }
            else
            {
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_Y))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_Y);
                }
            }
        }
コード例 #3
0
ファイル: Helpers.cs プロジェクト: Xyaren/CoverMe
 /// <summary>
 /// Checks wether one of the keys in the given list is pressed
 /// </summary>
 /// <param name="keys">A list of virtual keys</param>
 /// <returns>True if at least one key is pressed, otherwise false</returns>
 public static bool IsOneKeyDown(List <VirtualKeyCode> keys)
 {
     foreach (VirtualKeyCode key in keys)
     {
         if (InputSimulator.IsKeyDown(key))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
        /// <summary>
        /// Process shoulder turning. Calculates the depth difference between shoulders.
        /// </summary>
        /// <param name="rightShoulder"></param>
        /// <param name="leftShoulder"></param>
        /// <returns></returns>
        private Boolean detectShoulderTurning(Joint rightShoulder, Joint leftShoulder)
        {
            double shoulderDepthDifferential = leftShoulder.Position.Z - rightShoulder.Position.Z;

            if (shoulderDepthDifferential > turnSlowThresh)
            {
                if (shoulderDepthDifferential > turnFastThresh)
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.OEM_COMMA);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_K);
                }
                return(true);
            }
            else if (shoulderDepthDifferential < -turnSlowThresh)
            {
                if (shoulderDepthDifferential < -turnFastThresh)
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.OEM_PERIOD);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_L);
                }
                return(true);
            }
            else
            {
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_L))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_L);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_K))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_K);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_COMMA))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.OEM_COMMA);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_PERIOD))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.OEM_PERIOD);
                }
                return(false);
            }
        }
コード例 #5
0
        public static string GetInputAsAString()
        {
            //This isn't even used... so much for refactoring. Leaving just bcuz...
            //string inputString = "";
            inputString.Clear();

            foreach (var keyCode in Enum.GetValues(typeof(VirtualKeyCode)).Cast <VirtualKeyCode>())
            {
                if (InputSimulator.IsKeyDown(keyCode))
                {
                    inputString.Append(FormatString(keyCode.ToString()));
                }
            }

            return(inputString.ToString());
        }
コード例 #6
0
ファイル: Trigger.cs プロジェクト: Xyaren/CoverMe
        /// <summary>
        /// Checks wether the this trigger's criteria are met and it is triggered
        /// </summary>
        /// <returns>True if the user has triggered an action, otherwise false</returns>
        public bool isTriggered()
        {
            // Trigger whenever user types T-4-1/2
            if (useSmartTrigger)
            {
                if (Helpers.IsOneKeyDown(triggerKeys))
                {
                    if (smartTriggerStage != 1)
                    {
                        Logger.log("SmartTrigger stage is now 1");
                    }

                    smartTriggerStage = 1;
                    Helpers.RestartStopwatch(smartTriggerTimeoutWatch);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_4) && smartTriggerStage == 1 && smartTriggerTimeoutWatch.ElapsedMilliseconds < smartTriggerTimeout)
                {
                    if (smartTriggerStage != 2)
                    {
                        Logger.log("SmartTrigger stage is now 2");
                    }
                    smartTriggerStage = 2;
                    Helpers.RestartStopwatch(smartTriggerTimeoutWatch);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_1) || InputSimulator.IsKeyDown(VirtualKeyCode.VK_2))
                {
                    if (smartTriggerStage == 2 && smartTriggerTimeoutWatch.ElapsedMilliseconds < smartTriggerTimeout)
                    {
                        Logger.log("SmartTrigger is now triggered");
                        smartTriggerStage = 0;
                        return(true);
                    }
                }
            }
            // Trigger when user presses set key
            else
            {
                if (Helpers.IsOneKeyDown(triggerKeys))
                {
                    Logger.log("Simple trigger is now triggered");
                    return(true);
                }
            }

            return(false);
        }
コード例 #7
0
        private static IntPtr HookCallback(
            int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN) || wParam == (IntPtr)WM_SYSCOMMAND || wParam == (IntPtr)WM_SYSKEYDOWN)
            {
                InterceptMouse.stpWtch.Stop();
                Recorder.CaptureQueue.Enqueue("[" + (InterceptMouse.stpWtch.ElapsedMilliseconds + 1) + "];");
                InterceptMouse.stpWtch.Reset();
                InterceptMouse.stpWtch.Start();

                int vkCode = Marshal.ReadInt32(lParam);
                if ((VirtualKeyCode)vkCode == VirtualKeyCode.F10)
                {
                    Recorder.endKeyCaught.Set();
                }
                else if ((VirtualKeyCode)vkCode != VirtualKeyCode.LSHIFT && (VirtualKeyCode)vkCode != VirtualKeyCode.RSHIFT &&
                         (VirtualKeyCode)vkCode != VirtualKeyCode.LCONTROL && (VirtualKeyCode)vkCode != VirtualKeyCode.RCONTROL &&
                         (VirtualKeyCode)vkCode != VirtualKeyCode.RMENU && (VirtualKeyCode)vkCode != VirtualKeyCode.LMENU)
                {
                    string keypress = string.Empty;
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.SHIFT))
                    {
                        keypress += "SHIFT&";
                    }
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.CONTROL))
                    {
                        keypress += "CONTROL&";
                    }
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.MENU))
                    {
                        keypress += "ALT&";
                    }
                    keypress += vkCode;
                    Recorder.CaptureQueue.Enqueue("(" + keypress + ");");
                }
            }
            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        }
コード例 #8
0
        /// <summary>
        /// Process walking/running. Calculates how far forward the right foot
        /// is from the left foot.
        /// </summary>
        /// <param name="rightFoot"></param>
        /// <param name="leftFoot"></param>
        private void detectWalking(Joint rightFoot, Joint leftFoot)
        {
            double feetDifferential = leftFoot.Position.Z - rightFoot.Position.Z;

            // Move forward
            if (feetDifferential > walkThresh)
            {
                if (feetDifferential > runThresh)
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_2);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
                }
            }
            // Move backward
            else if (feetDifferential < -walkThresh)
            {
                InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
            }
            else
            {
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_W))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_S))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                }
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_2))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_2);
                }
            }
        }
コード例 #9
0
        public static void calculateMovement(List <TileNode> path)
        {
            path.Reverse();

            // ModCore.CoreMonitor.Log("PATH COUNT TIME!!!!: " + path.Count);
            bool            xTargetReached = false;
            bool            yTargetReached = false;
            List <TileNode> removalList    = new List <TileNode>();

            if (path.Count == 0)
            {
                return;
            }
            while (path.Count > 0)
            {
                TileNode w = path[0];

                // ModCore.CoreMonitor.Log("Here: " +Game1.player.position.ToString());
                //  ModCore.CoreMonitor.Log("LOC: " + Game1.player.currentLocation);
                Vector2 center2 = Utilities.parseCenterFromTile((int)w.tileLocation.X, (int)w.tileLocation.Y);
                // ModCore.CoreMonitor.Log("Goto: " + center2);
                //ModCore.CoreMonitor.Log("My position now: " + Game1.player.getTileLocation());
                //ModCore.CoreMonitor.Log("My Point position now: " + Game1.player.getTileLocationPoint());

                if (Game1.player.getTileX() == w.tileLocation.X && Game1.player.getTileY() == w.tileLocation.Y)
                {
                    removalList.Add(w);

                    path.Remove(w);
                    xTargetReached = false;
                    yTargetReached = false;

                    //ModCore.CoreMonitor.Log("LOOOP", LogLevel.Debug);
                    // return;
                    continue;
                }
                else
                {
                    Vector2 center = Utilities.parseCenterFromTile((int)w.tileLocation.X, (int)w.tileLocation.Y);

                    while (Game1.player.position.X > center.X && xTargetReached == false)
                    {
                        if (Utilities.isWithinRange(Game1.player.position.X, center.X, 6) == true)
                        {
                            //ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
                            xTargetReached = true;
                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
                            //break;
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_A) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_A);
                        }
                    }


                    while (Game1.player.position.X < center.X && xTargetReached == false)
                    {
                        //ModCore.CoreMonitor.Log("Player x: " + Game1.player.position.X);
                        //ModCore.CoreMonitor.Log("center x: " + center.X);
                        if (Utilities.isWithinRange(Game1.player.position.X, center.X, 6) == true)
                        {
                            xTargetReached = true;
                            //ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_D) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
                        }
                    }



                    while (Game1.player.position.Y < center.Y && yTargetReached == false)
                    {
                        //ModCore.CoreMonitor.Log("banana");
                        if (Utilities.isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
                        {
                            yTargetReached = true;
                            //ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");

                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_S) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
                        }
                    }



                    while (Game1.player.position.Y > center.Y && yTargetReached == false)
                    {
                        //ModCore.CoreMonitor.Log("potato");
                        if (Utilities.isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
                        {
                            yTargetReached = true;
                            // ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");
                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_W) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
                        }
                    }


                    if (xTargetReached == true && yTargetReached == true)
                    {
                        removalList.Add(w);

                        path.Remove(w);
                        xTargetReached = false;
                        yTargetReached = false;


                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                        //return;
                        //ModCore.CoreMonitor.Log("Reached goal!", LogLevel.Error);
                        //Game1.player.position = new Vector2(center.X, center.Y);
                        continue;
                    }


                    ModCore.CoreMonitor.Log("UNCAUGHT EXCEPTION", LogLevel.Error);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                }
            }
            foreach (var v in removalList)
            {
                //v.thisLocation.objects.Remove(v.tileLocation);
                //v.thisLocation.removeObject(v.tileLocation, false);
                //v.performRemoveAction(v.tileLocation, v.thisLocation);
                //StardustCore.Utilities.masterRemovalList.Add(v);
                v.thisLocation.objects.Remove(v.tileLocation);
                //ModCore.CoreMonitor.Log("WHUT???"+v.tileLocation);
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
                //var ok = v;
                //ok = null;
            }
            //goals.Clear();
        }
コード例 #10
0
        //string de ação


        public void Executa(string action, string oq)
        {
            //possiveis casos
            // "fechar"  "minimizar", "maximizar", "pesquisar" "bloquear", "trocar"    "voltar"   "escolher" selecionar
            // guia/tela    tela/janela/tudo                   computador   guia/tela   guia/tela    tela
            if (action.ToLower() != "escolher" && action.ToLower() != "selecionar" && action.ToLower() != "voltar" && action.ToLower() != "avançar")
            {
                if (InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                }
            }
            switch (action.ToLower())
            {
            case "fechar":
                if (oq.ToLower() == "guia")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.F4);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LMENU);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.F4);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                }

                break;

            case "trocar":
                if (oq.ToLower() == "guia")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT);
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LMENU);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT);
                }

                break;

            case "voltar":
                if ((oq.ToLower() == "tela" || oq.ToLower() == "janela") && InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT);
                }
                else if (oq.ToLower() == "guia")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LMENU);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                }

                break;

            case "escolher":
                if ((oq.ToLower() == "tela" || oq.ToLower() == "janela") && !InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LMENU);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                }
                else if (InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                }
                break;

            case "selecionar":
                if ((oq.ToLower() == "tela" || oq.ToLower() == "janela") && !InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LMENU);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                }
                else if ((oq.ToLower() == "tudo") && !InputSimulator.IsKeyDown(VirtualKeyCode.CONTROL))
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_A);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                }
                else if (InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                }
                break;

            case "avançar":
                if ((oq.ToLower() == "tela" || oq.ToLower() == "janela") && InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
                {
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                }
                //InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                else if (oq.ToLower() == "guia")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                }
                break;

            case "maximizar":
                if (oq.ToLower() == "tudo")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_M);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LWIN);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.UP);
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                }
                break;

            case "minimizar":
                if (oq.ToLower() == "tudo")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_M);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LWIN);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN);
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                }
                break;

            case "bloquear":
                InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                InputSimulator.SimulateKeyDown(VirtualKeyCode.LMENU);
                InputSimulator.SimulateKeyPress(VirtualKeyCode.DELETE);
                InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                InputSimulator.SimulateKeyUp(VirtualKeyCode.LMENU);
                break;

            case "escrever":

                // InputSimulator.SimulateKeyPress(VirtualKeyCode.LWIN);
                // InputSimulator.SimulateTextEntry(oq);

                InputSimulator.SimulateTextEntry(oq);


                break;

            case "pesquisar":

                InputSimulator.SimulateKeyPress(VirtualKeyCode.LWIN);
                // InputSimulator.SimulateTextEntry(oq);

                //InputSimulator.SimulateTextEntry(oq);

                break;

            case "criar_nova":
                if (oq.ToLower() == "guia")
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_T);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                }
                break;

            default:

                break;
            }
        }
コード例 #11
0
    public void checkInputs()
    {
        if (InputSimulator.IsKeyDown(VirtualKeyCode.UP))
        {
            _ShouldMouseUp = true;
        }
        else
        {
            _ShouldMouseUp = false;
        }

        if (InputSimulator.IsKeyDown(VirtualKeyCode.DOWN))
        {
            _ShouldMouseDown = true;
        }
        else
        {
            _ShouldMouseDown = false;
        }

        if (InputSimulator.IsKeyDown(VirtualKeyCode.LEFT))
        {
            _ShouldMouseLeft = true;
        }
        else
        {
            _ShouldMouseLeft = false;
        }

        if (InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT))
        {
            _ShouldMouseRight = true;
        }
        else
        {
            _ShouldMouseRight = false;
        }
        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_1))
        {
            _IsLeftClicking = true;
        }
        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_2))
        {
            _IsRightClicking = true;
        }
        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_3))
        {
            _ShouldDoubleClick = true;
        }
        else
        {
            _ShouldDoubleClick = false;
        }

        if (!InputSimulator.IsKeyDown(VirtualKeyCode.VK_1) && _IsLeftClicking)
        {
            _ShouldLeftClick = true;
            _IsLeftClicking  = false;
        }

        if (!InputSimulator.IsKeyDown(VirtualKeyCode.VK_2) && _IsRightClicking)
        {
            _ShouldRightClick = true;
            _IsRightClicking  = false;
        }
    }
コード例 #12
0
        public static HashSet <VirtualKeyCodeHolder> GetPressedVirtualKeyCodeHoldersThatAreModifiers()
        {
            var virtualKeyCodeHolders = new HashSet <VirtualKeyCodeHolder>();

            if (InputSimulator.IsKeyDown(VirtualKeyCode.LSHIFT))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.LSHIFT));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.RSHIFT))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.RSHIFT));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.LCONTROL))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.LCONTROL));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.RCONTROL))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.RCONTROL));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.LWIN))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.LWIN));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.RWIN))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.RWIN));
            }

            /*
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F1))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F1));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F2))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F2));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F3))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F3));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F4))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F4));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F5))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F5));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F6))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F6));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F7))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F7));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F8))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F8));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F9))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F9));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F10))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F10));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F11))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F11));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.F12))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.F12));
             * }
             */
            if (InputSimulator.IsKeyDown(VirtualKeyCode.END))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.END));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.DELETE))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.DELETE));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.INSERT))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.INSERT));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.HOME))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.HOME));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.LEFT))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.LEFT));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.RIGHT));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.UP))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.UP));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.DOWN))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.DOWN));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.DIVIDE))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.DIVIDE));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.MULTIPLY))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.MULTIPLY));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.SUBTRACT))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.SUBTRACT));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.ADD))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.ADD));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.RETURN))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.RETURN));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMLOCK))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMLOCK));
            }

            /*
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD0))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD0));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD1))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD1));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD2))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD2));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD3))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD3));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD4))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD4));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD5))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD5));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD6))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD6));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD7))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD7));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD8))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD8));
             * }
             * if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD9))
             * {
             *  virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.NUMPAD9));
             * }*/
            if (InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.LMENU));
            }
            if (InputSimulator.IsKeyDown(VirtualKeyCode.RMENU))
            {
                virtualKeyCodeHolders.Add(new VirtualKeyCodeHolder(VirtualKeyCode.RMENU));
            }
            return(virtualKeyCodeHolders);
        }
コード例 #13
0
        private async void App_OnStartup(object sender, StartupEventArgs e)
        {
            TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            try
            {
                using (var key = Registry.LocalMachine.OpenSubKey("Software", true))
                    using (var panacea = key.CreateSubKey("Panacea"))
                        using (var launcher = panacea.CreateSubKey("Launcher"))
                        {
                            var disabled = (int)launcher.GetValue("Disabled", 0);
                            if (disabled == 1)
                            {
                                Enabled = false;
                            }
                            _lockFsDisabled = (int)launcher.GetValue("LockFsDisabled", 0) == 1;
                        }
            }
            catch
            {
            }
            LockFileSystem();
            _settings          = new SettingsWindow();
            _settings.Closing += (s, args) =>
            {
                _isSettingsWindowOpen = false;
            };
            int _showDev = 0;

            HookManager.KeyDown += (o, ee) =>
            {
                if (!InputSimulator.IsKeyDown(VirtualKeyCode.LCONTROL) || !InputSimulator.IsKeyDown(VirtualKeyCode.VK_Q))
                {
                    return;
                }
                if (ee.KeyCode == Keys.D0 && _showDev == 0)
                {
                    ee.Handled = true;
                    _showDev   = 1;
                    return;
                }
                if (ee.KeyCode == Keys.D9 && _showDev == 1)
                {
                    ee.Handled = true;
                    _showDev   = 2;
                    return;
                }
                if (ee.KeyCode == Keys.D8 && _showDev == 2)
                {
                    _showDev   = 0;
                    ee.Handled = true;
                    ShowUI();
                    return;
                }
                _showDev = 0;
            };

            var appsToCheck             = new Dictionary <string, Dictionary <string, string> >();
            int registrySkipReadCounter = 7;

            if (e.Args.Contains("/show"))
            {
                ShowUI();
            }
            try
            {
                await Task.Run(async() =>
                {
                    while (true)
                    {
                        try
                        {
                            await Task.Delay(1200);

                            if (!Enabled)
                            {
                                continue;
                            }

                            if (registrySkipReadCounter > 6)
                            {
                                registrySkipReadCounter = 0;
                                appsToCheck             = GetAppsToCheck();
                            }
                            else
                            {
                                registrySkipReadCounter++;
                            }

                            foreach (var group in appsToCheck.Keys)
                            {
                                bool running = CheckGroupOfApps(appsToCheck[group]);
                                if (!running)
                                {
                                    await Task.Delay(4000);                 //let some time just to make sure
                                    running = CheckGroupOfApps(appsToCheck[group]);
                                }
                                if (!Enabled || running)
                                {
                                    continue;
                                }

                                try
                                {
                                    var g       = group;
                                    var modules = (from app in appsToCheck[g].Keys
                                                   where !string.IsNullOrEmpty(app)
                                                   let process = Process.GetProcessesByName(app).FirstOrDefault()
                                                                 where process != null

                                                                 select $"{app}: {string.Join(", ", process.Modules)}");
                                    Log(
                                        $"No application found for group '{group}'. Launching default '{appsToCheck[@group][""]}'. {string.Join(Environment.NewLine, modules)}", EventLogEntryType.Warning);
                                    Process.Start(Common.Path() + "../../" + appsToCheck[group][""]);
                                }
                                catch (Exception ex)
                                {
                                    Log(String.Format("Failed to launch '{0}'. '{1}'", appsToCheck[group][""], ex.Message),
                                        EventLogEntryType.FailureAudit);
                                }
                            }
                        }
                        catch (Exception ex) {
                            Log(String.Format("Exception '{0}'", ex.Message), EventLogEntryType.Warning);
                        }
                    }
                });
            }
            catch
            {
                //closed
            }
        }
コード例 #14
0
        /// <summary>
        /// Process jetpack gesture.
        /// Both hands should be at the same level in the y direction.
        /// Shoulder and elbow must line up in the x direction.
        /// Forearms horizontal to ground = hover
        /// Forearms angled above horizontal = go up
        /// angled below = go down
        /// </summary>
        /// <param name="rightHand"></param>
        /// <param name="rightElbow"></param>
        /// <param name="rightShoulder"></param>
        /// <param name="leftHand"></param>
        /// <param name="leftElbow"></param>
        /// <param name="leftShoulder"></param>
        private void detectJetPackUp(Joint rightHand, Joint rightElbow, Joint rightShoulder,
                                     Joint leftHand, Joint leftElbow, Joint leftShoulder)
        {
            // right shoulder elbow x difference
            double rightShoulderElbowDiffX = Math.Abs(rightShoulder.Position.X - rightElbow.Position.X);

            // right elbow hand y difference
            double rightElbowHandDiffY = Math.Abs(rightElbow.Position.Y - rightHand.Position.Y);

            // left shoulder elbow x difference
            double leftShoulderElbowDiffX = Math.Abs(leftShoulder.Position.X - leftElbow.Position.X);

            // left elbow hand y difference
            double leftElbowHandDiffY = Math.Abs(leftElbow.Position.Y - leftHand.Position.Y);

            if (rightShoulderElbowDiffX < JetPackThresh &&
                leftShoulderElbowDiffX < JetPackThresh)    // elbows and shoulders aligned along x-axis
            {
                if (rightElbowHandDiffY < JetPackThresh &&
                    leftElbowHandDiffY < JetPackThresh)
                { //hover
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_U))
                    {
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_U);
                    }
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_J))
                    {
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_J);
                    }
                }
                else if (rightHand.Position.Y < rightElbow.Position.Y && leftHand.Position.Y < leftElbow.Position.Y)
                { //down
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_U))
                    {
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_U);
                    }
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_J);
                }
                else if (rightHand.Position.Y > rightElbow.Position.Y && leftHand.Position.Y > leftElbow.Position.Y &&
                         rightHand.Position.Y < rightShoulder.Position.Y && leftHand.Position.Y < leftShoulder.Position.Y)
                { //up
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_J))
                    {
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_J);
                    }
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_U);
                }
                else
                {
                    if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_U))
                    {
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_U);
                    }
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_J);
                }
            }
            else
            {
                if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_U))
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_U);
                }
                InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_J);
            }
        }
コード例 #15
0
    // Update is called once per frame
    void Update()
    {
        if ((InputSimulator.IsKeyDown(left) || InputSimulator.IsKeyDown(right)) && k > 500)
        {
            InputSimulator.SimulateKeyUp(left);
            InputSimulator.SimulateKeyUp(right);
            k = 0;
        }
        else
        {
            k++;
        }

        for (int i = 0; i <= 6; i++)
        {
            if (i != 6 && zones.zoneStatuses[2 * i] && zones.zoneStatuses[(2 * i) + 1])
            {
                sameZone = true;
                break;
            }
            else if (i == 6)
            {
                sameZone = false;
            }
        }
        if (sameZone)
        {
            // StartCoroutine(followAndAttack());

            if (sameZone && Mathf.Abs((player1.position.x - computer.position.x)) < 10)
            {
                if (sameZone && player1.position.x > computer.position.x)
                {
                    //InputSimulator.SimulateKeyUp(left);
                    InputSimulator.SimulateKeyPress(right);
                    InputSimulator.SimulateKeyPress(attack);
                }
                else if (sameZone)
                {
                    //InputSimulator.SimulateKeyUp(right);
                    InputSimulator.SimulateKeyPress(left);
                    InputSimulator.SimulateKeyPress(attack);
                }
            }
            else if (sameZone && player1.position.x > computer.position.x)
            {
                //InputSimulator.SimulateKeyUp(left);
                InputSimulator.SimulateKeyPress(right);
            }
            else if (sameZone && player1.position.x < computer.position.x)
            {
                // InputSimulator.SimulateKeyUp(right);
                InputSimulator.SimulateKeyPress(left);
            }
        }

        else if (zones.zoneStatuses[FloorP2])
        {
            if (zones.zoneStatuses[MiddleCenterRightP1] || zones.zoneStatuses[MiddleRightP1])
            {
                if (Mathf.Abs(computer.transform.position.x - floorWayPoint) < 5)
                {
                    InputSimulator.SimulateKeyUp(left);
                    InputSimulator.SimulateKeyDown(right);
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyPress(jump);
                    // InputSimulator.SimulateKeyPress(right);
                    //InputSimulator.SimulateKeyPress(right);
                }
                else if (computer.transform.position.x < floorWayPoint)
                {
                    InputSimulator.SimulateKeyPress(right);
                }
                else
                {
                    InputSimulator.SimulateKeyPress(left);
                }
            }
            else if (zones.zoneStatuses[MiddleCenterLeftP1] || zones.zoneStatuses[MiddleLeftP1] || zones.zoneStatuses[TopP1])
            {
                if (Mathf.Abs(computer.transform.position.x - floorWayPoint) < 5)
                {
                    InputSimulator.SimulateKeyUp(right);
                    InputSimulator.SimulateKeyDown(left);
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyPress(jump);
                    // InputSimulator.SimulateKeyPress(right);
                    //InputSimulator.SimulateKeyPress(right);
                }
                else if ((computer.transform.position.x < floorWayPoint) && (zones.zoneStatuses[MiddleCenterLeftP1] || zones.zoneStatuses[MiddleLeftP1] || zones.zoneStatuses[TopP1]))
                {
                    InputSimulator.SimulateKeyPress(right);
                }
                else if ((computer.transform.position.x > floorWayPoint) && (zones.zoneStatuses[MiddleCenterLeftP1] || zones.zoneStatuses[MiddleLeftP1] || zones.zoneStatuses[TopP1]))
                {
                    InputSimulator.SimulateKeyPress(left);
                }
            }
        }
        else if (zones.zoneStatuses[MiddleCenterLeftP2])
        {
            if (zones.zoneStatuses[FloorP1])
            {
                InputSimulator.SimulateKeyPress(right);
            }
            else if (zones.zoneStatuses[MiddleCenterRightP1])
            {
                if (Mathf.Abs(computer.transform.position.x - leftCenterWayPoint2) < 5)
                {
                    InputSimulator.SimulateKeyUp(left);
                    InputSimulator.SimulateKeyDown(right);
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyPress(jump);
                }
                else if (computer.position.x < leftCenterWayPoint2)
                {
                    InputSimulator.SimulateKeyPress(right);
                }
            }
            else if (zones.zoneStatuses[MiddleLeftP1] || zones.zoneStatuses[TopP1])
            {
                if (Mathf.Abs(computer.transform.position.x - leftCenterWayPoint1) < 5)
                {
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyUp(right);
                    InputSimulator.SimulateKeyDown(left);
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyPress(jump);
                }
                else if (computer.position.x > leftCenterWayPoint1)
                {
                    InputSimulator.SimulateKeyPress(left);
                }
            }
        }
        else if (zones.zoneStatuses[MiddleCenterRightP2])
        {
            if (zones.zoneStatuses[FloorP1])
            {
                InputSimulator.SimulateKeyPress(left);
            }
            else if (zones.zoneStatuses[MiddleCenterLeftP1])
            {
                if (Mathf.Abs(computer.transform.position.x - rightCenterWayPoint1) < 5)
                {
                    InputSimulator.SimulateKeyUp(right);
                    InputSimulator.SimulateKeyDown(left);
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyPress(jump);
                }
                else if (computer.position.x > rightCenterWayPoint1)
                {
                    InputSimulator.SimulateKeyPress(left);
                }
            }
            else if (zones.zoneStatuses[MiddleRightP1])
            {
                if (Mathf.Abs(computer.transform.position.x - rightCenterWayPoint2) < 5)
                {
                    InputSimulator.SimulateKeyUp(left);
                    InputSimulator.SimulateKeyDown(right);
                    InputSimulator.SimulateKeyPress(jump);
                    InputSimulator.SimulateKeyPress(jump);
                }
                else if (computer.position.x < rightCenterWayPoint2)
                {
                    InputSimulator.SimulateKeyPress(right);
                }
            }
        }
        else if (!sameZone && zones.zoneStatuses[MiddleRightP2])
        {
            InputSimulator.SimulateKeyUp(right);
            InputSimulator.SimulateKeyDown(left);
            InputSimulator.SimulateKeyPress(jump);
            InputSimulator.SimulateKeyPress(jump);
        }
        else if (!sameZone && zones.zoneStatuses[MiddleLeftP2])
        {
            InputSimulator.SimulateKeyUp(left);
            InputSimulator.SimulateKeyDown(right);
            InputSimulator.SimulateKeyPress(jump);
            StartCoroutine(secondJump());
            // InputSimulator.SimulateKeyPress(jump);
        }
        else if (!sameZone && zones.zoneStatuses[TopP2])
        {
            InputSimulator.SimulateKeyPress(right);
        }



        else if (zones.zoneStatuses[LeftDeathP2])
        {
            InputSimulator.SimulateKeyUp(left);
            InputSimulator.SimulateKeyPress(jump);
            InputSimulator.SimulateKeyDown(right);
        }
        else if (zones.zoneStatuses[RightDeathP2])
        {
            InputSimulator.SimulateKeyUp(right);
            InputSimulator.SimulateKeyPress(jump);
            InputSimulator.SimulateKeyDown(left);
        }



        //StartCoroutine(jumpToRight());



        // }
        //}

        /* else
         * {
         *   InputSimulator.SimulateKeyUp(left);
         *   InputSimulator.SimulateKeyUp(right);
         * }
         */


        /*
         *   IEnumerator jumpToRight()
         * {
         *   while (zones.zoneStatuses[FloorP2] && zones.zoneStatuses[MiddleCenterLeftP1])
         *   {
         *
         *       if (Mathf.Abs(computer.position.x - HalfScreenWidth) < 20)
         *       {
         *           InputSimulator.SimulateKeyPress(right);
         *           InputSimulator.SimulateKeyPress(jump);
         *           yield return new WaitForSeconds(.5f);
         *           InputSimulator.SimulateKeyPress(jump);
         *       }
         *
         *       else if (computer.position.x >= HalfScreenWidth)
         *       {
         *           //InputSimulator.SimulateKeyUp(right);
         *           InputSimulator.SimulateKeyPress(left);
         *           Debug.Log("left");
         *       }
         *       else if (computer.position.x < HalfScreenWidth - 20)
         *       {
         *           // InputSimulator.SimulateKeyUp(left);
         *           InputSimulator.SimulateKeyPress(right);
         *           Debug.Log("right");
         *       }
         *   }
         *
         *
         *
         *
         *
         *
         *
         *   //InputSimulator.SimulateKeyUp(right);
         * }
         */
    }
コード例 #16
0
ファイル: Play.cs プロジェクト: tempaccount140/osu-Tool
        public void Run(ref Osu osu, ref OsuBeatmap beatmap)
        {
            // Check if correct beatmap is selected and is being played.
            if (beatmap == null || beatmap.Mode != BeatmapMode.Standard || !osu.IsMapPlaying())
            {
                return;
            }

            int time = osu.GetAudioTime();

            int hitObjectIndex                     = 0;
            BeatmapHitObject hitObject             = beatmap.HitObjects[hitObjectIndex];
            float            hitObjectRadiusScaled = beatmap.HitObjectRadius * xMultiplier;

            float hitWindow300 = OsuGameRules.GetHitWindow300(beatmap.Difficulty.OverallDifficulty);
            float hitWindow100 = OsuGameRules.GetHitWindow100(beatmap.Difficulty.OverallDifficulty);
            float hitWindow50  = OsuGameRules.GetHitWindow50(beatmap.Difficulty.OverallDifficulty);

            // Can't even change the keys from UI.
            // 2017 programming LUL
            VirtualKeyCode primaryKey   = VirtualKeyCode.VK_Z;
            VirtualKeyCode secondaryKey = VirtualKeyCode.VK_X;
            VirtualKeyCode allow100Key  = VirtualKeyCode.SPACE;

            VirtualKeyCode activeKey = primaryKey;
            bool           keyDown   = false;

            // Default click window will simply be the timing offset.
            int clickWindow = Settings.Default.TimingOffset;

            float clickWindow300Min = -Math.Abs(hitWindow300) / 2.0f;
            float clickWindow300Max = Math.Abs(hitWindow300) / 2.0f;
            float clickWindow100Min = -Math.Abs(hitWindow100) / 1.5f;
            float clickWindow100Max = Math.Abs(hitWindow100) / 1.5f;

            // This needs tweaking for sure. Take into account if DT is enabled, otherwise it can hold active key for too long.
            float extraHoldTime    = hitWindow300;
            float extraHoldTimeMin = extraHoldTime;
            float extraHoldTimeMax = extraHoldTime * 2.0f;

            float speedMultiplier = 1;

            if (Settings.Default.DoubleTime)
            {
                speedMultiplier = 1.5f;
            }
            else if (Settings.Default.HalfTime)
            {
                speedMultiplier = 0.75f;
            }

            float userSetBPM = Settings.Default.SingleTapMaxBPM / speedMultiplier / 2.0f;

            Random random = new Random();

            while (hitObjectIndex <= beatmap.HitObjects.Capacity)
            {
                // Check if map is still playing.
                if (!osu.IsMapPlaying())
                {
                    break;
                }

                bool waiting = false;

                if (Settings.Default.HitScan && !hitObject.IsSpinner && !IsCursorOnCircle(GetScaledX(hitObject.X), GetScaledY(hitObject.Y), hitObjectRadiusScaled, Settings.Default.HitScanPixelOffset))
                {
                    waiting = true;
                }

                time = osu.GetAudioTime();

                if (Settings.Default.RandomizeKeyTimings)
                {
                    extraHoldTime = GetRandomNumber(random, extraHoldTimeMin, extraHoldTimeMax);

                    if (InputSimulator.IsKeyDown(allow100Key))
                    {
                        clickWindow = random.Next((int)clickWindow100Min, (int)clickWindow100Max) + Settings.Default.TimingOffset;
                    }
                    else
                    {
                        clickWindow = random.Next((int)clickWindow300Min, (int)clickWindow300Max) + Settings.Default.TimingOffset;
                    }
                }

                float startTime = hitObject.StartTime + clickWindow;
                float endTime   = hitObject.EndTime;

                // Only add extra hold time if the object is a circle OR it is a slider with hold time less than extra hold time.
                if (hitObject.IsCircle)
                {
                    endTime += extraHoldTime;
                }
                else if (hitObject.IsSlider && (endTime - startTime) < extraHoldTime)
                {
                    endTime = startTime + extraHoldTime;
                }

                if (time >= startTime && !keyDown && !waiting)
                {
                    if (Settings.Default.TappingStyle == 1 && !hitObject.IsSpinner && (hitObjectIndex + 1) <= beatmap.HitObjects.Count) // Single, not a spinner and next hit object exists.
                    {
                        BeatmapHitObject nextHitObject = beatmap.HitObjects[hitObjectIndex + 1];
                        int nextObjectBPM   = beatmap.MsPerBeatToBPM(nextHitObject.StartTime - hitObject.EndTime);
                        int userSetBPMFinal = (int)Math.Round(userSetBPM * beatmap.GetTimingPointFromOffset(time).Meter);

                        if (nextObjectBPM > userSetBPMFinal)
                        {
                            activeKey = (activeKey == primaryKey) ? secondaryKey : primaryKey;
                        }
                        else
                        {
                            activeKey = primaryKey;
                        }
                    }

                    // Hold active key.
                    InputSimulator.SimulateKeyDown(activeKey);
                    keyDown = true;
                }
                else if (time > endTime && keyDown)
                {
                    // Release active key.
                    InputSimulator.SimulateKeyUp(activeKey);
                    keyDown = false;

                    if (Settings.Default.TappingStyle == 0) // Alternate
                    {
                        activeKey = (activeKey == primaryKey) ? secondaryKey : primaryKey;
                    }

                    // Advance to the next hit object.
                    hitObjectIndex++;
                    hitObject = beatmap.HitObjects[hitObjectIndex];
                }
                // Can't get a 50 anymore, move on to the next object.
                else if (waiting && time > (hitObject.EndTime + hitWindow50))
                {
                    hitObjectIndex++;
                    hitObject = beatmap.HitObjects[hitObjectIndex];
                }

                // Release keys if game is paused to prevent accidentaly hitting a menu button.
                if (!osu.IsAudioPlaying() && keyDown)
                {
                    InputSimulator.SimulateKeyUp(activeKey);
                }

                Task.Delay(1).Wait();
            }

            // Make sure keys are released when done.
            if (keyDown)
            {
                InputSimulator.SimulateKeyUp(activeKey);
            }
        }
コード例 #17
0
 public static string GetInputAsAString()
 {
     //string inputString = "";
     inputString.Clear();
     if (InputSimulator.IsKeyDown(VirtualKeyCode.ACCEPT))
     {
         inputString.Append(FormatString(VirtualKeyCode.ACCEPT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.ADD))
     {
         inputString.Append(FormatString(VirtualKeyCode.ADD.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.APPS))
     {
         inputString.Append(FormatString(VirtualKeyCode.APPS.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.ATTN))
     {
         inputString.Append(FormatString(VirtualKeyCode.ATTN.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BACK))
     {
         inputString.Append(FormatString(VirtualKeyCode.BACK.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_BACK))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_BACK.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_FAVORITES))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_FAVORITES.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_FORWARD))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_FORWARD.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_HOME))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_HOME.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_REFRESH))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_REFRESH.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_SEARCH))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_SEARCH.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.BROWSER_STOP))
     {
         inputString.Append(FormatString(VirtualKeyCode.BROWSER_STOP.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.CANCEL))
     {
         inputString.Append(FormatString(VirtualKeyCode.CANCEL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.CAPITAL))
     {
         inputString.Append(FormatString(VirtualKeyCode.CAPITAL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.CLEAR))
     {
         inputString.Append(FormatString(VirtualKeyCode.CLEAR.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.CONTROL))
     {
         inputString.Append(FormatString(VirtualKeyCode.CONTROL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.CONVERT))
     {
         inputString.Append(FormatString(VirtualKeyCode.CONVERT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.CRSEL))
     {
         inputString.Append(FormatString(VirtualKeyCode.CRSEL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.DECIMAL))
     {
         inputString.Append(FormatString(VirtualKeyCode.DECIMAL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.DELETE))
     {
         inputString.Append(FormatString(VirtualKeyCode.DELETE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.DIVIDE))
     {
         inputString.Append(FormatString(VirtualKeyCode.DIVIDE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.DOWN))
     {
         inputString.Append(FormatString(VirtualKeyCode.DOWN.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.END))
     {
         inputString.Append(FormatString(VirtualKeyCode.END.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.EREOF))
     {
         inputString.Append(FormatString(VirtualKeyCode.EREOF.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.ESCAPE))
     {
         inputString.Append(FormatString(VirtualKeyCode.ESCAPE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.EXECUTE))
     {
         inputString.Append(FormatString(VirtualKeyCode.EXECUTE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.EXSEL))
     {
         inputString.Append(FormatString(VirtualKeyCode.EXSEL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F1))
     {
         inputString.Append(FormatString(VirtualKeyCode.F1.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F2))
     {
         inputString.Append(FormatString(VirtualKeyCode.F2.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F3))
     {
         inputString.Append(FormatString(VirtualKeyCode.F3.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F4))
     {
         inputString.Append(FormatString(VirtualKeyCode.F4.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F5))
     {
         inputString.Append(FormatString(VirtualKeyCode.F5.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F6))
     {
         inputString.Append(FormatString(VirtualKeyCode.F6.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F7))
     {
         inputString.Append(FormatString(VirtualKeyCode.F7.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F8))
     {
         inputString.Append(FormatString(VirtualKeyCode.F8.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F9))
     {
         inputString.Append(FormatString(VirtualKeyCode.F9.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F10))
     {
         inputString.Append(FormatString(VirtualKeyCode.F10.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F11))
     {
         inputString.Append(FormatString(VirtualKeyCode.F11.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.F12))
     {
         inputString.Append(FormatString(VirtualKeyCode.F12.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.FINAL))
     {
         inputString.Append(FormatString(VirtualKeyCode.FINAL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.HANGUL))
     {
         inputString.Append(FormatString(VirtualKeyCode.HANGUL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.HANJA))
     {
         inputString.Append(FormatString(VirtualKeyCode.HANJA.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.HELP))
     {
         inputString.Append(FormatString(VirtualKeyCode.HELP.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.HOME))
     {
         inputString.Append(FormatString(VirtualKeyCode.HOME.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.INSERT))
     {
         inputString.Append(FormatString(VirtualKeyCode.INSERT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.JUNJA))
     {
         inputString.Append(FormatString(VirtualKeyCode.JUNJA.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.KANA))
     {
         inputString.Append(FormatString(VirtualKeyCode.KANA.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.KANJI))
     {
         inputString.Append(FormatString(VirtualKeyCode.KANJI.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.LBUTTON))
     {
         inputString.Append(FormatString(VirtualKeyCode.LBUTTON.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.LCONTROL))
     {
         inputString.Append(FormatString(VirtualKeyCode.LCONTROL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.LEFT))
     {
         inputString.Append(FormatString(VirtualKeyCode.LEFT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.LMENU))
     {
         inputString.Append(FormatString(VirtualKeyCode.LMENU.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.LSHIFT))
     {
         inputString.Append(FormatString(VirtualKeyCode.LSHIFT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.LWIN))
     {
         inputString.Append(FormatString(VirtualKeyCode.LWIN.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.MBUTTON))
     {
         inputString.Append(FormatString(VirtualKeyCode.MBUTTON.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.MENU))
     {
         inputString.Append(FormatString(VirtualKeyCode.MENU.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.MULTIPLY))
     {
         inputString.Append(FormatString(VirtualKeyCode.MULTIPLY.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NEXT))
     {
         inputString.Append(FormatString(VirtualKeyCode.NEXT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMLOCK))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMLOCK.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD0))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD0.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD1))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD1.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD2))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD2.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD3))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD3.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD4))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD4.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD5))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD5.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD6))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD6.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD7))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD7.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD8))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD8.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.NUMPAD9))
     {
         inputString.Append(FormatString(VirtualKeyCode.NUMPAD9.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_1))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_1.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_2))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_2.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_3))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_3.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_4))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_4.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_5))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_5.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_6))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_6.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_7))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_7.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_8))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_8.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_CLEAR))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_CLEAR.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_COMMA))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_COMMA.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_MINUS))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_MINUS.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_PERIOD))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_PERIOD.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.OEM_PLUS))
     {
         inputString.Append(FormatString(VirtualKeyCode.OEM_PLUS.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.PAUSE))
     {
         inputString.Append(FormatString(VirtualKeyCode.PAUSE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.PLAY))
     {
         inputString.Append(FormatString(VirtualKeyCode.PLAY.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.PRINT))
     {
         inputString.Append(FormatString(VirtualKeyCode.PRINT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.PRIOR))
     {
         inputString.Append(FormatString(VirtualKeyCode.PRIOR.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RBUTTON))
     {
         inputString.Append(FormatString(VirtualKeyCode.RBUTTON.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RCONTROL))
     {
         inputString.Append(FormatString(VirtualKeyCode.RCONTROL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RETURN))
     {
         inputString.Append(FormatString(VirtualKeyCode.RETURN.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT))
     {
         inputString.Append(FormatString(VirtualKeyCode.RIGHT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RMENU))
     {
         inputString.Append(FormatString(VirtualKeyCode.RMENU.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RSHIFT))
     {
         inputString.Append(FormatString(VirtualKeyCode.RSHIFT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.RWIN))
     {
         inputString.Append(FormatString(VirtualKeyCode.RWIN.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SCROLL))
     {
         inputString.Append(FormatString(VirtualKeyCode.SCROLL.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SELECT))
     {
         inputString.Append(FormatString(VirtualKeyCode.SELECT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SEPARATOR))
     {
         inputString.Append(FormatString(VirtualKeyCode.SEPARATOR.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SHIFT))
     {
         inputString.Append(FormatString(VirtualKeyCode.SHIFT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SLEEP))
     {
         inputString.Append(FormatString(VirtualKeyCode.SLEEP.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SNAPSHOT))
     {
         inputString.Append(FormatString(VirtualKeyCode.SNAPSHOT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SPACE))
     {
         inputString.Append(FormatString(VirtualKeyCode.SPACE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.SUBTRACT))
     {
         inputString.Append(FormatString(VirtualKeyCode.SUBTRACT.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.TAB))
     {
         inputString.Append(FormatString(VirtualKeyCode.TAB.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.UP))
     {
         inputString.Append(FormatString(VirtualKeyCode.UP.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_0))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_0.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_1))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_1.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_3))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_3.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_4))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_4.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_5))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_5.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_6))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_6.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_7))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_7.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_8))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_8.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_9))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_9.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_A))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_A.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_B))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_B.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_C))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_C.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_D))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_D.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_E))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_E.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_F))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_F.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_G))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_G.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_H))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_H.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_I))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_I.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_J))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_J.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_K))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_K.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_L))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_L.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_M))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_M.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_N))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_N.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_O))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_O.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_P))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_P.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_Q))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_Q.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_R))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_R.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_S))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_S.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_T))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_T.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_U))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_U.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_V))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_V.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_W))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_W.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_X))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_X.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_Y))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_Y.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_Z))
     {
         inputString.Append(FormatString(VirtualKeyCode.VK_Z.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VOLUME_DOWN))
     {
         inputString.Append(FormatString(VirtualKeyCode.VOLUME_DOWN.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VOLUME_MUTE))
     {
         inputString.Append(FormatString(VirtualKeyCode.VOLUME_MUTE.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.VOLUME_UP))
     {
         inputString.Append(FormatString(VirtualKeyCode.VOLUME_UP.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.XBUTTON1))
     {
         inputString.Append(FormatString(VirtualKeyCode.XBUTTON1.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.XBUTTON2))
     {
         inputString.Append(FormatString(VirtualKeyCode.XBUTTON2.ToString()));
     }
     if (InputSimulator.IsKeyDown(VirtualKeyCode.ZOOM))
     {
         inputString.Append(FormatString(VirtualKeyCode.ZOOM.ToString()));
     }
     return(inputString.ToString());
 }
コード例 #18
0
 /// <summary>
 /// Determines whether the specified key is up or down by calling the GetKeyState function. (See: http://msdn.microsoft.com/en-us/library/ms646301(VS.85).aspx)
 /// </summary>
 /// <param name="keyCode">The <see cref="VirtualKeyCode"/> for the key.</param>
 /// <returns>
 ///     <c>true</c> if the key is down; otherwise, <c>false</c>.
 /// </returns>
 /// <remarks>
 /// The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.
 /// An application calls GetKeyState in response to a keyboard-input message. This function retrieves the state of the key when the input message was generated.
 /// To retrieve state information for all the virtual keys, use the GetKeyboardState function.
 /// An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL, and VK_MENU as values for the nVirtKey parameter. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also use the following virtual-key code constants as values for nVirtKey to distinguish between the left and right instances of those keys.
 /// VK_LSHIFT
 /// VK_RSHIFT
 /// VK_LCONTROL
 /// VK_RCONTROL
 /// VK_LMENU
 /// VK_RMENU
 ///
 /// These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
 /// </remarks>
 public bool IsKeyDown(VirtualKeyCode keyCode)
 {
     return(InputSimulator.IsKeyDown(keyCode));
 }
コード例 #19
0
 bool IsKeyDown(string actionCode)
 {
     return(InputSimulator.IsKeyDown((VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), actionCode)));
 }