diff --git a/DivaBot/src/sig/MyRobot.java b/DivaBot/src/sig/MyRobot.java index 99a55c3..a5f21a1 100644 --- a/DivaBot/src/sig/MyRobot.java +++ b/DivaBot/src/sig/MyRobot.java @@ -126,7 +126,7 @@ public class MyRobot{ boolean EyeTrackingIsOn() { //1888,760 if (System.currentTimeMillis()-5000>lastReportedEyeTrackingTime) { - BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(1865,724,1,1))); + BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(1865,760,1,1))); Color pixel = new Color(img.getRGB(0, 0)); lastReportedEyeTrackingTime=System.currentTimeMillis(); eyeTrackingSceneOn=pixel.getRed()<60 && pixel.getGreen()<60 && pixel.getBlue()<60; @@ -170,6 +170,12 @@ public class MyRobot{ p.pullData(selectedSong.title,difficulty); prevSongTitle=selectedSong.title; prevDifficulty=difficulty; + MYROBOT.keyPress(KeyEvent.VK_CONTROL); + MYROBOT.keyPress(KeyEvent.VK_SHIFT); + MYROBOT.keyPress(KeyEvent.VK_F11); + MYROBOT.keyRelease(KeyEvent.VK_F11); + MYROBOT.keyRelease(KeyEvent.VK_SHIFT); + MYROBOT.keyRelease(KeyEvent.VK_CONTROL); } } lastSongSelectTime = System.currentTimeMillis(); @@ -188,14 +194,15 @@ public class MyRobot{ if (OnResultsScreen() && !recordedResults && !recordingResults && results.size()==0) { lastSongSelectTime=System.currentTimeMillis(); - if (EyeTrackingIsOn()) { - eyeTrackingSceneOn=false; - lastReportedEyeTrackingTime=System.currentTimeMillis(); - gotoxy(800,64); - click(); - gotoxy(1870,724); - click(); - } + gotoxy(800,64); + click(); + MYROBOT.setAutoDelay(0); + MYROBOT.keyPress(KeyEvent.VK_CONTROL); + MYROBOT.keyPress(KeyEvent.VK_SHIFT); + MYROBOT.keyPress(KeyEvent.VK_F12); + MYROBOT.keyRelease(KeyEvent.VK_F12); + MYROBOT.keyRelease(KeyEvent.VK_SHIFT); + MYROBOT.keyRelease(KeyEvent.VK_CONTROL); //1885,761 //System.out.println(typeface1.extractNumbersFromImage(MYROBOT.createScreenCapture(new Rectangle(1235,451,115,26)))); //System.out.println(typeface1.extractNumbersFromImage(MYROBOT.createScreenCapture(new Rectangle(1235,484,115,26)))); @@ -258,14 +265,15 @@ public class MyRobot{ results.add(new Result(selectedSong.title,difficulty,cool,fine,safe,sad,worst,percent,fail)); SoundUtils.playSound("collect_item.wav"); - if (!EyeTrackingIsOn()) { - eyeTrackingSceneOn=true; - lastReportedEyeTrackingTime=System.currentTimeMillis(); - gotoxy(800,64); - click(); - gotoxy(1870,724); - click(); - } + gotoxy(800,64); + click(); + MYROBOT.setAutoDelay(0); + MYROBOT.keyPress(KeyEvent.VK_CONTROL); + MYROBOT.keyPress(KeyEvent.VK_SHIFT); + MYROBOT.keyPress(KeyEvent.VK_F11); + MYROBOT.keyRelease(KeyEvent.VK_F11); + MYROBOT.keyRelease(KeyEvent.VK_SHIFT); + MYROBOT.keyRelease(KeyEvent.VK_CONTROL); } } else { if (results.size()>0) { diff --git a/DivaBot/src/sig/utils/FileUtils.java b/DivaBot/src/sig/utils/FileUtils.java index eb44c97..9e420ee 100644 --- a/DivaBot/src/sig/utils/FileUtils.java +++ b/DivaBot/src/sig/utils/FileUtils.java @@ -8,8 +8,11 @@ import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; +import java.io.Writer; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; @@ -18,6 +21,7 @@ import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -258,6 +262,7 @@ public class FileUtils { logToFile(message,filename,false); } + public static void logToFile(String message, String filename, boolean outputToChatLog) { File file = new File(filename); try { @@ -265,9 +270,9 @@ public class FileUtils { if (!file.exists()) { file.createNewFile(); } - - FileWriter fw = new FileWriter(file, true); - PrintWriter pw = new PrintWriter(fw); + OutputStream out = new FileOutputStream(file,true); + Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8); + PrintWriter pw = new PrintWriter(writer); pw.println(message); pw.flush(); @@ -353,7 +358,7 @@ public class FileUtils { } - public static void downloadFileFromUrl(String url, String file,boolean bearer) throws IOException, JSONException { + public static void downloadFileFromUrl(String url, String file) throws IOException, JSONException { File filer = new File(file); filer.createNewFile(); @@ -364,12 +369,6 @@ public class FileUtils { }*/ connection.setRequestMethod("GET"); //connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("Accept", "application/vnd.twitchtv.v5+json"); - connection.setRequestProperty("Authorization", ((bearer)?"Bearer":"OAuth") + " "+sigIRC.oauth.replace("oauth:", "")); - if (sigIRC.CLIENTID.length()!=0) { - connection.setRequestProperty("Client-ID", sigIRC.CLIENTID); - //System.out.println("Using "+ sigIRC.oauth+"/"+sigIRC.CLIENTID); - } try { ReadableByteChannel rbc = Channels.newChannel(connection.getInputStream()); FileOutputStream fos = new FileOutputStream(file); @@ -379,8 +378,4 @@ public class FileUtils { System.out.println("Failed to connect, moving on..."); } } - - public static void downloadFileFromUrl(String url, String file) throws IOException, JSONException { - downloadFileFromUrl(url,file,false); //Uses OAUTH instead of Bearer - } }