Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import java.awt.Robot;
  2. import java.awt.event.KeyEvent;
  3. import java.awt.AWTException;
  4. import java.nio.file.*;
  5.  
  6. void setup() {
  7.  
  8. String pathToVideo = "D:\\Videos\\Desktop";
  9.  
  10.  
  11.  
  12. try {
  13.  
  14. long preFileCount = Files.list(Paths.get(pathToVideo)).count();
  15.  
  16. Robot robot = new Robot();
  17.  
  18. // Simulate a key press
  19. robot.keyPress(KeyEvent.VK_ALT);
  20. robot.keyPress(KeyEvent.VK_F9);
  21. robot.keyRelease(KeyEvent.VK_F9);
  22. robot.keyRelease(KeyEvent.VK_ALT);
  23.  
  24. delay(2000); //make sure that geforce experience had time to start/stop recording
  25.  
  26. long postFileCount = Files.list(Paths.get(pathToVideo)).count();
  27. if(postFileCount == preFileCount) {
  28. //then we stopped the video and should hit alt+f9 again to start recording a new file
  29. // Simulate a key press
  30. robot.keyPress(KeyEvent.VK_ALT);
  31. robot.keyPress(KeyEvent.VK_F9);
  32. robot.keyRelease(KeyEvent.VK_F9);
  33. robot.keyRelease(KeyEvent.VK_ALT);
  34. }
  35.  
  36. // new File(<directory path>).list().length
  37.  
  38.  
  39. String[] cmd = { "D:\\Projects\\social_dinner_runnable\\social_dinner_runnable.exe", "-sendInvites" };
  40. //String[] cmd = { "D:\\Projects\\social_dinner_runnable\\social_dinner_runnable.exe -sendInvites" };
  41. Process p = Runtime.getRuntime().exec(cmd);
  42. p.waitFor();
  43.  
  44.  
  45. }
  46. catch (AWTException e) {
  47. e.printStackTrace();
  48. }
  49. catch (IOException e) {
  50. e.printStackTrace();
  51. }
  52. catch (InterruptedException e) {
  53. e.printStackTrace();
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement