├── .gitignore ├── src ├── META-INF │ └── MANIFEST.MF └── snapmacro │ ├── res │ ├── app_icon.png │ ├── eye_icon.png │ ├── run_icon.png │ ├── clear_icon.png │ ├── debug_icon.png │ ├── load_icon.png │ ├── save_icon.png │ ├── stop_icon.png │ ├── theme_icon.png │ ├── cursor_icon.png │ └── restart_icon.png │ ├── utils │ ├── Theme.java │ ├── OnThemeChangeListener.java │ ├── CursorManager.java │ ├── AppConst.java │ ├── DialogUtils.java │ ├── ThemeManager.java │ ├── Settings.java │ └── FileManager.java │ ├── lang │ ├── DebugType.java │ ├── ExitEvent.java │ ├── ParserError.java │ ├── SnapCallable.java │ ├── Statement.java │ ├── Expression.java │ ├── StreamListener.java │ ├── DebuggerListener.java │ ├── ExitStatement.java │ ├── ExpressionVisitor.java │ ├── RuntimeError.java │ ├── Variable.java │ ├── LiteralExp.java │ ├── MouseClickStatement.java │ ├── MouseWheelStatement.java │ ├── SleepStatement.java │ ├── EchoStatement.java │ ├── KeyboardController.java │ ├── ExpressionStatement.java │ ├── MousePointStatement.java │ ├── BlockStatement.java │ ├── TokenType.java │ ├── AssignExp.java │ ├── ScreenStatement.java │ ├── VarStatement.java │ ├── UnaryExp.java │ ├── RepeatStatement.java │ ├── KeyboardStatement.java │ ├── WhileStatement.java │ ├── IfStatement.java │ ├── FunctionStatement.java │ ├── StatementVisitor.java │ ├── LogicalExp.java │ ├── BinaryExp.java │ ├── SnapFunction.java │ ├── ListenerMessage.java │ ├── Token.java │ ├── CallExp.java │ ├── MouseController.java │ ├── ScreenController.java │ ├── Environment.java │ ├── RobotController.java │ ├── KeyboardKey.java │ ├── SnapRuntime.java │ ├── SnapLexer.java │ ├── SnapParser.java │ └── Interpreter.java │ ├── Main.java │ ├── ui │ ├── SnapSyntax.java │ └── SnapEditor.java │ ├── styles │ ├── dark_theme.css │ └── white_theme.css │ ├── views │ └── main_view.fxml │ └── controllers │ └── MainController.java ├── jar └── SnapMacro.jar ├── out └── production │ └── SnapMacro │ ├── META-INF │ └── MANIFEST.MF │ └── snapmacro │ ├── Main.class │ ├── lang │ ├── Token.class │ ├── AssignExp.class │ ├── BinaryExp.class │ ├── CallExp.class │ ├── DebugType.class │ ├── ExitEvent.class │ ├── SnapLexer.class │ ├── Statement.class │ ├── TokenType.class │ ├── UnaryExp.class │ ├── Variable.class │ ├── Environment.class │ ├── Expression.class │ ├── IfStatement.class │ ├── Interpreter.class │ ├── KeyboardKey.class │ ├── LiteralExp.class │ ├── LogicalExp.class │ ├── ParserError.class │ ├── SnapParser.class │ ├── SnapRuntime.class │ ├── BlockStatement.class │ ├── EchoStatement.class │ ├── ExitStatement.class │ ├── Interpreter$1.class │ ├── RuntimeError.class │ ├── SleepStatement.class │ ├── SnapCallable.class │ ├── SnapFunction.class │ ├── SnapParser$1.class │ ├── StreamListener.class │ ├── VarStatement.class │ ├── WhileStatement.class │ ├── DebuggerListener.class │ ├── ListenerMessage.class │ ├── MouseController.class │ ├── RepeatStatement.class │ ├── RobotController.class │ ├── ScreenController.class │ ├── ScreenStatement.class │ ├── StatementVisitor.class │ ├── ExpressionStatement.class │ ├── ExpressionVisitor.class │ ├── FunctionStatement.class │ ├── KeyboardController.class │ ├── KeyboardStatement.class │ ├── MouseClickStatement.class │ └── MousePointStatement.class │ ├── res │ ├── app_icon.png │ ├── load_icon.png │ ├── run_icon.png │ ├── save_icon.png │ ├── stop_icon.png │ ├── clear_icon.png │ ├── cursor_icon.png │ ├── debug_icon.png │ ├── restart_icon.png │ └── theme_icon.png │ ├── utils │ ├── Theme.class │ ├── AppConst.class │ ├── Settings.class │ ├── CursorManager.class │ ├── DialogUtils.class │ ├── FileManager.class │ ├── ThemeManager.class │ ├── ThemeManager$1.class │ └── OnThemeChangeListener.class │ ├── ui │ ├── SnapEditor.class │ ├── SnapSyntax.class │ └── SnapEditor$1.class │ ├── controllers │ ├── MainController.class │ └── MainController$1.class │ ├── styles │ ├── dark_theme.css │ └── white_theme.css │ └── views │ └── main_view.fxml ├── screenshots ├── screen1.PNG └── screen2.PNG ├── lib └── richtextfx-fat-0.9.2.jar ├── .idea ├── vcs.xml ├── libraries │ ├── SnapMacro.xml │ ├── SnapMacro1.xml │ └── richtextfx_fat_0_9_2.xml ├── misc.xml ├── modules.xml ├── artifacts │ └── SnapMacro_jar.xml ├── $PRODUCT_WORKSPACE_FILE$ ├── checkstyle-idea.xml ├── workspace.xml └── uiDesigner.xml ├── examples ├── Screenshot.ss └── Linkedin.ss ├── SnapMacro.iml ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /out/ 2 | -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: snapmacro.Main 3 | 4 | -------------------------------------------------------------------------------- /jar/SnapMacro.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/jar/SnapMacro.jar -------------------------------------------------------------------------------- /out/production/SnapMacro/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: snapmacro.Main 3 | 4 | -------------------------------------------------------------------------------- /screenshots/screen1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/screenshots/screen1.PNG -------------------------------------------------------------------------------- /screenshots/screen2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/screenshots/screen2.PNG -------------------------------------------------------------------------------- /lib/richtextfx-fat-0.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/lib/richtextfx-fat-0.9.2.jar -------------------------------------------------------------------------------- /src/snapmacro/res/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/app_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/eye_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/eye_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/run_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/run_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/clear_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/clear_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/debug_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/debug_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/load_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/load_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/save_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/save_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/stop_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/stop_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/theme_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/theme_icon.png -------------------------------------------------------------------------------- /src/snapmacro/utils/Theme.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | public enum Theme { 4 | WHITE, 5 | DARK 6 | } 7 | -------------------------------------------------------------------------------- /src/snapmacro/lang/DebugType.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public enum DebugType { 4 | ERROR, 5 | WARN 6 | } 7 | -------------------------------------------------------------------------------- /src/snapmacro/lang/ExitEvent.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class ExitEvent extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /src/snapmacro/res/cursor_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/cursor_icon.png -------------------------------------------------------------------------------- /src/snapmacro/res/restart_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/src/snapmacro/res/restart_icon.png -------------------------------------------------------------------------------- /src/snapmacro/lang/ParserError.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class ParserError extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/Main.class -------------------------------------------------------------------------------- /src/snapmacro/lang/SnapCallable.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public interface SnapCallable { 4 | Object call(Interpreter interpreter); 5 | } 6 | -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Token.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Token.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/app_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/load_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/load_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/run_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/run_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/save_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/save_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/stop_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/stop_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/Theme.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/Theme.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/AssignExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/AssignExp.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/BinaryExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/BinaryExp.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/CallExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/CallExp.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/DebugType.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/DebugType.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ExitEvent.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ExitEvent.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SnapLexer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SnapLexer.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Statement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Statement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/TokenType.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/TokenType.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/UnaryExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/UnaryExp.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Variable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Variable.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/clear_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/clear_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/cursor_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/cursor_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/debug_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/debug_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/restart_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/restart_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/res/theme_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/res/theme_icon.png -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/ui/SnapEditor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/ui/SnapEditor.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/ui/SnapSyntax.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/ui/SnapSyntax.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/AppConst.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/AppConst.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/Settings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/Settings.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Environment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Environment.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Expression.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Expression.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/IfStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/IfStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Interpreter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Interpreter.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/KeyboardKey.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/KeyboardKey.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/LiteralExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/LiteralExp.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/LogicalExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/LogicalExp.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ParserError.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ParserError.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SnapParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SnapParser.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SnapRuntime.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SnapRuntime.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/ui/SnapEditor$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/ui/SnapEditor$1.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/BlockStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/BlockStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/EchoStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/EchoStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ExitStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ExitStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/Interpreter$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/Interpreter$1.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/RuntimeError.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/RuntimeError.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SleepStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SleepStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SnapCallable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SnapCallable.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SnapFunction.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SnapFunction.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/SnapParser$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/SnapParser$1.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/StreamListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/StreamListener.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/VarStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/VarStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/WhileStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/WhileStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/CursorManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/CursorManager.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/DialogUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/DialogUtils.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/FileManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/FileManager.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/ThemeManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/ThemeManager.class -------------------------------------------------------------------------------- /src/snapmacro/lang/Statement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public abstract class Statement { 4 | public abstract R accept(StatementVisitor visitor); 5 | } 6 | -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/DebuggerListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/DebuggerListener.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ListenerMessage.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ListenerMessage.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/MouseController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/MouseController.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/RepeatStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/RepeatStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/RobotController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/RobotController.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ScreenController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ScreenController.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ScreenStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ScreenStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/StatementVisitor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/StatementVisitor.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/ThemeManager$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/ThemeManager$1.class -------------------------------------------------------------------------------- /src/snapmacro/lang/Expression.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public abstract class Expression { 4 | public abstract R accept(ExpressionVisitor visitor); 5 | } 6 | -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ExpressionStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ExpressionStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/ExpressionVisitor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/ExpressionVisitor.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/FunctionStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/FunctionStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/KeyboardController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/KeyboardController.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/KeyboardStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/KeyboardStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/MouseClickStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/MouseClickStatement.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/lang/MousePointStatement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/lang/MousePointStatement.class -------------------------------------------------------------------------------- /src/snapmacro/lang/StreamListener.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | @FunctionalInterface 4 | public interface StreamListener { 5 | void getStreamListener(String message); 6 | } 7 | -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/controllers/MainController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/controllers/MainController.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/controllers/MainController$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/controllers/MainController$1.class -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/utils/OnThemeChangeListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmrDeveloper/SnapMacro/HEAD/out/production/SnapMacro/snapmacro/utils/OnThemeChangeListener.class -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/snapmacro/lang/DebuggerListener.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | @FunctionalInterface 4 | public interface DebuggerListener { 5 | void getDebugMessages(String message, DebugType type); 6 | } 7 | -------------------------------------------------------------------------------- /src/snapmacro/utils/OnThemeChangeListener.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | @FunctionalInterface 4 | public interface OnThemeChangeListener { 5 | public void onThemeChange(Theme theme); 6 | } 7 | -------------------------------------------------------------------------------- /examples/Screenshot.ss: -------------------------------------------------------------------------------- 1 | # Repeat the block 10 times 2 | repeat(3) { 3 | #Take full screenshot and save it in this path 4 | screen capture "C:\Users\AmrDeveloper\Desktop\screenshots" 5 | 6 | #Wait 2s 7 | delay 2000 8 | } 9 | -------------------------------------------------------------------------------- /src/snapmacro/lang/ExitStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class ExitStatement extends Statement{ 4 | 5 | @Override 6 | public R accept(StatementVisitor visitor) { 7 | return visitor.visit(this); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.idea/libraries/SnapMacro.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/snapmacro/utils/CursorManager.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | import java.awt.*; 4 | 5 | public class CursorManager { 6 | 7 | public static Point getCursorPosition(){ 8 | return MouseInfo.getPointerInfo().getLocation(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/snapmacro/utils/AppConst.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | public final class AppConst { 4 | 5 | public static final String NAME = "SnapMacro"; 6 | 7 | public static final double MIN_WIDTH = 600; 8 | public static final double MIN_HEIGHT = 400; 9 | } 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/SnapMacro1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/richtextfx_fat_0_9_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/Linkedin.ss: -------------------------------------------------------------------------------- 1 | func connectButton { 2 | #point to connect button 3 | mouse point 514 543 4 | mouse click left 5 | } 6 | 7 | func closeButton { 8 | #point to close button 9 | mouse point 579 307 10 | mouse click left 11 | } 12 | 13 | repeat(3) { 14 | connectButton() 15 | delay 2000 16 | closeButton() 17 | delay 2000 18 | } 19 | -------------------------------------------------------------------------------- /src/snapmacro/lang/ExpressionVisitor.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | 4 | public interface ExpressionVisitor { 5 | R visit(AssignExp expr); 6 | R visit(BinaryExp expr); 7 | R visit(LogicalExp expr); 8 | R visit(LiteralExp expr); 9 | R visit(Variable expr); 10 | R visit(UnaryExp expr); 11 | R visit(CallExp expr); 12 | } 13 | -------------------------------------------------------------------------------- /src/snapmacro/lang/RuntimeError.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class RuntimeError extends RuntimeException { 4 | 5 | private final Token token; 6 | 7 | public RuntimeError(Token token, String message) { 8 | super(message); 9 | this.token = token; 10 | } 11 | 12 | public Token getToken() { 13 | return token; 14 | } 15 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/Variable.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class Variable extends Expression{ 4 | 5 | private final Token name; 6 | 7 | public Variable(Token name) { 8 | this.name = name; 9 | } 10 | 11 | public Token getName() { 12 | return name; 13 | } 14 | 15 | @Override 16 | public R accept(ExpressionVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/LiteralExp.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class LiteralExp extends Expression{ 4 | 5 | private final Object value; 6 | 7 | public LiteralExp(Object value) { 8 | this.value = value; 9 | } 10 | 11 | public Object getValue() { 12 | return value; 13 | } 14 | 15 | @Override 16 | public R accept(ExpressionVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/MouseClickStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class MouseClickStatement extends Statement{ 4 | 5 | private final Token value; 6 | 7 | public MouseClickStatement(Token value){ 8 | this.value = value; 9 | } 10 | 11 | public Token getValue(){ 12 | return value; 13 | } 14 | 15 | @Override 16 | public R accept(StatementVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/snapmacro/lang/MouseWheelStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class MouseWheelStatement extends Statement { 4 | 5 | private final Token value; 6 | 7 | public MouseWheelStatement(Token value){ 8 | this.value = value; 9 | } 10 | 11 | public Token getValue(){ 12 | return value; 13 | } 14 | 15 | @Override 16 | public R accept(StatementVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/snapmacro/lang/SleepStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class SleepStatement extends Statement { 4 | 5 | private final Expression value; 6 | 7 | public SleepStatement(Expression value){ 8 | this.value = value; 9 | } 10 | 11 | public Expression getValue(){ 12 | return value; 13 | } 14 | 15 | @Override 16 | public R accept(StatementVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/snapmacro/lang/EchoStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class EchoStatement extends Statement { 4 | 5 | private final Expression expression; 6 | 7 | public EchoStatement(Expression expression) { 8 | this.expression = expression; 9 | } 10 | 11 | public Expression getExpression() { 12 | return expression; 13 | } 14 | 15 | @Override 16 | public R accept(StatementVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.idea/artifacts/SnapMacro_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/jar 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/snapmacro/lang/KeyboardController.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.awt.*; 4 | 5 | public class KeyboardController { 6 | 7 | private final Robot mCursorRobot; 8 | 9 | public KeyboardController(Robot robot) { 10 | mCursorRobot = robot; 11 | } 12 | 13 | public void keyboardPressKey(int keyValue) { 14 | mCursorRobot.keyPress(keyValue); 15 | } 16 | 17 | public void keyboardReleaseKey(int keyValue) { 18 | mCursorRobot.keyRelease(keyValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/snapmacro/lang/ExpressionStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class ExpressionStatement extends Statement { 4 | 5 | private final Expression expression; 6 | 7 | public ExpressionStatement(Expression expression) { 8 | this.expression = expression; 9 | } 10 | 11 | public Expression getExpression() { 12 | return expression; 13 | } 14 | 15 | @Override 16 | public R accept(StatementVisitor visitor) { 17 | return visitor.visit(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/snapmacro/lang/MousePointStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.util.List; 4 | 5 | public class MousePointStatement extends Statement { 6 | 7 | private List value; 8 | 9 | public MousePointStatement(List value) { 10 | this.value = value; 11 | } 12 | 13 | public List getValue() { 14 | return value; 15 | } 16 | 17 | @Override 18 | public R accept(StatementVisitor visitor) { 19 | return visitor.visit(this); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/snapmacro/lang/BlockStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.util.List; 4 | 5 | public class BlockStatement extends Statement{ 6 | 7 | private final List statementList; 8 | 9 | public BlockStatement(List statementList) { 10 | this.statementList = statementList; 11 | } 12 | 13 | public List getStatementList() { 14 | return statementList; 15 | } 16 | 17 | @Override 18 | public R accept(StatementVisitor visitor) { 19 | return visitor.visit(this); 20 | } 21 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/TokenType.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public enum TokenType { 4 | MOUSE, KEYBOARD, SCREEN, 5 | 6 | EQUAL, EQUAL_EQUAL, GREATER, LESS, GREATER_EQUAL, LESS_EQUAL, 7 | BANG_EQUAL, BANG, 8 | 9 | FUNCTION, 10 | 11 | IDENTIFIER, STRING, NUMBER, HEX_NUMBER, TRUE, FALSE, CHAR, 12 | LEFT_PAREN, RIGHT_PAREN, LEFT_BRACE, RIGHT_BRACE, 13 | 14 | IF, REPEAT, WHILE, VAR, ECHO, 15 | 16 | RESTART, SLEEP, EXIT, 17 | 18 | PLUS, MINUS, MINUS_MINUS, PLUS_PLUS, SLASH, STAR, 19 | 20 | AND, OR, XOR, 21 | 22 | EOF 23 | } 24 | -------------------------------------------------------------------------------- /.idea/$PRODUCT_WORKSPACE_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 1.8 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/snapmacro/lang/AssignExp.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class AssignExp extends Expression { 4 | 5 | private final Token name; 6 | private final Expression value; 7 | 8 | public AssignExp(Token name, Expression value) { 9 | this.name = name; 10 | this.value = value; 11 | } 12 | 13 | public Token getName() { 14 | return name; 15 | } 16 | 17 | public Expression getValue() { 18 | return value; 19 | } 20 | 21 | @Override 22 | public R accept(ExpressionVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/ScreenStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class ScreenStatement extends Statement { 4 | 5 | private final Token order; 6 | private final Token value; 7 | 8 | public ScreenStatement(Token order, Token value) { 9 | this.order = order; 10 | this.value = value; 11 | } 12 | 13 | public Token getOrder() { 14 | return order; 15 | } 16 | 17 | public Token getValue() { 18 | return value; 19 | } 20 | 21 | @Override 22 | public R accept(StatementVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/snapmacro/lang/VarStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class VarStatement extends Statement { 4 | 5 | private final Token name; 6 | private final Expression initializer; 7 | 8 | public VarStatement(Token name, Expression initializer) { 9 | this.name = name; 10 | this.initializer = initializer; 11 | } 12 | 13 | public Token getName() { 14 | return name; 15 | } 16 | 17 | public Expression getInitializer() { 18 | return initializer; 19 | } 20 | 21 | @Override 22 | public R accept(StatementVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/UnaryExp.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class UnaryExp extends Expression { 4 | 5 | private final Token operator; 6 | private final Expression rightExp; 7 | 8 | public UnaryExp(Token operator, Expression rightExp) { 9 | this.operator = operator; 10 | this.rightExp = rightExp; 11 | } 12 | 13 | public Token getOperator() { 14 | return operator; 15 | } 16 | 17 | public Expression getRightExp() { 18 | return rightExp; 19 | } 20 | 21 | @Override 22 | public R accept(ExpressionVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/snapmacro/lang/RepeatStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class RepeatStatement extends Statement { 4 | 5 | private final Expression value; 6 | private final Statement loopBody; 7 | 8 | public RepeatStatement(Expression value, Statement loopBody) { 9 | this.value = value; 10 | this.loopBody = loopBody; 11 | } 12 | 13 | public Expression getValue() { 14 | return value; 15 | } 16 | 17 | public Statement getLoopBody() { 18 | return loopBody; 19 | } 20 | 21 | @Override 22 | public R accept(StatementVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } -------------------------------------------------------------------------------- /.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /src/snapmacro/lang/KeyboardStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class KeyboardStatement extends Statement { 4 | 5 | private final Token order; 6 | private final KeyboardKey keyboardKey; 7 | 8 | public KeyboardStatement(Token order, KeyboardKey keyboardKey) { 9 | this.order = order; 10 | this.keyboardKey = keyboardKey; 11 | } 12 | 13 | public Token getOrder() { 14 | return order; 15 | } 16 | 17 | public KeyboardKey getKeyboardKey() { 18 | return keyboardKey; 19 | } 20 | 21 | @Override 22 | public R accept(StatementVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/snapmacro/lang/WhileStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class WhileStatement extends Statement { 4 | 5 | private final Expression condition; 6 | private final Statement loopBody; 7 | 8 | public WhileStatement(Expression condition, Statement loopBody) { 9 | this.condition = condition; 10 | this.loopBody = loopBody; 11 | } 12 | 13 | public Expression getCondition() { 14 | return condition; 15 | } 16 | 17 | public Statement getLoopBody() { 18 | return loopBody; 19 | } 20 | 21 | @Override 22 | public R accept(StatementVisitor visitor) { 23 | return visitor.visit(this); 24 | } 25 | } -------------------------------------------------------------------------------- /SnapMacro.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/snapmacro/lang/IfStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.util.List; 4 | 5 | public class IfStatement extends Statement{ 6 | 7 | private final Expression condition; 8 | private final List body; 9 | 10 | public IfStatement(Expression condition, List body){ 11 | this.condition = condition; 12 | this.body = body; 13 | } 14 | 15 | public Expression getCondition(){ 16 | return condition; 17 | } 18 | 19 | public List getBody(){ 20 | return body; 21 | } 22 | 23 | @Override 24 | public R accept(StatementVisitor visitor) { 25 | return visitor.visit(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/snapmacro/lang/FunctionStatement.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.util.List; 4 | 5 | public class FunctionStatement extends Statement { 6 | 7 | private final Token name; 8 | private final List functionBody; 9 | 10 | public FunctionStatement(Token name, List functionBody) { 11 | this.name = name; 12 | this.functionBody = functionBody; 13 | } 14 | 15 | public Token getName(){ 16 | return name; 17 | } 18 | 19 | public List getFunctionBody() { 20 | return functionBody; 21 | } 22 | 23 | @Override 24 | public R accept(StatementVisitor visitor) { 25 | return visitor.visit(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/snapmacro/lang/StatementVisitor.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public interface StatementVisitor { 4 | R visit(IfStatement statement); 5 | R visit(WhileStatement statement); 6 | R visit(FunctionStatement statement); 7 | R visit(VarStatement statement); 8 | R visit(ExpressionStatement statement); 9 | R visit(RepeatStatement statement); 10 | R visit(BlockStatement statement); 11 | 12 | R visit(MousePointStatement statement); 13 | R visit(MouseClickStatement statement); 14 | R visit(MouseWheelStatement statement); 15 | R visit(KeyboardStatement statement); 16 | R visit(ScreenStatement statement); 17 | R visit(EchoStatement statement); 18 | R visit(ExitStatement statement); 19 | R visit(SleepStatement statement); 20 | } 21 | -------------------------------------------------------------------------------- /src/snapmacro/lang/LogicalExp.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class LogicalExp extends Expression{ 4 | 5 | private Expression leftExp; 6 | private Token operator; 7 | private Expression rightExp; 8 | 9 | public LogicalExp(Expression leftExp, Token operator, Expression rightExp) { 10 | this.leftExp = leftExp; 11 | this.operator = operator; 12 | this.rightExp = rightExp; 13 | } 14 | 15 | public Expression getLeftExp() { 16 | return leftExp; 17 | } 18 | 19 | public Token getOperator() { 20 | return operator; 21 | } 22 | 23 | public Expression getRightExp() { 24 | return rightExp; 25 | } 26 | 27 | @Override 28 | public R accept(ExpressionVisitor visitor) { 29 | return visitor.visit(this); 30 | } 31 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/BinaryExp.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class BinaryExp extends Expression { 4 | 5 | private final Expression leftExp; 6 | private final Token operator; 7 | private final Expression rightExp; 8 | 9 | public BinaryExp(Expression leftExp, Token operator, Expression rightExp) { 10 | this.leftExp = leftExp; 11 | this.operator = operator; 12 | this.rightExp = rightExp; 13 | } 14 | 15 | public Expression getLeftExp() { 16 | return leftExp; 17 | } 18 | 19 | public Token getOperator() { 20 | return operator; 21 | } 22 | 23 | public Expression getRightExp() { 24 | return rightExp; 25 | } 26 | 27 | @Override 28 | public R accept(ExpressionVisitor visitor) { 29 | return visitor.visit(this); 30 | } 31 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/SnapFunction.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | 4 | public class SnapFunction implements SnapCallable { 5 | 6 | private FunctionStatement declaration; 7 | private final Environment closure; 8 | 9 | private final boolean isInitializer; 10 | 11 | public SnapFunction(FunctionStatement declaration, Environment closure, boolean isInitializer){ 12 | this.closure = closure; 13 | this.declaration = declaration; 14 | this.isInitializer = isInitializer; 15 | } 16 | 17 | @Override 18 | public Object call(Interpreter interpreter) { 19 | Environment environment = new Environment(closure); 20 | interpreter.execute(declaration.getFunctionBody(), environment); 21 | if (isInitializer) return closure.getAt(0, "this"); 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/snapmacro/lang/ListenerMessage.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | public class ListenerMessage { 8 | 9 | private static final DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); 10 | 11 | public static void showStreamMessage(StreamListener listener, String message){ 12 | if(listener != null){ 13 | listener.getStreamListener(message); 14 | } 15 | } 16 | 17 | public static void showDebugMessage(DebuggerListener listener, String message, DebugType type){ 18 | if(listener != null){ 19 | Date date = new Date(); 20 | String datedMessage = dateFormat.format(date) + ":\t" + message + "\n"; 21 | listener.getDebugMessages(datedMessage, type); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/snapmacro/lang/Token.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | public class Token { 4 | 5 | private final TokenType type; 6 | private final String lexeme; 7 | private final Object literal; 8 | private final int line; 9 | 10 | public Token(TokenType type, String lexeme, 11 | Object literal, int line) { 12 | this.type = type; 13 | this.lexeme = lexeme; 14 | this.literal = literal; 15 | this.line = line; 16 | } 17 | 18 | public TokenType getType() { 19 | return type; 20 | } 21 | 22 | public String getLexeme() { 23 | return lexeme; 24 | } 25 | 26 | public Object getLiteral() { 27 | return literal; 28 | } 29 | 30 | public int getLine() { 31 | return line; 32 | } 33 | 34 | public String toString() { 35 | return type + " " + lexeme + " " + literal; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/snapmacro/lang/CallExp.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.util.List; 4 | 5 | public class CallExp extends Expression { 6 | 7 | private final Expression callee; 8 | private final Token closingParenthesis; 9 | private final List arguments; 10 | 11 | public CallExp(Expression calle, Token paren, List arguments) { 12 | this.callee = calle; 13 | this.closingParenthesis = paren; 14 | this.arguments = arguments; 15 | } 16 | 17 | public Expression getCallee() { 18 | return callee; 19 | } 20 | 21 | public Token getClosingParenthesis() { 22 | return closingParenthesis; 23 | } 24 | 25 | public List getArguments() { 26 | return arguments; 27 | } 28 | 29 | @Override 30 | public R accept(ExpressionVisitor visitor) { 31 | return visitor.visit(this); 32 | } 33 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/MouseController.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.awt.*; 4 | import java.awt.event.InputEvent; 5 | 6 | public class MouseController { 7 | 8 | private final Robot mCursorRobot; 9 | 10 | public MouseController(Robot robot) { 11 | mCursorRobot = robot; 12 | } 13 | 14 | public void mouseRightClick() { 15 | mCursorRobot.mousePress(InputEvent.BUTTON3_DOWN_MASK); 16 | mCursorRobot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); 17 | } 18 | 19 | public void mouseLeftClick() { 20 | mCursorRobot.mousePress(InputEvent.BUTTON1_DOWN_MASK); 21 | mCursorRobot.delay(100); 22 | mCursorRobot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); 23 | } 24 | 25 | public void mouseWheels(int value) { 26 | mCursorRobot.mouseWheel(value); 27 | } 28 | 29 | public Point getPosition() { 30 | return MouseInfo.getPointerInfo().getLocation(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Amr Hesham 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/snapmacro/utils/DialogUtils.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | import javafx.scene.control.Alert; 4 | 5 | public class DialogUtils { 6 | 7 | public static void createInformationDialog(String title, String header, String content) { 8 | Alert infoDialog = new Alert(Alert.AlertType.INFORMATION); 9 | infoDialog.setTitle(title); 10 | infoDialog.setHeaderText(header); 11 | infoDialog.setContentText(content); 12 | infoDialog.showAndWait(); 13 | } 14 | 15 | public static void createWarningDialog(String title, String header, String content){ 16 | Alert warnDialog = new Alert(Alert.AlertType.WARNING); 17 | warnDialog.setTitle(title); 18 | warnDialog.setHeaderText(header); 19 | warnDialog.setContentText(content); 20 | warnDialog.showAndWait(); 21 | } 22 | 23 | public static void createErrorDialog(String title, String header, String content){ 24 | Alert errorDialog = new Alert(Alert.AlertType.ERROR); 25 | errorDialog.setTitle(title); 26 | errorDialog.setHeaderText(header); 27 | errorDialog.setContentText(content); 28 | errorDialog.showAndWait(); 29 | } 30 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/ScreenController.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import javax.imageio.ImageIO; 4 | import java.awt.*; 5 | import java.awt.image.BufferedImage; 6 | import java.io.File; 7 | import java.io.IOException; 8 | 9 | public class ScreenController { 10 | 11 | private final Robot mCursorRobot; 12 | 13 | public ScreenController(Robot robot){ 14 | mCursorRobot = robot; 15 | } 16 | 17 | public void takeScreenshot(String path) throws IOException { 18 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 19 | int width = (int) screenSize.getWidth(); 20 | int height = (int) screenSize.getHeight(); 21 | 22 | Rectangle fullScreen = new Rectangle(width, height); 23 | BufferedImage bufferedImage = mCursorRobot.createScreenCapture(fullScreen); 24 | 25 | path = path + File.separator + System.currentTimeMillis() + ".jpg"; 26 | 27 | File screenshot = new File(path); 28 | ImageIO.write(bufferedImage, "jpg", screenshot); 29 | } 30 | 31 | public String getCurrentPixelColor() { 32 | PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 33 | Point point = pointerInfo.getLocation(); 34 | Color color = mCursorRobot.getPixelColor(point.x, point.y); 35 | return String.format("0x%02x%02x%02x%n", color.getRed(), color.getGreen(), color.getBlue()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/snapmacro/utils/ThemeManager.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | import javafx.application.Platform; 4 | import javafx.scene.Scene; 5 | 6 | public class ThemeManager { 7 | 8 | public static final String DARK_THEME_PATH = "/snapmacro/styles/dark_theme.css"; 9 | public static final String WHITE_THEME_PATH = "/snapmacro/styles/white_theme.css"; 10 | 11 | public static void setTheme(Scene stage, Theme theme) { 12 | switch (theme){ 13 | case DARK: 14 | setDarkTheme(stage); 15 | break; 16 | case WHITE: 17 | setWhiteTheme(stage); 18 | break; 19 | } 20 | } 21 | 22 | public static void setDarkTheme(Scene scene){ 23 | Platform.runLater(() -> { 24 | scene.getStylesheets().remove(WHITE_THEME_PATH); 25 | scene.getStylesheets().add(DARK_THEME_PATH); 26 | }); 27 | } 28 | 29 | public static void setWhiteTheme(Scene scene){ 30 | Platform.runLater(() -> { 31 | scene.getStylesheets().remove(DARK_THEME_PATH); 32 | scene.getStylesheets().add(WHITE_THEME_PATH); 33 | }); 34 | } 35 | 36 | public static String getThemePath(Theme theme){ 37 | switch (theme){ 38 | case DARK: return DARK_THEME_PATH; 39 | case WHITE: return WHITE_THEME_PATH; 40 | } 41 | return WHITE_THEME_PATH; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/snapmacro/utils/Settings.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | import java.util.prefs.Preferences; 4 | 5 | public class Settings { 6 | 7 | private final Preferences mSettingsPreference; 8 | 9 | private static final String SETTINGS = "settings"; 10 | private static final String THEME = "theme"; 11 | private static final Theme DEFAULT_THEME = Theme.WHITE; 12 | private OnThemeChangeListener mOnThemeChangeListener; 13 | 14 | public Settings() { 15 | mSettingsPreference = Preferences.userRoot().node(SETTINGS); 16 | mSettingsPreference.addPreferenceChangeListener(event -> { 17 | if(event.getKey().equals(THEME)){ 18 | if(mOnThemeChangeListener == null){ 19 | return; 20 | } 21 | mOnThemeChangeListener.onThemeChange(Theme.valueOf(event.getNewValue())); 22 | } 23 | }); 24 | } 25 | 26 | public Preferences getSettingPreference() { 27 | return mSettingsPreference; 28 | } 29 | 30 | public void setThemeChangeListener(OnThemeChangeListener listener) { 31 | mOnThemeChangeListener = listener; 32 | } 33 | 34 | public void setTheme(Theme theme) { 35 | mSettingsPreference.put(THEME, theme.name()); 36 | } 37 | 38 | public String getTheme() { 39 | return mSettingsPreference.get(THEME, DEFAULT_THEME.name()); 40 | } 41 | 42 | public Theme getThemeEnum(){ 43 | String theme = mSettingsPreference.get(THEME, DEFAULT_THEME.name()); 44 | return Theme.valueOf(theme); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/snapmacro/Main.java: -------------------------------------------------------------------------------- 1 | package snapmacro; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.scene.image.Image; 8 | import javafx.stage.Stage; 9 | import snapmacro.utils.AppConst; 10 | import snapmacro.utils.Settings; 11 | import snapmacro.utils.Theme; 12 | import snapmacro.utils.ThemeManager; 13 | 14 | public class Main extends Application { 15 | 16 | private static Stage mainStage; 17 | 18 | @Override 19 | public void start(Stage primaryStage) throws Exception{ 20 | mainStage = primaryStage; 21 | Parent root = FXMLLoader.load(getClass().getResource("views/main_view.fxml")); 22 | Scene scene = new Scene(root, AppConst.MIN_WIDTH, AppConst.MIN_HEIGHT); 23 | 24 | //Bind Styles 25 | Image appIconImage = new Image(Main.class.getResourceAsStream("res/app_icon.png")); 26 | primaryStage.setTitle(AppConst.NAME); 27 | primaryStage.getIcons().add(appIconImage); 28 | primaryStage.setMinWidth(AppConst.MIN_WIDTH); 29 | primaryStage.setMinHeight(AppConst.MIN_HEIGHT); 30 | primaryStage.setOnCloseRequest(event -> System.exit(0)); 31 | primaryStage.setScene(scene); 32 | primaryStage.show(); 33 | 34 | Settings settings = new Settings(); 35 | ThemeManager.setTheme(scene, Theme.valueOf(settings.getTheme())); 36 | settings.setThemeChangeListener(theme -> ThemeManager.setTheme(scene, theme)); 37 | } 38 | 39 | public static void main(String[] args) { 40 | launch(args); 41 | } 42 | 43 | public static Stage getMainStage(){ 44 | return mainStage; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/snapmacro/lang/Environment.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Environment { 7 | 8 | public final Environment enclosing; 9 | private final Map valuesMap = new HashMap<>(); 10 | 11 | public Environment() { 12 | enclosing = null; 13 | } 14 | 15 | public Environment(Environment enclosing) { 16 | this.enclosing = enclosing; 17 | } 18 | 19 | public Object get(Token name) { 20 | if (valuesMap.containsKey(name.getLexeme())) { 21 | return valuesMap.get(name.getLexeme()); 22 | } 23 | 24 | //If the variable isn’t found in this scope, we simply try the enclosing one 25 | if (enclosing != null) return enclosing.get(name); 26 | 27 | throw new RuntimeException("Undefined variable '" + name.getLexeme() + "'."); 28 | } 29 | 30 | public void define(String name, Object value) { 31 | valuesMap.put(name, value); 32 | } 33 | 34 | public void assign(Token name, Object value) { 35 | if (valuesMap.containsKey(name.getLexeme())) { 36 | valuesMap.put(name.getLexeme(), value); 37 | return; 38 | } 39 | //Again, if the variable isn’t in this environment, it checks the outer one, recursively. 40 | if (enclosing != null) { 41 | enclosing.assign(name, value); 42 | return; 43 | } 44 | throw new RuntimeException("Undefined variable '" + name.getLexeme() + "'."); 45 | } 46 | 47 | void assignAt(int distance, Token name, Object value) { 48 | ancestor(distance).valuesMap.put(name.getLexeme(), value); 49 | } 50 | 51 | public Object getAt(int distance, String name) { 52 | return ancestor(distance).valuesMap.get(name); 53 | } 54 | 55 | Environment ancestor(int distance) { 56 | Environment environment = this; 57 | for (int i = 0; i < distance; i++) { 58 | environment = environment.enclosing; 59 | } 60 | 61 | return environment; 62 | } 63 | } -------------------------------------------------------------------------------- /src/snapmacro/ui/SnapSyntax.java: -------------------------------------------------------------------------------- 1 | package snapmacro.ui; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | public class SnapSyntax { 6 | 7 | public static final String[] KEYWORDS = { 8 | "var", "func", "mouse", "keyboard", "screen", "capture", 9 | "point", "click", "press", "wheel", "release", "right", "left", 10 | 11 | "true", "false", "while", "if", "repeat", "exit", "delay", "echo", 12 | "or", "xor", "and" 13 | }; 14 | 15 | public static final String[] KEYBOARD_KEYS = { 16 | // Characters and digits 17 | "CHAR_[A-Z]", "DIGIT_[0-9]", 18 | 19 | // Virtual Keys 20 | "ENTER", "BACK_SPACE", "BACK_SPACE", "TAB", 21 | "SPACE", "ESCAPE", "ALT", "SHIFT", "CONTROL", 22 | "PAGE_UP", "PAGE_DOWN", "HOME", "END", 23 | 24 | // Arrows 25 | "UP", "DOWN", "RIGHT", "LEFT", 26 | 27 | // F 1 to 24 28 | "F[0-9]", "F1[0-9]", "F2[0-4]" 29 | }; 30 | 31 | private static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b"; 32 | private static final String KEYS_PATTERN = "\\b(" + String.join("|", KEYBOARD_KEYS) + ")\\b"; 33 | private static final String PAREN_PATTERN = "\\(|\\)"; 34 | private static final String BRACE_PATTERN = "\\{|\\}"; 35 | private static final String BRACKET_PATTERN = "\\[|\\]"; 36 | private static final String COMMENT_PATTERN = "#[0-9a-zA-Z ]*"; 37 | private static final String OPERATION_PATTERN = "==|>|<|!=|>=|<=|=|>|<|%|-|\\+|\\-|\\-=|\\^|\\&|\\|::|\\?|\\*"; 38 | private static final String HEX_NUMBERS_PATTERN = "0x[0-9a-fA-F]+"; 39 | private static final String NUMBERS_PATTERN = "[0-9]+"; 40 | 41 | public static final Pattern PATTERN = Pattern.compile( 42 | "(?" + KEYWORD_PATTERN + ")" 43 | + "|(?" + KEYS_PATTERN + ")" 44 | + "|(?" + PAREN_PATTERN + ")" 45 | + "|(?" + BRACE_PATTERN + ")" 46 | + "|(?" + BRACKET_PATTERN + ")" 47 | + "|(?" + COMMENT_PATTERN + ")" 48 | + "|(?" + OPERATION_PATTERN + ")" 49 | + "|(?" + HEX_NUMBERS_PATTERN + ")" 50 | + "|(?" + NUMBERS_PATTERN + ")" 51 | 52 | ); 53 | } 54 | -------------------------------------------------------------------------------- /src/snapmacro/styles/dark_theme.css: -------------------------------------------------------------------------------- 1 | /* Main Theme */ 2 | .root { 3 | -fx-background-color: #303030; 4 | } 5 | 6 | .split-pane-divider { 7 | -fx-background-color: #cccccc; 8 | -fx-padding: 1.5px ; 9 | } 10 | 11 | /* Terminal Theme */ 12 | .text-area { 13 | text-area-background: #272822 ; 14 | -fx-text-fill: gray; 15 | } 16 | 17 | .text-area .content { 18 | -fx-background-color: text-area-background ; 19 | } 20 | 21 | /* Tabs Theme */ 22 | .tab-pane .tab-header-area .tab-header-background { 23 | -fx-opacity: 0; 24 | } 25 | 26 | .tab-pane { 27 | -fx-tab-min-width: 90px; 28 | -fx-background-color: #272822; 29 | } 30 | 31 | .tab { 32 | -fx-background-insets: 0 1 0 1, 0, 0; 33 | } 34 | 35 | .tab-pane .tab { 36 | -fx-background-color: #cccccc; 37 | } 38 | 39 | .tab-pane .tab:selected { 40 | -fx-background-color: #3c3c3c; 41 | } 42 | 43 | .tab .tab-label { 44 | -fx-alignment: CENTER; 45 | -fx-text-fill: #828282; 46 | -fx-font-size: 12px; 47 | -fx-font-weight: bold; 48 | } 49 | 50 | .tab:selected .tab-label { 51 | -fx-alignment: CENTER; 52 | } 53 | 54 | .tab-pane:top *.tab-header-area { 55 | -fx-background-insets: 0, 0 0 1 0; 56 | -fx-padding: 0.416667em 0.166667em 0.0em 0.0em; 57 | } 58 | 59 | /* Code Area Theme */ 60 | .lineno { 61 | -fx-background-color: #303030; 62 | } 63 | 64 | .styled-text-area{ 65 | -fx-background-color: #272822; 66 | } 67 | 68 | .styled-text-area .text{ 69 | -fx-fill: #f8f8f2; 70 | } 71 | 72 | .styled-text-area .text.keyword { 73 | -fx-fill: #f82671; 74 | -fx-font-weight: bold; 75 | } 76 | 77 | .styled-text-area .text.paren { 78 | -fx-fill: #f8f8f2; 79 | -fx-font-weight: bold; 80 | } 81 | 82 | .styled-text-area .text.bracket { 83 | -fx-fill: #f8f8f2; 84 | -fx-font-weight: bold; 85 | } 86 | 87 | .styled-text-area .text.brace { 88 | -fx-fill: #f8f8f2; 89 | -fx-font-weight: bold; 90 | } 91 | 92 | .styled-text-area .text.keys { 93 | -fx-fill: #e6da74; 94 | } 95 | 96 | .styled-text-area .text.comment { 97 | -fx-fill: #ae81ff; 98 | } 99 | 100 | .styled-text-area .text.operation { 101 | -fx-fill: #e17b20; 102 | } 103 | 104 | .styled-text-area .text.number{ 105 | -fx-fill: #ae81ff; 106 | } 107 | 108 | .styled-text-area .text.hexnumber{ 109 | -fx-fill: #ae81ff; 110 | } 111 | 112 | .paragraph-box:has-caret { 113 | -fx-background-color: #1c1c1c99; 114 | } 115 | 116 | .caret { 117 | -fx-stroke: #f8f8f2; 118 | } -------------------------------------------------------------------------------- /src/snapmacro/styles/white_theme.css: -------------------------------------------------------------------------------- 1 | /* Main Theme */ 2 | .root { 3 | -fx-background-color: #ffffff; 4 | } 5 | 6 | .split-pane-divider { 7 | -fx-background-color: #cccccc; 8 | -fx-padding: 1.5px ; 9 | } 10 | 11 | /* Terminal Theme */ 12 | .text-area { 13 | text-area-background: #ffffff ; 14 | -fx-text-fill: black; 15 | } 16 | 17 | .text-area .content { 18 | -fx-background-color: text-area-background ; 19 | } 20 | 21 | /* Tabs Theme */ 22 | .tab-pane .tab-header-area .tab-header-background { 23 | -fx-opacity: 0; 24 | } 25 | 26 | .tab-pane { 27 | -fx-tab-min-width: 90px; 28 | -fx-background-color: #ffffff; 29 | } 30 | 31 | .tab { 32 | -fx-background-insets: 0 1 0 1, 0, 0; 33 | } 34 | 35 | .tab-pane .tab { 36 | -fx-background-color: #eeeeee; 37 | } 38 | 39 | .tab-pane .tab:selected { 40 | -fx-background-color: #dddddd; 41 | } 42 | 43 | .tab .tab-label { 44 | -fx-alignment: CENTER; 45 | -fx-text-fill: #828282; 46 | -fx-font-size: 12px; 47 | -fx-font-weight: bold; 48 | } 49 | 50 | .tab:selected .tab-label { 51 | -fx-alignment: CENTER; 52 | } 53 | 54 | .tab-pane:top *.tab-header-area { 55 | -fx-background-insets: 0, 0 0 1 0; 56 | -fx-padding: 0.416667em 0.166667em 0.0em 0.0em; 57 | } 58 | 59 | /* Code Area Theme */ 60 | .lineno { 61 | -fx-background-color: #eeeeee; 62 | } 63 | 64 | .styled-text-area{ 65 | -fx-background-color: #ffffff; 66 | } 67 | 68 | .styled-text-area .text{ 69 | -fx-fill: #000000; 70 | } 71 | 72 | .styled-text-area .text.keyword { 73 | -fx-fill: #170ea0; 74 | -fx-font-weight: bold; 75 | } 76 | 77 | .styled-text-area .text.paren { 78 | -fx-fill: #505050; 79 | -fx-font-weight: bold; 80 | } 81 | 82 | .styled-text-area .text.bracket { 83 | -fx-fill: #505050; 84 | -fx-font-weight: bold; 85 | } 86 | 87 | .styled-text-area .text.brace { 88 | -fx-fill: #505050; 89 | -fx-font-weight: bold; 90 | } 91 | 92 | .styled-text-area .text.keys { 93 | -fx-fill: #009938; 94 | } 95 | 96 | .styled-text-area .text.comment { 97 | -fx-fill: #797979; 98 | } 99 | 100 | .styled-text-area .text.operation { 101 | -fx-fill: #e1371f; 102 | } 103 | 104 | .styled-text-area .text.number{ 105 | -fx-fill: #d684ff; 106 | } 107 | 108 | .styled-text-area .text.hexnumber{ 109 | -fx-fill: #d684ff; 110 | } 111 | 112 | .paragraph-box:has-caret { 113 | -fx-background-color: #cccccc; 114 | } 115 | 116 | .caret { 117 | -fx-stroke: #000000; 118 | } -------------------------------------------------------------------------------- /src/snapmacro/utils/FileManager.java: -------------------------------------------------------------------------------- 1 | package snapmacro.utils; 2 | 3 | import javafx.stage.DirectoryChooser; 4 | import javafx.stage.FileChooser; 5 | 6 | import java.io.File; 7 | import java.io.FileWriter; 8 | import java.io.IOException; 9 | 10 | public class FileManager { 11 | 12 | public static File createNewFile(String filePath) { 13 | try { 14 | File newFolder = new File(filePath); 15 | newFolder.createNewFile(); 16 | DialogUtils.createInformationDialog("Success", 17 | null, "New File Created"); 18 | return newFolder; 19 | } catch (IOException e) { 20 | String errorMessage = "Can't Create new file in this path"; 21 | DialogUtils.createErrorDialog("Error",null,errorMessage); 22 | return null; 23 | } 24 | } 25 | 26 | public static File createNewFolder(String filePath) { 27 | File newFolder = new File(filePath); 28 | newFolder.mkdir(); 29 | return newFolder; 30 | } 31 | 32 | public static File openSourceFile(String title) { 33 | FileChooser fileChooser = new FileChooser(); 34 | fileChooser.setTitle(title); 35 | 36 | FileChooser.ExtensionFilter snapExtension = 37 | new FileChooser.ExtensionFilter("Snap Script", "*.ss"); 38 | fileChooser.getExtensionFilters().add(snapExtension); 39 | 40 | return fileChooser.showOpenDialog(null); 41 | } 42 | 43 | public static File openSourceDir(String title) { 44 | DirectoryChooser chooser = new DirectoryChooser(); 45 | chooser.setTitle(title); 46 | return chooser.showDialog(null); 47 | } 48 | 49 | public static File saveAsSourceFile(String title) { 50 | FileChooser fileChooser = new FileChooser(); 51 | fileChooser.setTitle(title); 52 | return fileChooser.showSaveDialog(null); 53 | } 54 | 55 | public static void updateContent(File file, String content) { 56 | try { 57 | FileWriter fileWriter = new FileWriter(file); 58 | fileWriter.write(content); 59 | fileWriter.close(); 60 | DialogUtils.createInformationDialog("Success", null, "File content Updated"); 61 | } catch (IOException iox) { 62 | String errorMessage = "Can't Save this file, Please make sure this file not deleted"; 63 | DialogUtils.createErrorDialog("Error",null, errorMessage); 64 | } 65 | } 66 | 67 | public static void deleteFile(File file) { 68 | file.deleteOnExit(); 69 | } 70 | } -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/styles/dark_theme.css: -------------------------------------------------------------------------------- 1 | /* Main Theme */ 2 | .root { 3 | -fx-background-color: #303030; 4 | } 5 | 6 | .split-pane-divider { 7 | -fx-background-color: #cccccc; 8 | -fx-padding: 1.5px ; 9 | } 10 | 11 | /* Terminal Theme */ 12 | .text-area { 13 | text-area-background: #272822 ; 14 | -fx-text-fill: gray; 15 | } 16 | 17 | .text-area .content { 18 | -fx-background-color: text-area-background ; 19 | } 20 | 21 | /* Tabs Theme */ 22 | .tab-pane .tab-header-area .tab-header-background { 23 | -fx-opacity: 0; 24 | } 25 | 26 | .tab-pane { 27 | -fx-tab-min-width: 90px; 28 | -fx-background-color: #272822; 29 | } 30 | 31 | .tab { 32 | -fx-background-insets: 0 1 0 1, 0, 0; 33 | } 34 | 35 | .tab-pane .tab { 36 | -fx-background-color: #cccccc; 37 | } 38 | 39 | .tab-pane .tab:selected { 40 | -fx-background-color: #3c3c3c; 41 | } 42 | 43 | .tab .tab-label { 44 | -fx-alignment: CENTER; 45 | -fx-text-fill: #828282; 46 | -fx-font-size: 12px; 47 | -fx-font-weight: bold; 48 | } 49 | 50 | .tab:selected .tab-label { 51 | -fx-alignment: CENTER; 52 | } 53 | 54 | .tab-pane:top *.tab-header-area { 55 | -fx-background-insets: 0, 0 0 1 0; 56 | -fx-padding: 0.416667em 0.166667em 0.0em 0.0em; 57 | } 58 | 59 | /* Code Area Theme */ 60 | .lineno { 61 | -fx-background-color: #303030; 62 | } 63 | 64 | .styled-text-area{ 65 | -fx-background-color: #272822; 66 | } 67 | 68 | .styled-text-area .text{ 69 | -fx-fill: #f8f8f2; 70 | } 71 | 72 | .styled-text-area .text.keyword { 73 | -fx-fill: #f82671; 74 | -fx-font-weight: bold; 75 | } 76 | 77 | .styled-text-area .text.paren { 78 | -fx-fill: #f8f8f2; 79 | -fx-font-weight: bold; 80 | } 81 | 82 | .styled-text-area .text.bracket { 83 | -fx-fill: #f8f8f2; 84 | -fx-font-weight: bold; 85 | } 86 | 87 | .styled-text-area .text.brace { 88 | -fx-fill: #f8f8f2; 89 | -fx-font-weight: bold; 90 | } 91 | 92 | .styled-text-area .text.keys { 93 | -fx-fill: #e6da74; 94 | } 95 | 96 | .styled-text-area .text.comment { 97 | -fx-fill: #ae81ff; 98 | } 99 | 100 | .styled-text-area .text.operation { 101 | -fx-fill: #e17b20; 102 | } 103 | 104 | .styled-text-area .text.number{ 105 | -fx-fill: #ae81ff; 106 | } 107 | 108 | .styled-text-area .text.hexnumber{ 109 | -fx-fill: #ae81ff; 110 | } 111 | 112 | .paragraph-box:has-caret { 113 | -fx-background-color: #1c1c1c99; 114 | } 115 | 116 | .caret { 117 | -fx-stroke: #f8f8f2; 118 | } -------------------------------------------------------------------------------- /out/production/SnapMacro/snapmacro/styles/white_theme.css: -------------------------------------------------------------------------------- 1 | /* Main Theme */ 2 | .root { 3 | -fx-background-color: #ffffff; 4 | } 5 | 6 | .split-pane-divider { 7 | -fx-background-color: #cccccc; 8 | -fx-padding: 1.5px ; 9 | } 10 | 11 | /* Terminal Theme */ 12 | .text-area { 13 | text-area-background: #ffffff ; 14 | -fx-text-fill: black; 15 | } 16 | 17 | .text-area .content { 18 | -fx-background-color: text-area-background ; 19 | } 20 | 21 | /* Tabs Theme */ 22 | .tab-pane .tab-header-area .tab-header-background { 23 | -fx-opacity: 0; 24 | } 25 | 26 | .tab-pane { 27 | -fx-tab-min-width: 90px; 28 | -fx-background-color: #ffffff; 29 | } 30 | 31 | .tab { 32 | -fx-background-insets: 0 1 0 1, 0, 0; 33 | } 34 | 35 | .tab-pane .tab { 36 | -fx-background-color: #eeeeee; 37 | } 38 | 39 | .tab-pane .tab:selected { 40 | -fx-background-color: #dddddd; 41 | } 42 | 43 | .tab .tab-label { 44 | -fx-alignment: CENTER; 45 | -fx-text-fill: #828282; 46 | -fx-font-size: 12px; 47 | -fx-font-weight: bold; 48 | } 49 | 50 | .tab:selected .tab-label { 51 | -fx-alignment: CENTER; 52 | } 53 | 54 | .tab-pane:top *.tab-header-area { 55 | -fx-background-insets: 0, 0 0 1 0; 56 | -fx-padding: 0.416667em 0.166667em 0.0em 0.0em; 57 | } 58 | 59 | /* Code Area Theme */ 60 | .lineno { 61 | -fx-background-color: #eeeeee; 62 | } 63 | 64 | .styled-text-area{ 65 | -fx-background-color: #ffffff; 66 | } 67 | 68 | .styled-text-area .text{ 69 | -fx-fill: #000000; 70 | } 71 | 72 | .styled-text-area .text.keyword { 73 | -fx-fill: #170ea0; 74 | -fx-font-weight: bold; 75 | } 76 | 77 | .styled-text-area .text.paren { 78 | -fx-fill: #505050; 79 | -fx-font-weight: bold; 80 | } 81 | 82 | .styled-text-area .text.bracket { 83 | -fx-fill: #505050; 84 | -fx-font-weight: bold; 85 | } 86 | 87 | .styled-text-area .text.brace { 88 | -fx-fill: #505050; 89 | -fx-font-weight: bold; 90 | } 91 | 92 | .styled-text-area .text.keys { 93 | -fx-fill: #009938; 94 | } 95 | 96 | .styled-text-area .text.comment { 97 | -fx-fill: #797979; 98 | } 99 | 100 | .styled-text-area .text.operation { 101 | -fx-fill: #e1371f; 102 | } 103 | 104 | .styled-text-area .text.number{ 105 | -fx-fill: #d684ff; 106 | } 107 | 108 | .styled-text-area .text.hexnumber{ 109 | -fx-fill: #d684ff; 110 | } 111 | 112 | .paragraph-box:has-caret { 113 | -fx-background-color: #cccccc; 114 | } 115 | 116 | .caret { 117 | -fx-stroke: #000000; 118 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/RobotController.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.awt.*; 4 | import java.io.IOException; 5 | 6 | public class RobotController { 7 | 8 | private final Robot mCursorRobot; 9 | private final MouseController mMouseController; 10 | private final KeyboardController mKeyboardController; 11 | private final ScreenController mScreenController; 12 | 13 | private static RobotController mInstance = null; 14 | 15 | public static RobotController getInstance() { 16 | if (mInstance == null) { 17 | try { 18 | mInstance = new RobotController(); 19 | } catch (AWTException e) { 20 | System.out.println("can't init Robot Controller"); 21 | } 22 | } 23 | return mInstance; 24 | } 25 | 26 | private RobotController() throws AWTException { 27 | mCursorRobot = new Robot(); 28 | mMouseController = new MouseController(mCursorRobot); 29 | mKeyboardController = new KeyboardController(mCursorRobot); 30 | mScreenController = new ScreenController(mCursorRobot); 31 | } 32 | 33 | public void setCursorPosition(int x, int y) { 34 | mCursorRobot.mouseMove(x, y); 35 | } 36 | 37 | public void setCursorPositionPlus(int xp, int yp) { 38 | //Get current x and y values 39 | int xValue = MouseInfo.getPointerInfo().getLocation().x; 40 | int yValue = MouseInfo.getPointerInfo().getLocation().y; 41 | 42 | //Update values by offset values 43 | xValue = xValue + xp; 44 | yValue = yValue + yp; 45 | 46 | //Update cursor position 47 | setCursorPosition(xValue, yValue); 48 | } 49 | 50 | public void mouseRightClick() { 51 | mMouseController.mouseRightClick(); 52 | } 53 | 54 | public void mouseLeftClick() { 55 | mMouseController.mouseLeftClick(); 56 | } 57 | 58 | public void mouseWheels(int value) { 59 | mMouseController.mouseWheels(value); 60 | } 61 | 62 | public void keyboardPressKey(int key) { 63 | mKeyboardController.keyboardPressKey(key); 64 | } 65 | 66 | public void keyboardReleaseKey(int key) { 67 | mKeyboardController.keyboardReleaseKey(key); 68 | } 69 | 70 | public void captureScreen(String path) { 71 | try{ 72 | mScreenController.takeScreenshot(path); 73 | }catch (IOException e){ 74 | throw new RuntimeException("Invalid Directory path"); 75 | } 76 | } 77 | 78 | public String getCurrentPixelColor() { 79 | return mScreenController.getCurrentPixelColor(); 80 | } 81 | 82 | public void delay(int time){ 83 | mCursorRobot.delay(time); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Snap Macro 1.0.0 2 | 3 | Free and open source Cross-platform bot creator with a new scripting language called 4 | snap to interact with mouse, keyboard and screen using snap scripting language 5 | 6 | [![Download SnapMacro](https://a.fsdn.com/con/app/sf-download-button)](https://sourceforge.net/projects/snapmacro/files/latest/download) 7 | [![Download SnapMacro](https://img.shields.io/sourceforge/dt/snapmacro.svg)](https://sourceforge.net/projects/snapmacro/files/latest/download) 8 | 9 | Snap language has many features to make it easy to implement your bot 10 | 11 | 12 | 13 | ### Features: 14 | - variables, 15 | - conditions, 16 | - flow conditions like if, while loop, repeat loop 17 | - sleep, exit statements 18 | 19 | ### Editor shortcuts 20 | - `F1` to change editor theme dark/light 21 | - `F5` to run snap script 22 | - `F6` to run snap script in debugging mode 23 | - `F7` to restart the execution 24 | - `F8` to stop running snap script 25 | - `F9` to load new snap script file in new tab 26 | - `F10` to save current snap script file 27 | - `F11` Show/Stop the X and Y values in the current cursor position 28 | - `F12` Show/Stop the pixel value in the current cursor position 29 | - `F13` Clear the debugging info area 30 | 31 | For examples take a look at example directory 32 | 33 | ### How to use? 34 | To run SnapMacro Jar you need to install JDK 8 35 | Then You can download SnapMacro from [Here](https://github.com/AmrDeveloper/SnapMacro/raw/master/jar/SnapMacro.jar) 36 | 37 | ### Instructions 38 | 39 | #### Mouse 40 | 41 | ##### Perform right or left mouse click 42 | ` 43 | mouse click (left | right) 44 | ` 45 | 46 | ##### Move mouse cursor to x, y position 47 | ` 48 | mouse point x y 49 | ` 50 | 51 | #### Mouse wheel to control wheel and scroll down or up 52 | ``` 53 | mouse wheel 10 54 | mouse wheel -10 55 | ``` 56 | 57 | #### Keyboard 58 | 59 | #### Keyboard press key 60 | ` 61 | keyboard press key 62 | ` 63 | 64 | #### Keyboard keys 65 | ``` 66 | F1 to F11 67 | F12 to F24 68 | DIGIT_0 to DIGIT_9 69 | CHAR_A to CHAR_Z 70 | ``` 71 | 72 | #### Screen to take screenshot and store it in path 73 | ` 74 | screen capture "C:\Users\AmrDeveloper\Desktop\screenshots" 75 | ` 76 | 77 | ##### Sleep execution s milliseconds 78 | ` 79 | delay s 80 | ` 81 | 82 | #### Variables assign and reassign 83 | ` 84 | var x = 10 85 | x = x + 1 86 | ` 87 | 88 | #### If to execute the body if the condition is true 89 | ``` 90 | if(condition) { 91 | 92 | } 93 | ``` 94 | 95 | ##### Execute the body statements n times 96 | ``` 97 | repeat(n) { 98 | 99 | } 100 | ``` 101 | 102 | ##### Execute the body statements while the condition is true 103 | ``` 104 | while(condition) { 105 | 106 | } 107 | ``` 108 | 109 | ##### Function declaration to make easy to call or repeat instructions 110 | ``` 111 | func name { 112 | 113 | } 114 | ``` 115 | 116 | ##### Function call to execute function instructions 117 | ` 118 | name() 119 | ` 120 | 121 | #### Boolean values 122 | ``` 123 | true 124 | false 125 | ``` 126 | 127 | #### Math Operations 128 | ``` 129 | + / - * 130 | ``` 131 | 132 | #### Bitwise Operations 133 | ``` 134 | x and y 135 | x or y 136 | x xor y 137 | ``` 138 | 139 | #### Pixel Color to get color of current pointer position 140 | ``` 141 | mouse point 100 100 142 | var color = pixelColor() 143 | if(color == "0xffffff") { 144 | 145 | } 146 | ``` 147 | 148 | #### Restart the execution to start from first line 149 | ``` 150 | restart 151 | ``` 152 | 153 | #### Exit the execution to stop the script 154 | ``` 155 | exit 156 | ``` 157 | 158 | #### Comments to make your script more readable 159 | ``` 160 | # ..... 161 | ``` 162 | -------------------------------------------------------------------------------- /src/snapmacro/lang/KeyboardKey.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.awt.event.KeyEvent; 4 | 5 | enum KeyboardKey { 6 | 7 | // Characters A to Z 8 | CHAR_A("CHAR_A", KeyEvent.VK_A), 9 | CHAR_B("CHAR_B", KeyEvent.VK_B), 10 | CHAR_C("CHAR_C", KeyEvent.VK_C), 11 | CHAR_D("CHAR_D", KeyEvent.VK_D), 12 | CHAR_E("CHAR_E", KeyEvent.VK_E), 13 | CHAR_F("CHAR_F", KeyEvent.VK_F), 14 | CHAR_G("CHAR_G", KeyEvent.VK_G), 15 | CHAR_H("CHAR_H", KeyEvent.VK_H), 16 | CHAR_I("CHAR_I", KeyEvent.VK_I), 17 | CHAR_J("CHAR_J", KeyEvent.VK_J), 18 | CHAR_K("CHAR_K", KeyEvent.VK_K), 19 | CHAR_L("CHAR_L", KeyEvent.VK_L), 20 | CHAR_M("CHAR_M", KeyEvent.VK_M), 21 | CHAR_N("CHAR_N", KeyEvent.VK_N), 22 | CHAR_O("CHAR_O", KeyEvent.VK_O), 23 | CHAR_P("CHAR_P", KeyEvent.VK_P), 24 | CHAR_Q("CHAR_Q", KeyEvent.VK_Q), 25 | CHAR_R("CHAR_R", KeyEvent.VK_R), 26 | CHAR_S("CHAR_S", KeyEvent.VK_S), 27 | CHAR_T("CHAR_T", KeyEvent.VK_T), 28 | CHAR_U("CHAR_U", KeyEvent.VK_U), 29 | CHAR_V("CHAR_V", KeyEvent.VK_V), 30 | CHAR_W("CHAR_W", KeyEvent.VK_W), 31 | CHAR_X("CHAR_X", KeyEvent.VK_X), 32 | CHAR_Y("CHAR_Y", KeyEvent.VK_Y), 33 | CHAR_Z("CHAR_Z", KeyEvent.VK_Z), 34 | 35 | // Digit keys 36 | DIGIT_0("DIGIT_0", KeyEvent.VK_0), 37 | DIGIT_1("DIGIT_1", KeyEvent.VK_1), 38 | DIGIT_2("DIGIT_2", KeyEvent.VK_2), 39 | DIGIT_3("DIGIT_3", KeyEvent.VK_3), 40 | DIGIT_4("DIGIT_4", KeyEvent.VK_4), 41 | DIGIT_5("DIGIT_5", KeyEvent.VK_5), 42 | DIGIT_6("DIGIT_6", KeyEvent.VK_6), 43 | DIGIT_7("DIGIT_7", KeyEvent.VK_7), 44 | DIGIT_8("DIGIT_8", KeyEvent.VK_8), 45 | DIGIT_9("DIGIT_9", KeyEvent.VK_9), 46 | 47 | // Virtual keys 48 | ENTER("ENTER", KeyEvent.VK_ENTER), 49 | BACK_SPACE("BACK_SPACE", KeyEvent.VK_BACK_SPACE), 50 | CAPS_LOCK("BACK_SPACE", KeyEvent.VK_CAPS_LOCK), 51 | TAB("TAB", KeyEvent.VK_TAB), 52 | SPACE("SPACE", KeyEvent.VK_SPACE), 53 | ESCAPE("ESCAPE", KeyEvent.VK_ESCAPE), 54 | ALT("ALT", KeyEvent.VK_ALT), 55 | SHIFT("SHIFT", KeyEvent.VK_SHIFT), 56 | CONTROL("CONTROL", KeyEvent.VK_CONTROL), 57 | PAGE_UP("PAGE_UP", KeyEvent.VK_PAGE_UP), 58 | PAGE_DOWN("PAGE_DOWN", KeyEvent.VK_PAGE_DOWN), 59 | HOME("HOME", KeyEvent.VK_HOME), 60 | END("END", KeyEvent.VK_END), 61 | 62 | // Arrows keys 63 | UP("UP", KeyEvent.VK_UP), 64 | DOWN("DOWN", KeyEvent.VK_DOWN), 65 | RIGHT("RIGHT", KeyEvent.VK_RIGHT), 66 | LEFT("LEFT", KeyEvent.VK_LEFT), 67 | 68 | // F Keys 69 | F1("F1", KeyEvent.VK_F1), 70 | F2("F2", KeyEvent.VK_F2), 71 | F3("F3", KeyEvent.VK_F3), 72 | F4("F4", KeyEvent.VK_F4), 73 | F5("F5", KeyEvent.VK_F5), 74 | F6("F6", KeyEvent.VK_F6), 75 | F7("F7", KeyEvent.VK_F7), 76 | F8("F8", KeyEvent.VK_F8), 77 | F9("F9", KeyEvent.VK_F9), 78 | F10("F10", KeyEvent.VK_F10), 79 | F11("F11", KeyEvent.VK_F11), 80 | 81 | // F13 - F24 are used on IBM 3270 keyboard 82 | F12("F12", KeyEvent.VK_F12), 83 | F13("F13", KeyEvent.VK_F13), 84 | F14("F14", KeyEvent.VK_F14), 85 | F15("F15", KeyEvent.VK_F15), 86 | F16("F16", KeyEvent.VK_F16), 87 | F17("F17", KeyEvent.VK_F17), 88 | F18("F18", KeyEvent.VK_F18), 89 | F19("F19", KeyEvent.VK_F19), 90 | F20("F20", KeyEvent.VK_F20), 91 | F21("F21", KeyEvent.VK_F21), 92 | F22("F22", KeyEvent.VK_F22), 93 | F23("F23", KeyEvent.VK_F23), 94 | F24("F24", KeyEvent.VK_F24); 95 | 96 | private final String keyName; 97 | private final int keyValue; 98 | 99 | KeyboardKey(String key, int value) { 100 | keyName = key; 101 | keyValue = value; 102 | } 103 | 104 | public String getKeyName() { 105 | return keyName; 106 | } 107 | 108 | public int getKeyValue() { 109 | return keyValue; 110 | } 111 | } -------------------------------------------------------------------------------- /src/snapmacro/lang/SnapRuntime.java: -------------------------------------------------------------------------------- 1 | package snapmacro.lang; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.nio.charset.Charset; 7 | import java.nio.file.Files; 8 | import java.nio.file.Paths; 9 | import java.util.List; 10 | 11 | public class SnapRuntime { 12 | 13 | private static boolean hadError = false; 14 | private static boolean hadRuntimeError = false; 15 | private static final Interpreter interpreter = new Interpreter(); 16 | 17 | private StreamListener mStreamListener; 18 | private DebuggerListener mDebuggerListener; 19 | 20 | public SnapRuntime(StreamListener listener){ 21 | mStreamListener = listener; 22 | interpreter.setStreamListener(mStreamListener); 23 | } 24 | 25 | public SnapRuntime(DebuggerListener listener){ 26 | mDebuggerListener = listener; 27 | interpreter.setDebuggerListener(mDebuggerListener); 28 | } 29 | 30 | public SnapRuntime(StreamListener stream, DebuggerListener debugger){ 31 | mStreamListener = stream; 32 | interpreter.setStreamListener(mStreamListener); 33 | 34 | mDebuggerListener = debugger; 35 | interpreter.setDebuggerListener(mDebuggerListener); 36 | } 37 | 38 | public void runSnapFile(String path) throws IOException { 39 | byte[] bytes = Files.readAllBytes(Paths.get(path)); 40 | runSnapCode(new String(bytes, Charset.defaultCharset())); 41 | if (hadError) System.exit(65); 42 | if (hadRuntimeError) System.exit(70); 43 | } 44 | 45 | public void runSnapTerminal() throws IOException { 46 | InputStreamReader input = new InputStreamReader(System.in); 47 | BufferedReader reader = new BufferedReader(input); 48 | 49 | System.out.println("Welcome in Tank Programming lang"); 50 | while (true) { 51 | System.out.print("> "); 52 | runSnapCode(reader.readLine()); 53 | hadError = false; 54 | } 55 | } 56 | 57 | public void runSnapCode(String source) { 58 | SnapLexer tankLexer = new SnapLexer(source, mDebuggerListener); 59 | List tokens = tankLexer.scanTokens(); 60 | SnapParser parser = new SnapParser(tokens, mDebuggerListener); 61 | List statements = parser.parse(); 62 | 63 | //Start Tank Interpreter 64 | interpreter.interpret(statements); 65 | } 66 | 67 | public void setStreamListener(StreamListener listener){ 68 | mStreamListener = listener; 69 | interpreter.setStreamListener(mStreamListener); 70 | } 71 | 72 | public void removeStreamListener(){ 73 | interpreter.removeStreamListener(); 74 | } 75 | 76 | public void setDebuggerListener(DebuggerListener listener){ 77 | mDebuggerListener = listener; 78 | interpreter.setDebuggerListener(mDebuggerListener); 79 | } 80 | 81 | public void removeDebuggerListener(){ 82 | interpreter.removeDebuggerListener(); 83 | } 84 | 85 | public static void error(int line, String message) { 86 | report(line, "", message); 87 | } 88 | 89 | public static void error(Token token, String message) { 90 | if (token.getType() == TokenType.EOF) { 91 | report(token.getLine(), " at end", message); 92 | } else { 93 | report(token.getLine(), " at '" + token.getLexeme() + "'", message); 94 | } 95 | } 96 | 97 | private static void report(int line, String where, String message) { 98 | System.err.println("[line " + line + "] Error" + where + ": " + message); 99 | hadError = true; 100 | } 101 | 102 | public static void runtimeError(RuntimeError error) { 103 | System.err.println(error.getMessage() +" \n[line " + error.getToken().getLine() + "]"); 104 | hadRuntimeError = true; 105 | } 106 | 107 | public void stopInterpreter(){ 108 | interpreter.visit(new ExitStatement()); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/snapmacro/ui/SnapEditor.java: -------------------------------------------------------------------------------- 1 | package snapmacro.ui; 2 | 3 | import javafx.concurrent.Task; 4 | import javafx.scene.Node; 5 | import javafx.scene.control.TextArea; 6 | import org.fxmisc.richtext.CodeArea; 7 | import org.fxmisc.richtext.LineNumberFactory; 8 | import org.fxmisc.richtext.model.StyleSpans; 9 | import org.fxmisc.richtext.model.StyleSpansBuilder; 10 | 11 | import java.io.File; 12 | import java.time.Duration; 13 | import java.util.Collection; 14 | import java.util.Collections; 15 | import java.util.Optional; 16 | import java.util.concurrent.ExecutorService; 17 | import java.util.concurrent.Executors; 18 | import java.util.function.IntFunction; 19 | import java.util.regex.Matcher; 20 | 21 | public class SnapEditor { 22 | 23 | private CodeArea codeTextArea; 24 | private TextArea resultTextArea; 25 | 26 | private File sourceFile; 27 | private ExecutorService taskExecutor; 28 | 29 | public SnapEditor(CodeArea codeArea, TextArea resultArea){ 30 | taskExecutor = Executors.newSingleThreadExecutor(); 31 | codeTextArea = codeArea; 32 | resultTextArea = resultArea; 33 | } 34 | 35 | public void editorSettings(){ 36 | codeAreaHighlighter(); 37 | codeAreaAddLineNumber(); 38 | } 39 | 40 | private void codeAreaHighlighter() { 41 | codeTextArea.multiPlainChanges() 42 | .successionEnds(Duration.ofMillis(500)) 43 | .supplyTask(this::computeHighlightingAsync) 44 | .awaitLatest(codeTextArea.multiPlainChanges()) 45 | .filterMap(tryTask -> { 46 | if (tryTask.isSuccess()) { 47 | return Optional.of(tryTask.get()); 48 | } else { 49 | tryTask.getFailure().printStackTrace(); 50 | return Optional.empty(); 51 | } 52 | }) 53 | .subscribe(this::applyHighlighting); 54 | } 55 | 56 | private void codeAreaAddLineNumber() { 57 | IntFunction lineNumberFactory = LineNumberFactory.get(codeTextArea); 58 | codeTextArea.setParagraphGraphicFactory(lineNumberFactory); 59 | } 60 | 61 | private void applyHighlighting(StyleSpans> highlighting) { 62 | codeTextArea.setStyleSpans(0, highlighting); 63 | } 64 | 65 | private Task>> computeHighlightingAsync() { 66 | String text = codeTextArea.getText(); 67 | Task>> task = new Task>>() { 68 | @Override 69 | protected StyleSpans> call() { 70 | return computeHighlighting(text); 71 | } 72 | }; 73 | taskExecutor.execute(task); 74 | return task; 75 | } 76 | 77 | private static StyleSpans> computeHighlighting(String text) { 78 | Matcher matcher = SnapSyntax.PATTERN.matcher(text); 79 | int lastKeywordEnd = 0; 80 | StyleSpansBuilder> spansBuilder = new StyleSpansBuilder<>(); 81 | while (matcher.find()) { 82 | String styleClass = 83 | matcher.group("KEYWORD") != null ? "keyword" : 84 | matcher.group("PAREN") != null ? "paren" : 85 | matcher.group("BRACE") != null ? "brace" : 86 | matcher.group("BRACKET") != null ? "bracket" : 87 | matcher.group("KEYS") != null ? "keys" : 88 | matcher.group("OPERATION") != null ? "operation" : 89 | matcher.group("NUMBER") != null ? "number" : 90 | matcher.group("HEXNUMBER") != null ? "hexnumber" : 91 | matcher.group("COMMENT") != null ? "comment" : 92 | null; /* never happens */ 93 | assert styleClass != null; 94 | spansBuilder.add(Collections.emptyList(), matcher.start() - lastKeywordEnd); 95 | spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start()); 96 | lastKeywordEnd = matcher.end(); 97 | } 98 | spansBuilder.add(Collections.emptyList(), text.length() - lastKeywordEnd); 99 | return spansBuilder.create(); 100 | } 101 | 102 | public void updateSourceFile(File source) { 103 | sourceFile = source; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/snapmacro/views/main_view.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |