Skip to content

nostrangerstolove.java

Submission to the practice problem of the 17th Annual University of Evansville High School Programming Contest:

import java.awt.Robot;
import java.awt.event.*;

public class sampleProgram 
{
	public static void main(String [] args) throws Exception
	{
		Robot poop = new Robot();
		poop.keyPress(KeyEvent.VK_CAPS_LOCK);
		poop.keyRelease(KeyEvent.VK_CAPS_LOCK);
		poop.keyPress(KeyEvent.VK_WINDOWS);
		poop.keyRelease(KeyEvent.VK_WINDOWS);
		Thread.sleep(1000);
		poop.keyPress(KeyEvent.VK_R);
		poop.keyRelease(KeyEvent.VK_R);

		Thread.sleep(500);
		poop.keyPress(KeyEvent.VK_W);
		poop.keyRelease(KeyEvent.VK_W);
		poop.keyPress(KeyEvent.VK_W);
		poop.keyRelease(KeyEvent.VK_W);
		poop.keyPress(KeyEvent.VK_W);
		poop.keyRelease(KeyEvent.VK_W);
		poop.keyPress(KeyEvent.VK_PERIOD);
		poop.keyRelease(KeyEvent.VK_PERIOD);
		poop.keyPress(KeyEvent.VK_Y);
		poop.keyRelease(KeyEvent.VK_Y);
		poop.keyPress(KeyEvent.VK_O);
		poop.keyRelease(KeyEvent.VK_O);
		poop.keyPress(KeyEvent.VK_U);
		poop.keyRelease(KeyEvent.VK_U);
		poop.keyPress(KeyEvent.VK_T);
		poop.keyRelease(KeyEvent.VK_T);
		poop.keyPress(KeyEvent.VK_U);
		poop.keyRelease(KeyEvent.VK_U);
		poop.keyPress(KeyEvent.VK_B);
		poop.keyRelease(KeyEvent.VK_B);
		poop.keyPress(KeyEvent.VK_E);
		poop.keyRelease(KeyEvent.VK_E);
		poop.keyPress(KeyEvent.VK_PERIOD);
		poop.keyRelease(KeyEvent.VK_PERIOD);
		poop.keyPress(KeyEvent.VK_C);
		poop.keyRelease(KeyEvent.VK_C);
		poop.keyPress(KeyEvent.VK_O);
		poop.keyRelease(KeyEvent.VK_O);
		poop.keyPress(KeyEvent.VK_M);
		poop.keyRelease(KeyEvent.VK_M);
		poop.keyPress(KeyEvent.VK_SLASH);
		poop.keyRelease(KeyEvent.VK_SLASH);
		
		poop.keyPress(KeyEvent.VK_SHIFT);
		poop.keyPress(KeyEvent.VK_W);
		poop.keyRelease(KeyEvent.VK_W);
		poop.keyPress(KeyEvent.VK_A);
		poop.keyRelease(KeyEvent.VK_A);
		poop.keyPress(KeyEvent.VK_T);
		poop.keyRelease(KeyEvent.VK_T);
		poop.keyPress(KeyEvent.VK_C);
		poop.keyRelease(KeyEvent.VK_C);
		poop.keyPress(KeyEvent.VK_H);
		poop.keyRelease(KeyEvent.VK_H);
		poop.keyRelease(KeyEvent.VK_SHIFT);
		
		
		poop.keyPress(KeyEvent.VK_SHIFT);
		poop.keyPress(KeyEvent.VK_SLASH);
		poop.keyRelease(KeyEvent.VK_SLASH);
		poop.keyRelease(KeyEvent.VK_SHIFT);

		poop.keyPress(KeyEvent.VK_SHIFT);


		poop.keyPress(KeyEvent.VK_V);
		poop.keyRelease(KeyEvent.VK_V);

		poop.keyRelease(KeyEvent.VK_SHIFT);
		
		poop.keyPress(KeyEvent.VK_EQUALS);
		poop.keyRelease(KeyEvent.VK_EQUALS);
		
		poop.keyPress(KeyEvent.VK_SHIFT);
		
		poop.keyPress(KeyEvent.VK_E);

		poop.keyRelease(KeyEvent.VK_E);
		poop.keyRelease(KeyEvent.VK_SHIFT);
		poop.keyPress(KeyEvent.VK_B);
		poop.keyRelease(KeyEvent.VK_B);
		poop.keyPress(KeyEvent.VK_G);
		poop.keyRelease(KeyEvent.VK_G);
		poop.keyPress(KeyEvent.VK_I);
		poop.keyRelease(KeyEvent.VK_I);
		poop.keyPress(KeyEvent.VK_Q);
		poop.keyRelease(KeyEvent.VK_Q);
		poop.keyPress(KeyEvent.VK_7);
		poop.keyRelease(KeyEvent.VK_7);
		poop.keyPress(KeyEvent.VK_Z);
		poop.keyRelease(KeyEvent.VK_Z);

		poop.keyPress(KeyEvent.VK_SHIFT);
		poop.keyPress(KeyEvent.VK_U);
		poop.keyRelease(KeyEvent.VK_U);
		poop.keyPress(KeyEvent.VK_U);
		poop.keyRelease(KeyEvent.VK_U);
		poop.keyPress(KeyEvent.VK_I);
		poop.keyRelease(KeyEvent.VK_I);

		poop.keyRelease(KeyEvent.VK_SHIFT);

		poop.keyPress(KeyEvent.VK_U);
		poop.keyRelease(KeyEvent.VK_U);


		Thread.sleep(500);
		poop.keyRelease(KeyEvent.VK_ENTER);
		poop.keyPress(KeyEvent.VK_ENTER);
	}
}
//http://www.youtube.com/watch?v=eBGIQ7ZuuiU

Code explanation: java.awt.Robot “is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed.” It generates actual input events for the system, so instantiating a Robot and calling keyPress and keyRelease for a key will generate the same effect as if a user had physically pressed and released that key. This code “presses” the Windows key and waits a second for the Start menu to open, selects “Run…” with the R key and waits half a second for that, enters the URL found in the comment at the bottom of the listing, and opens that page in a web browser with Enter.

Submission result: Wrong Answer

Explanation of result: file compiled and tested on a Mac, so source failed to either answer the problem correctly or produce the intended effect

Post a Comment

You must be logged in to post a comment.