Esempio n. 1
0
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args)   //;;;
//Click the ► button on the toolbar to run the script.

                                 {
                                     AOutput.Write("The programming language is C#.");
                                     if (ADialog.ShowYesNo("Run Notepad?", "The script will add some text and close Notepad after 2 s."))
                                     {
                                         AExec.Run(AFolders.System + @"Notepad.exe");
                                         var w = AWnd.Wait(5, active: true, "*- Notepad"); //to create this code can be used the Code menu
                                         50.ms();
                                         AKeys.Text("some text");
                                         2.s();
                                         AKeys.Key("Ctrl+Z"); //Undo
                                         w.Close();
                                     }

                                     string linkText = "Read about code editor features",
                                            linkUrl  = "https://www.quickmacros.com/au/help/editor/Code editor.html";

                                     AOutput.Write($"<><link \"{linkUrl}\">{linkText}</link>");
                                 }
Esempio n. 2
0
    void MouseTriggers()
    {
        //examples of mouse triggers

        Triggers.Mouse[TMClick.Right, "Ctrl+Shift", TMFlags.ButtonModUp] = o => AOutput.Write(o.Trigger); //Ctrl+Shift+RightClick
        Triggers.Mouse[TMEdge.RightInCenter50] = o => {                                                   //the right edge of the primary screen, center 50%
            var m = new AMenu("example");
            m["A"] = o => {  };
            m["B"] = o => {  };
            using (m.Submenu("C")) {
                m["D"] = o => {  };
                m["E"] = o => {  };
            }
            m.Show();

            //To create menus can be used snippet menuSnippet. Start typing "menu" and you will see snippets in the completion list.
        };
        Triggers.Mouse[TMMove.LeftRightInCenter50, screen : TMScreen.Any] = o => AWnd.SwitchActiveWindow(); //move the mouse quickly to the left and back in center 50% of any screen
        Triggers.Mouse[TMMove.RightLeftInCenter50, screen : TMScreen.Any] = o => AKeys.Key("Ctrl+Tab");     //to the right and back. Ctrl+Tab should switch the active document.

        Triggers.FuncOf.NextTrigger     = o => AKeys.IsScrollLock;                                          //example of a custom scope (aka context, condition)
        Triggers.Mouse[TMWheel.Forward] = o => AOutput.Write($"{o.Trigger} while ScrollLock is on");
    }
Esempio n. 3
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