Beispiel #1
0
        public Task ParseMessageReceived(WebSocketReceiveResult result)
        {
            string messageReceived = Encoding.Default.GetString(new ArraySegment <byte>(buffer, 0, result.Count));

            VirtualMouse.MouseCommand mc = VirtualMouse.JsonToMouseCommand(messageReceived);

            //Console.WriteLine("Parsing Command: " + mc);

            if (mc.command == "move")
            {
                mouse.Move(mc.x, mc.y);
            }

            else if (mc.command == "right_click")
            {
                mouse.RightClick();
            }
            else if (mc.command == "left_click")
            {
                mouse.LeftClick();
            }
            else if (mc.command == "left_down")
            {
                mouse.LeftDown();
            }
            else if (mc.command == "left_up")
            {
                mouse.LeftUp();
            }
            else if (mc.command == "right_down")
            {
                mouse.RightDown();
            }
            else if (mc.command == "right_up")
            {
                mouse.RightUp();
            }
            else if (mc.command == "touchpad_start")
            {
                mouse.TouchpadStart(mc.x, mc.y);
            }
            else if (mc.command == "touchpad_move")
            {
                mouse.TouchpadMove(mc.x, mc.y, (int)mc.extra);
            }
            else if (mc.command == "set_volume")
            {
                audio.SetVolume(mc.x);
            }
            else
            {
                return(Error());
            }

            return(Success());
        }
Beispiel #2
0
        public static void MoveTo(Vector3 position,
                                  float holdAreaRadius      = 0,
                                  bool overrideTimer        = false,
                                  bool useFixedDistance     = true,
                                  bool randomizeMinDistance = true)
        {
            if (LeagueSharp.Common.Utils.GameTimeTickCount - LastMoveCommandT < _delay && !overrideTimer)
            {
                return;
            }

            LastMoveCommandT = LeagueSharp.Common.Utils.GameTimeTickCount;

            if (Player.ServerPosition.Distance(position, true) < holdAreaRadius * holdAreaRadius)
            {
                if (Player.Path.Count() > 1)
                {
                    Player.IssueOrder((GameObjectOrder)10, Player.ServerPosition);
                    Player.IssueOrder(GameObjectOrder.HoldPosition, Player.ServerPosition);
                    LastMoveCommandPosition = Player.ServerPosition;
                }
                return;
            }

            var point = position;

            if (useFixedDistance)
            {
                point = Player.ServerPosition +
                        (randomizeMinDistance ? (_random.NextFloat(0.6f, 1) + 0.2f) * _minDistance : _minDistance) *
                        (position.To2D() - Player.ServerPosition.To2D()).Normalized().To3D();
            }
            else
            {
                if (randomizeMinDistance)
                {
                    point = Player.ServerPosition +
                            (_random.NextFloat(0.6f, 1) + 0.2f) * _minDistance *
                            (position.To2D() - Player.ServerPosition.To2D()).Normalized().To3D();
                }
                else if (Player.ServerPosition.Distance(position) > _minDistance)
                {
                    point = Player.ServerPosition +
                            _minDistance * (position.To2D() - Player.ServerPosition.To2D()).Normalized().To3D();
                }
            }

            Player.IssueOrder(GameObjectOrder.MoveTo, point);
            LastMoveCommandPosition = point;

            if (ChallengerPlugin.DrawingsMenu.Item("streamingmode").GetValue <bool>())
            {
                VirtualMouse.RightClick(point);
            }
        }
Beispiel #3
0
        internal static void OnUpdate(EventArgs args)
        {
            var hero  = ObjectManager.Player;
            var shops = ObjectManager.Get <Obj_Shop>();

            if (IsHeroNearShop())
            {
                if (hero.InShop())
                {
                    // get req. items from website --> buy them step by step
                }
                else
                {
                    VirtualMouse.RightClick(shop.Position);
                }
            }
            else
            {
                // close shop
            }
        }
Beispiel #4
0
        private void fish()
        {
            int tracker = GetControlPropertyThreadSafe(trackBar1, t => t.Value);

            VirtualMouse.RightClick();


            System.Threading.Thread.Sleep(1700);
            while (active)
            {
                var device = (MMDevice)GetControlPropertyThreadSafe(processList, t => t.SelectedItem);
                var curVol = (int)Math.Round(device.AudioMeterInformation.MasterPeakValue * 1000);
                if (curVol >= tracker)
                {
                    VirtualMouse.RightClick();
                    break;
                }
            }

            fished = fished + 1;
            System.Threading.Thread.Sleep(400);
        }
Beispiel #5
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                if (wasException)
                {
                    base.WndProc(ref m);
                    return;
                }


                if (!systemReady)
                {
                    if (m.Msg == NativeMethods.CM_STARTENGINE)
                    {
                        ActivateEngine();
                        return;
                    }

                    if ((m.Msg == NativeMethods.WM_CLOSE) || (m.Msg == NativeMethods.WM_QUIT) || (m.Msg == NativeMethods.WM_QUERYENDSESSION))
                    {
                        UnloadAll();
                    }
                    base.WndProc(ref m);
                    return;
                }
                else //do it only if the system is ready
                {
                    if (context.Dispatch(ref m))
                    {
                        return;
                    }

                    int code = m.Msg;
                    switch (code)
                    {
                    case NativeMethods.WM_ACTIVATEAPP:
                        // The WParam value identifies what is occurring.
                        bool appActive = (((int)m.WParam != 0));
                        {
                            if (GlobalSettings.HideOnClick)
                            {
                                if (!appActive)
                                {
                                    if (Manager.Visible && (!Manager.Fading))
                                    {
                                        if (!context.HookActive)
                                        {
                                            ChangeVisibility();
                                        }
                                    }
                                }
                            }
                        }
                        break;

                    case NativeMethods.WM_CLOSE:
                    case NativeMethods.WM_QUIT:
                        this.UnloadAll();
                        break;

                    case NativeMethods.WM_QUERYENDSESSION:
                        this.UnloadAll();
                        break;

                    case NativeMethods.CM_CHECKUPDATE:
                        ShowNewVersion();
                        break;

                    case NativeMethods.WM_POWERBROADCAST:
                        if (m.WParam == (IntPtr)NativeMethods.PBT_APMRESUMEAUTOMATIC)
                        {
                            context.HidePulsar();
                            if (Settings.Default.ShowPulsar)
                            {
                                Pulsar.RestoreAlpha();
                                Pulsar.Alpha = 60;
                                context.ShowPulsar();
                                Pulsar.DeactivatePulsar();
                            }
                        }
                        break;

                    case NativeMethods.CM_RBUTTONDOWN:
                    {
                        if (GlobalSettings.UseMouseActivation)
                        {
                            if (GlobalSettings.UseRightClick)
                            {
                                TraceDebug.Trace("CM_RBUTTONDOWN");
                                if (!trackRightDown)
                                {
                                    trackRightDown = true;
                                    if (!context.Manager.Visible)
                                    {
                                        timerIntercept.Enabled = true;
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case NativeMethods.CM_RBUTTONUP:
                    {
                        if (GlobalSettings.UseMouseActivation)
                        {
                            if (GlobalSettings.UseRightClick)
                            {
                                TraceDebug.Trace("CM_RBUTTONUP");
                                timerIntercept.Enabled = false;

                                if (trackRightDown)
                                {
                                    trackRightDown = false;
                                    if (!trackRightUp)
                                    {
                                        trackRightUp = true;
                                        MouseHook.PauseIntercept();
                                        VirtualMouse.RightClick();
                                    }
                                    else
                                    {
                                        trackRightUp = false;
                                        MouseHook.ResumeIntercept();
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case NativeMethods.CM_MBUTTONUP:
                    case NativeMethods.CM_XBUTTONUP:

                        if (GlobalSettings.UseMouseActivation)
                        {
                            int             xButton    = (int)m.WParam;
                            MouseHookButton hookButton = MouseHookButton.None;

                            if (m.Msg == NativeMethods.CM_MBUTTONUP)
                            {
                                hookButton = MouseHookButton.Wheel;
                            }
                            else
                            {
                                switch (xButton)
                                {
                                case NativeMethods.XBUTTON1:
                                    hookButton = MouseHookButton.XButton1;
                                    break;

                                case NativeMethods.XBUTTON2:
                                    hookButton = MouseHookButton.XButton2;
                                    break;

                                default:
                                    hookButton = MouseHookButton.None;
                                    break;
                                }
                            }

                            if (GlobalSettings.MouseHook != hookButton)
                            {
                                return;
                            }

                            Keys modifiers = (Keys)m.LParam;

                            if (GlobalSettings.MouseModifiers != modifiers)
                            {
                                return;
                            }

                            ActivateUsingMouse(true);
                        }
                        return;

                    case NativeMethods.CM_DESKTOPCLICK:
                        if (GlobalSettings.UseMouseActivation)
                        {
                            if (Manager != null)
                            {
                                if (context.HookActive)
                                {
                                    return;
                                }

                                if (GlobalSettings.DesktopClick)
                                {
                                    ActivateUsingMouse(true);
                                }
                            }
                        }
                        return;

                    case NativeMethods.WM_HOTKEY:
                        if (NativeMethods.IsMetroActive())
                        {
                            return;
                        }
                        if (GlobalSettings.UseKeyboardActivation)
                        {
                            if (Manager != null)
                            {
                                if (context.HookActive)
                                {
                                    return;
                                }

                                if (GlobalSettings.CircleSelector)
                                {
                                    if (ringKeys != null)
                                    {
                                        if (((int)m.WParam) == (ringKeys.Id))
                                        {
                                            Manager.SwitchRing();
                                        }
                                    }
                                }

                                if (hotKeys != null)
                                {
                                    if (((int)m.WParam) == (hotKeys.Id))
                                    {
                                        if (Manager.Visible)
                                        {
                                            if (NativeMethods.GetForegroundWindow() != Manager.Handle)
                                            {
                                                Manager.Visible = false;
                                                Manager.Rotate(0);
                                                ChangeVisibility();
                                                return;
                                            }
                                        }
                                        ChangeVisibility();
                                    }
                                }
                            }
                        }
                        return;

                    case NativeMethods.CM_SPLASHCLOSE:
                        if (splashScreen != null)
                        {
                            splashScreen.Dispose();
                            splashScreen = null;
                        }
                        break;

                    default:
                        break;
                    }
                    base.WndProc(ref m);
                }
            }
            catch (Exception ex)
            {
                TraceDebug.Trace(ex);
                if (!wasException)
                {
                    wasException = true;
                    throw new KrentoEngineException("Krento Engine Error: ", ex);
                }
            }
        }