<file_sep>/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.3/userguide/tutorial_java_projects.html
 */
buildscript {
    dependencies {
        classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
    }

    repositories {
        mavenLocal()
        mavenCentral()
    }
}
plugins {
    // Apply the java plugin to add support for Java
    id 'java'
    // Apply the application plugin to add support for building an application
    id 'application'
}

//javafx {
//	version = "8.0.0"
//	modules = [ 'javafx.controls', 'javafx.fxml']
//}
version = '1.0'
mainClassName = 'automation.FXGUI'
//makes a jar with dependencies
jar {
    manifest {
        attributes "Main-Class": mainClassName
    }

    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
}
sourceSets.main {
    java {
        srcDir 'src/main/java' //assume that your source codes are inside this path
    }
    resources {
        srcDirs = ['src/main/java', 'src/main/resources']
        exclude "**/*.java"
    }
}
apply plugin: 'javafx-gradle-plugin'
jfx {
	mainClass = mainClassName
	vendor = 'AutoRoutine'
}
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
	maven {
		url "https://raw.github.com/kristian/system-hook/mvn-repo/"
	}
	mavenLocal()
	mavenCentral()
}

dependencies {
    // This dependency is found on compile classpath of this component and consumers.
    implementation 'com.google.guava:guava:27.0.1-jre'
	implementation 'com.1stleg:jnativehook:2.1.0'
	implementation 'de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2'
    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
}<file_sep>package main.java.automation;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;

import main.java.listener.KeyListener;
import main.java.listener.MouseListener;

import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
public class Auto {
	// Incomplete Auto class that should be able to automate tasks
	// Currently working on implementing Key and Mouse Listeners using jnativehook
	private int screenHeight;
	private int screenWidth;
	private boolean startCapture = false;
	private ArrayList<BufferedImage> imgs;
	public Auto() {
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		screenHeight = screenSize.height;
		screenWidth = screenSize.width;
	}
	public void roboAuto(String routinename) throws AWTException, FileNotFoundException {
		//This is supposed to open up a txt containing the preprogrammed routines and do it
		Robot rb = new Robot();
		FileReader file = new FileReader("src/automation/routines.txt");
		
		
	}
	public void learnRoutine() throws AWTException {
		//This tracks the mouse and keyboard actions and writes to a txt file 
		addListeners();
		startCapture=true;
		while (startCapture==true) {
			BufferedImage image = takeScreenshot(new Rectangle(screenWidth, screenHeight));
			imgs.add(image);
		}
		System.out.println("Stopped recording");
		try {
			GlobalScreen.unregisterNativeHook();
		} catch (NativeHookException e) {
			e.printStackTrace();
		}
	}
	private static void addListeners() {
		try {
			GlobalScreen.registerNativeHook();
		} catch (NativeHookException e) {
			e.printStackTrace();
		}
		KeyListener keylistener = new KeyListener();
		MouseListener mouselistener = new MouseListener();
		GlobalScreen.addNativeKeyListener(keylistener);
		GlobalScreen.addNativeMouseListener(mouselistener);
	}
	private BufferedImage takeScreenshot(Rectangle screenRect) throws AWTException {
			Robot rb = new Robot();
			BufferedImage img = rb.createScreenCapture(screenRect);
			return img;
	}
	public void stopRecording() {
		startCapture=false;
	}
}
<file_sep># AutoRoutine
[![Linux and Mac Build Status](https://travis-ci.com/rahulkaura2004/AutoRoutine.svg?branch=master)](https://travis-ci.com/rahulkaura2004/AutoRoutine)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/5ey3n5fgbu9fnkfn?svg=true)](https://ci.appveyor.com/project/lithomas1/autoroutine)


Created by <NAME> and <NAME> 

Improved by Kento Nishi
## Prerequisites 
Java 1.8
## OS Support
- [X] Windows
- [X] Mac
- [X] Linux

## Download
Clone the repository with git.
```
git clone https://github.com/rahulkaura2004/AutoRoutine
```

## Execution
1. Install gradle (find installation instructions [here](https://gradle.org/))
2. Navigate to the repository.
3. Run the following command:
```bash
gradlew run
```
All done! The program should build and execute.
<file_sep>package main.java.automation;

import java.awt.AWTException;

import javafx.fxml.FXML;
import javafx.scene.control.Button;

public class MainController {
	@FXML
	private Button newRoutine;
	@FXML
	private Button executeRoutine;
	private boolean started = false;
	private Auto auto;
	@FXML
	private void newRoutine() {
		if (started==true) {
			auto.stopRecording();
		}
		else {
			auto = new Auto();
			newRoutine.setText("Stop routine");
			started=true;
			try {
				auto.learnRoutine();
			} catch (AWTException e) {
				e.printStackTrace();
			}
		}
	}
	@FXML
	private void findExecRoutine() {
		
	}
}
