private static void FlightMovement(Var.Rect _newwindowmovement, Var.Rect _windowcurrentpos, int _sleeptime)
        {
            IntPtr _window = NativeMethods.FindWindowByCaption(IntPtr.Zero, Var.WINDOW_NAME);

            //no moving by user
            Var.AllowManualMovement = false;
            //FIND THE DISTANCE
            int _distancesqr = Convert.ToInt32(Math.Floor(Math.Sqrt(Math.Pow(_newwindowmovement.Left, 2) + Math.Pow(_newwindowmovement.Top, 2))));

            if (_distancesqr > 1000)
            {
                _distancesqr = 1000;
            }
            if (_distancesqr < 50)
            {
                return;
            }
            //should we turn around?
            if ((Var.LookingRightWay == true && _newwindowmovement.Left < 0) || (Var.LookingRightWay == false && _newwindowmovement.Left > 0))
            {
                Var.TurnAroundState = 1;
            }
            //START MOVING TOWARDS IT
            double _angle = 0;
            double _cosx  = Math.Sin(_angle);
            double _cosy  = Math.Sin(_angle);
            int    _movex = 0;
            int    _movey = 0;

            while (_angle < Math.PI)
            {
                _cosx = Math.Cos(_angle);
                _cosy = Math.Cos(_angle);
                //big scary formulae o' flight
                _movex = _windowcurrentpos.Left + Convert.ToInt32(Math.Floor(_newwindowmovement.Left * (1 - ((1 + (_cosx)) / 2))));
                _movey = _windowcurrentpos.Top + Convert.ToInt32(Math.Floor(_newwindowmovement.Top * (1 - ((1 + (_cosy)) / 2))));
                Var.WingsSleepParameter = Convert.ToInt32((_distancesqr / Var.WingsSleepMultiplier) * (1 - (Math.Sin(_angle))) + (Var.WingsSleepParameterDefault - _distancesqr / (Var.WingsSleepMultiplier / 2)));
                NativeMethods.MoveWindow(_window,
                                         _movex,
                                         _movey,
                                         Var.WindowSizeX, Var.WindowSizeY, true);
                _angle = _angle + Math.PI / Var.FlightSpeedMultiplier;
                Thread.Sleep(_sleeptime);
            }
            Var.WingsSleepParameter = Var.WingsSleepParameterDefault;
            Var.AllowManualMovement = true;
        }
Exemplo n.º 2
0
        private void MoveWindowFunction()
        {
            //Take the difference between the mouses' current position
            //and the program's position and then using that
            //change the program's position.
            int    _xdif   = Cursor.Position.X - this.Location.X;
            int    _ydif   = Cursor.Position.Y - this.Location.Y;
            IntPtr _window = NativeMethods.FindWindowByCaption(IntPtr.Zero, Var.WINDOW_NAME);
            Random _rnd    = new Random();

            if (Var.AllowDialogs)
            {
                if (Var.DialogToDraw != null)
                {
                    Dialogs.refreshForm(0);
                }

                Dialogs.setDialog(_rnd.Next(16) + 101, 0);
            }

            while (Var.LeftMouseButtonDown)
            {
                Thread.Sleep(20);
                int _newx = Cursor.Position.X;
                int _newy = Cursor.Position.Y;
                NativeMethods.SetWindowPos(_window, 0, _newx - _xdif, _newy - _ydif, Var.WindowSizeX, Var.WindowSizeY, 0x0040);
            }
            //Turn around?
            if (Var.TurnTowardsCenter)
            {
                Var.Rect _windowcurrentpos = new Var.Rect();
                int      _screenwidth      = Screen.PrimaryScreen.Bounds.Width;
                NativeMethods.GetWindowRect(_window, ref _windowcurrentpos);
                if ((_windowcurrentpos.Left + Var.LOWER_BODY_X > _screenwidth / 2) && Var.LookingRightWay)
                {
                    Var.TurnAroundState = 1;
                }
                else if ((_windowcurrentpos.Left + Var.LOWER_BODY_X < _screenwidth / 2) && !Var.LookingRightWay)
                {
                    Var.TurnAroundState = 1;
                }
            }
            if (Var.AllowDialogs)
            {
                Dialogs.refreshForm(0);
            }
        }
Exemplo n.º 3
0
        public static void refreshForm(int _whattodo)
        {
            IntPtr _window = NativeMethods.FindWindowByCaption(IntPtr.Zero, Var.WINDOW_NAME);

            Var.Rect _windowcurrentpos = new Var.Rect();
            NativeMethods.GetWindowRect(_window, ref _windowcurrentpos);
            if (_whattodo == 1)
            {
                Var.WindowSizeX += Var.DialogToDraw.Length * 10 + Var.LOWER_BODY_X + 100;
            }
            else
            {
                Var.WindowSizeX -= Var.DialogToDraw.Length * 10 + Var.LOWER_BODY_X + 100;
                Var.DialogToDraw = null;
            }
            NativeMethods.MoveWindow(_window,
                                     _windowcurrentpos.Left,
                                     _windowcurrentpos.Top,
                                     Var.WindowSizeX, Var.WindowSizeY, true);
        }
Exemplo n.º 4
0
 public static extern bool GetWindowRect(IntPtr hwnd, ref Var.Rect rectangle);
        public static void FidgetsMind()
        {
            //Init moving
            Random _rnd    = new Random();
            IntPtr _window = NativeMethods.FindWindowByCaption(IntPtr.Zero, Var.WINDOW_NAME);

            Var.Rect _windowcurrentpos  = new Var.Rect();
            Var.Rect _newwindowmovement = new Var.Rect();
            int      _screenwidth       = Screen.PrimaryScreen.Bounds.Width;
            int      _screenheight      = Screen.PrimaryScreen.Bounds.Height;

            Var.SecondsToNextMovement = Convert.ToInt32(_rnd.Next(Var.MOVEMENT_TIME_MODIFIER - Var.MovementFrequency, (Var.MOVEMENT_TIME_MODIFIER - Var.MovementFrequency) * 2));
            while (true)
            {
                //mouse follow
                while (Var.FollowTheMouse && Var.MovementDistance == 0)
                {
                    //FIND THE TARGET
                    NativeMethods.GetWindowRect(_window, ref _windowcurrentpos);
                    if ((Var.LookingRightWay == true && Cursor.Position.X - _windowcurrentpos.Left - Var.LOWER_BODY_X < 0) || (Var.LookingRightWay == false && Cursor.Position.X - _windowcurrentpos.Left - Var.LOWER_BODY_X > 0))
                    {
                        Var.TurnAroundState = 1;
                    }
                    _newwindowmovement.Left = _windowcurrentpos.Left + Convert.ToInt32(((Cursor.Position.X - _windowcurrentpos.Left - Var.LOWER_BODY_X) * 0.01));
                    _newwindowmovement.Top  = _windowcurrentpos.Top + Convert.ToInt32(((Cursor.Position.Y - _windowcurrentpos.Top - Var.LOWER_BODY_Y) * 0.01));
                    int _distancesqr = Convert.ToInt32(Math.Floor(Math.Sqrt(Math.Pow((Cursor.Position.X - _windowcurrentpos.Left - Var.LOWER_BODY_X), 2) + Math.Pow((Cursor.Position.Y - _windowcurrentpos.Top - Var.LOWER_BODY_Y), 2))));
                    int _wsleep      = Var.WingsSleepParameterDefault - _distancesqr / 50;
                    if (_wsleep < 20)
                    {
                        _wsleep = 20;
                    }
                    Var.WingsSleepParameter = _wsleep;
                    NativeMethods.MoveWindow(_window,
                                             _newwindowmovement.Left,
                                             _newwindowmovement.Top,
                                             Var.WindowSizeX, Var.WindowSizeY, true);
                    Thread.Sleep(25);
                }
                //random moves
                if (Var.MovementDistance != 0 && !Var.FollowTheMouse)
                {
                    if (Var.SecondsSpentBeforeNextMovement > Var.SecondsToNextMovement)
                    {
                        //generate new rnd
                        Var.SecondsToNextMovement = Convert.ToInt32(_rnd.Next(Var.MOVEMENT_TIME_MODIFIER - Var.MovementFrequency, (Var.MOVEMENT_TIME_MODIFIER - Var.MovementFrequency) * 2));
                        //FIND THE TARGET
                        NativeMethods.GetWindowRect(_window, ref _windowcurrentpos);
                        do
                        {
                            _newwindowmovement.Top  = Convert.ToInt32(_rnd.Next(-_screenheight / 2 * Var.MovementDistance, _screenheight / 2 * Var.MovementDistance));
                            _newwindowmovement.Left = Convert.ToInt32(_rnd.Next(-_screenwidth / 2 * Var.MovementDistance, _screenwidth / 2 * Var.MovementDistance));
                        } while
                        //Make sure it's inside the monitor
                        (
                            0 > _windowcurrentpos.Left + _newwindowmovement.Left ||
                            0 > _windowcurrentpos.Top + _newwindowmovement.Top ||
                            _screenwidth - Var.WindowSizeX < _windowcurrentpos.Left + _newwindowmovement.Left ||
                            _screenheight - Var.WindowSizeY < _windowcurrentpos.Top + _newwindowmovement.Top
                        );

                        //do the magic
                        int _sleeptime = Var.SleepDuringRandomMoves;
                        FlightMovement(_newwindowmovement, _windowcurrentpos, _sleeptime);

                        //WE DID IT!
                        Var.SecondsSpentBeforeNextMovement = 0;
                        //Turn around?
                        if (Var.TurnTowardsCenter)
                        {
                            if ((_windowcurrentpos.Left + _newwindowmovement.Left > _screenwidth / 2) && Var.LookingRightWay)
                            {
                                Var.TurnAroundState = 1;
                            }
                            else if ((_windowcurrentpos.Left + _newwindowmovement.Left < _screenwidth / 2) && !Var.LookingRightWay)
                            {
                                Var.TurnAroundState = 1;
                            }
                        }
                    }
                    //this isn't the end yet
                    Var.SecondsSpentBeforeNextMovement++;
                }
                Thread.Sleep(1000);
            }
        }