|
|
@ -16,11 +16,18 @@ import java.util.Map; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
|
|
|
import javax.sound.sampled.AudioInputStream; |
|
|
|
|
|
|
|
import javax.sound.sampled.AudioSystem; |
|
|
|
|
|
|
|
import javax.sound.sampled.Clip; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import exceptions.FailedResponseException; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.AWTException; |
|
|
|
import java.awt.AWTException; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Robot; |
|
|
|
import java.awt.Robot; |
|
|
|
import java.awt.GraphicsEnvironment; |
|
|
|
import java.awt.GraphicsEnvironment; |
|
|
|
|
|
|
|
import java.net.http.HttpResponse; |
|
|
|
|
|
|
|
|
|
|
|
import readers.Box; |
|
|
|
import readers.Box; |
|
|
|
import readers.fonts.Font; |
|
|
|
import readers.fonts.Font; |
|
|
@ -95,6 +102,10 @@ public class sigPlace { |
|
|
|
if (args.length>0&&args[0].equals("arcade")) { |
|
|
|
if (args.length>0&&args[0].equals("arcade")) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Robot r = new Robot(); |
|
|
|
Robot r = new Robot(); |
|
|
|
|
|
|
|
Reader lastReader = null; |
|
|
|
|
|
|
|
int matches=0; |
|
|
|
|
|
|
|
final int EXPECTED_MATCHES=20; |
|
|
|
|
|
|
|
boolean submitted=false; |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); |
|
|
|
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); |
|
|
|
if (new Color(screenshot.getRGB(1550,604)).equals(SDVX_UI_COL)) { |
|
|
|
if (new Color(screenshot.getRGB(1550,604)).equals(SDVX_UI_COL)) { |
|
|
@ -115,7 +126,22 @@ public class sigPlace { |
|
|
|
ImageIO.write(screenshot,"png",temp.toFile()); |
|
|
|
ImageIO.write(screenshot,"png",temp.toFile()); |
|
|
|
result.interpretBoxes(temp, true); |
|
|
|
result.interpretBoxes(temp, true); |
|
|
|
if (result.isReasonableData()) { |
|
|
|
if (result.isReasonableData()) { |
|
|
|
System.out.println("Data is reasonable, prepare for submitting..."); |
|
|
|
if (lastReader!=null&&lastReader.equals(result)) { |
|
|
|
|
|
|
|
matches++; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
lastReader=result; |
|
|
|
|
|
|
|
matches=0; |
|
|
|
|
|
|
|
submitted=false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (matches>=EXPECTED_MATCHES&&!submitted) { |
|
|
|
|
|
|
|
System.out.println("Data is reasonable, prepare for submitting..."); |
|
|
|
|
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",temp); |
|
|
|
|
|
|
|
if (((HttpResponse<String>)postRes.run()).statusCode()==200) { |
|
|
|
|
|
|
|
playSound(Paths.get("ding.wav")); |
|
|
|
|
|
|
|
System.out.println("Successful!"); |
|
|
|
|
|
|
|
submitted=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/*if (result.isReasonableData()) { |
|
|
|
/*if (result.isReasonableData()) { |
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",Path.of("..",filename)); |
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",Path.of("..",filename)); |
|
|
@ -123,7 +149,7 @@ public class sigPlace { |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(50); |
|
|
|
Thread.sleep(50); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (AWTException | InterruptedException | IOException e) { |
|
|
|
} catch (AWTException | InterruptedException | IOException | FailedResponseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -729,5 +755,16 @@ public class sigPlace { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}public static void playSound(Path file) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file.toFile()); |
|
|
|
|
|
|
|
Clip clip = AudioSystem.getClip(); |
|
|
|
|
|
|
|
clip.open(audioInputStream); |
|
|
|
|
|
|
|
clip.start(); |
|
|
|
|
|
|
|
// If you want the sound to loop infinitely, then put: clip.loop(Clip.LOOP_CONTINUOUSLY);
|
|
|
|
|
|
|
|
// If you want to stop the sound, then use clip.stop();
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|