예제 #1
0
파일: t-mouse.cs 프로젝트: alexfordc/Au
            void _Detect()
            {
                if (AMouse.IsPressed(MButtons.Left | MButtons.Right | MButtons.Middle))
                {
                    _prev.mDirection = 0;
                    return;
                }

                int x = _x, y = _y;

                if (x == _prev.xx && y == _prev.yy) /*AOutput.Write("same x y");*/ return {
                    ;
                }
예제 #2
0
파일: UacDragDrop.cs 프로젝트: alexfordc/Au
        //Every 30 ms while in drag mode.
        void _Timer()
        {
            if (!_isDragMode)
            {
                return;
            }

            //when mouse released, end drag mode with ~100 ms delay
            if (!AMouse.IsPressed(MButtons.Left | MButtons.Right))              //calls GetKeyStateAsync. GetKeyState somehow unreliable when in drag mode.
            {
                if (++_endCounter == 4)
                {
                    _EndedDragMode();
                }
                return;
            }
            _endCounter = 0;
            //end drag mode if _wTransparent died, eg did not find useful data on drag enter
            if (!_wTransparent.Is0 && !_wTransparent.IsAlive)
            {
                _EndedDragMode();
                return;
            }

            var w = AWnd.FromMouse(WXYFlags.NeedWindow);

            if (!_isProcess2)
            {
                if (!w.IsOfThisProcess)
                {
                    return;
                }
                //AOutput.Write("drag");
                _isProcess2 = true;
                _wWindow    = w;
                new Au.Util.ProcessStarter_("Au.Editor.exe", "/dd " + CommandLine.MsgWnd.Handle.ToString()).StartUserIL();
                //new Au.Util.ProcessStarter_("Au.Editor.exe", $"/dd {CommandLine.MsgWnd.Handle.ToString()} {ATime.PerfMilliseconds}").StartUserIL(); //test process startup speed
            }
            else if (w != _wTransparent)
            {
                _wWindow = w;
                _SetTransparentSizeZorder();
            }
        }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            deltaTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            /*
             * So im figuring out a way to get the offset from the selected tile and save it...
             */

            int mx            = 0;
            int my            = 0;
            int playerOffsetX = 0;
            int playerOffsetY = 0;

            if (Input.KeyDown(Keys.W) || AMouse.MouseDown(AMouse.MouseButton.Right))
            {
                //currTargetPosition = Position;
                targetPosition = GameScreen.Camera.GetMousePosition(AMouse.MousePosition);

                // Make sure we don't go out of bounds!
                if (targetPosition.X < 0 || targetPosition.X > Game1.Monitor.Width ||
                    targetPosition.Y < 0 || targetPosition.Y > Game1.Monitor.Height)
                {
                    return;
                }
                int squaresPerTile = GameScreen.TileSizeMultiplier;

                int tileOffsetX      = (int)(targetPosition.X / GameScreen.TileWidth);
                int mouseX           = tileOffsetX * GameScreen.TileWidth;
                int mouseTileOffsetX = ((int)targetPosition.X - ((int)(targetPosition.X / GameScreen.TileWidth) * GameScreen.TileWidth));
                int mouseOffsetX     = mouseTileOffsetX / (GameScreen.TileWidth / squaresPerTile);

                int tileOffsetY      = (int)(targetPosition.Y / GameScreen.TileHeight);
                int mouseY           = tileOffsetY * GameScreen.TileHeight;
                int mouseTileOffsetY = ((int)targetPosition.Y - ((int)(targetPosition.Y / GameScreen.TileHeight) * GameScreen.TileHeight));
                int mouseOffsetY     = mouseTileOffsetY / (GameScreen.TileHeight / squaresPerTile);

                int mouseGridX = (mouseOffsetX * (GameScreen.TileWidth / squaresPerTile)) + mouseX;
                int mouseGridY = (mouseOffsetY * (GameScreen.TileHeight / squaresPerTile)) + mouseY;

                mx = mouseGridX / (GameScreen.TileWidth / squaresPerTile);
                my = mouseGridY / (GameScreen.TileHeight / squaresPerTile);

                playerOffsetX = (int)(Position.X / (GameScreen.TileWidth / squaresPerTile));
                playerOffsetY = (int)((Position.Y) / (GameScreen.TileHeight / squaresPerTile));

                // Make sure we don't update the pathing or move unless we need to!
                if (tarPositions.Count > 0)
                {
                    var currGoal = new Vector2(tarPositions[tarPositions.Count - 1].X / (GameScreen.TileWidth / GameScreen.TileSizeMultiplier),
                                               tarPositions[tarPositions.Count - 1].Y / (GameScreen.TileWidth / GameScreen.TileSizeMultiplier));

                    Vector2 mp = new Vector2(mx, my);
                    Game1.WindowMessage = currGoal.ToString() + "   " + mp.ToString();

                    if (currGoal.X != mp.X && currGoal.Y != mp.Y)
                    {
                        tarPositions.Clear();

                        Point playerPoint = new Point(playerOffsetX, playerOffsetY);
                        Point tarPoint    = new Point(mx, my);
                        var   paths       = GameScreen.aStar.FindPath(playerPoint, tarPoint);

                        for (int i = 0; i < paths.Count; i++)
                        {
                            tarPositions.Add(paths[i]);
                        }
                    }
                }
                // Set the pathing if there is none set
                else
                {
                    Point playerPoint = new Point(playerOffsetX, playerOffsetX);
                    Point tarPoint    = new Point(mx, my);

                    if (playerPoint.X != tarPoint.X && playerPoint.Y != tarPoint.Y)
                    {
                        Game1.WindowMessage = playerPoint.ToString() + "   " + tarPoint.ToString();

                        var paths = GameScreen.aStar.FindPath(playerPoint, tarPoint);

                        for (int i = 0; i < paths.Count; i++)
                        {
                            tarPositions.Add(paths[i]);
                        }
                    }
                }
            }

            Move(tarPositions, gameTime);

            //Game1.WindowMessage = "PlayerTile: (" + playerOffsetX + ", " + playerOffsetY + ")  MouseTile: (" + mx + ", " + my + ")";
        }
예제 #4
0
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;

/*
The programming language is C#.

In scripts you can use classes/functions of the automation library provided by
this program, as well as of .NET Core and everything that can be used in C#.
Also you can create and use new functions, classes, libraries and .exe programs.

Script properties are saved in /*/ /*/ comments at the very start of script.
You can change them in the Properties dialog.

Like all C# programs, a script starts with standard code: using directives,
class and function Main where the program starts. Click the small [+] box at
the top-left to see and edit that code when need. The //. and //; are used to
fold (hide) code.

To avoid 'static' everywhere, function Main creates a class instance. Your script
code is in the constructor function. The function and the class end with } and }.

To run a script, you can click the ► Run button on the toolbar, or use command line,
or call ATask.Run from another scrit, or in Options set to run at startup.

Triggers such as hotkeys, autotext, mouse and window are used to execute functions
in a running script. Also you can create custom toolbars and menus. To start
using them: menu File -> New -> Examples -> @Triggers and toolbars.
*/

//Examples of automation functions.

AOutput.Write("Main script code.");

ADialog.Show("Message box.");

AExec.Run(AFolders.System + "notepad.exe");
var w = AWnd.Wait(0, true, "*- Notepad");
AKeys.Key("F5 Enter*2");
AKeys.Text(w.Name);
2.s();
w.Close();
var w2 = AWnd.Wait(-3, true, "Notepad", "#32770");
if(!w2.Is0) {
	500.ms();
	var c = +w2.Child(null, "Button", skip: 1); // "Don't Save"
	AMouse.Click(c);
	500.ms();
}

//Examples of .NET functions.

string s = "Example";
var b = new System.Text.StringBuilder();
for(int i = 0; i < s.Length; i++) {
	b.Append(s[i]).AppendLine();
}
MessageBox.Show(b.ToString());

//Example of your function and how functions can share variables.

_sharedVariable = 1;
FunctionExample("Example");
AOutput.Write(_sharedVariable);

} //end of main function