There are several tools you can use to automate things on your PC. The ones I like are: GhostMouse, Screen Event Recorder, and the Java Robot class.
This is a freeware program that records mouse movements and clicks. This can then be played back, making the computer execute the recorded mouse events. It's extremely simple to use. Unfortunately the home page for it is not operational anymore, but you can still download it here.
Screen Event Recorder
There is an article here about running DLL's as stand alone programs, and the example they use is this screen event recorder DLL. This is a great program that records both mouse and keyboard events, but it's slightly harder to use than GhostMouse. I don't think it was ever meant to be anything more than an example program, so the documentation and interface aren't refined.
To get started, download the files (warning, registration required), double-click on "EventFile.reg" and install the contents, then go to the "Release" folder.
If you read the article, you'll find that it's slightly difficult to start the program. The main problem is that you can't just double click on something to run the program. Here's what you do (the article also explains this), open a command prompt, go to the "Release" folder, and put in the command:
This will use the built-in windows program "RullDll32.exe" to run "MacRcrd.dll" as a stand alone program. I believe that the "PlayFile" option just opens the program with no default recording to run.
After you've gotten the GUI to run, there's only one more thing that's kind of confusing, and not explained anywhere. You need to type in the name of an event file in order for everything to work properly. Just type in any name you want with a ".evr" extension. If the file doesn't exist the program will create it. For starters, just type "test.evr" and test out the record and playback buttons.
In Java, there is a class called Robot. Utilizing this class, a Java program can control the mouse, send key board commands, get the Color of a single pixel on the screen, pause the program, among other things. testRobot.java is an example of how to use the Robot class.
Keyboard keys can be specified with the KeyEvent class. If you can't find the key you want in there, then you can use KeyEventDemo.java to find the key code for any key on your keyboard. This is a demo program that comes with the Java SDK.
A more advanced example program is this fishing bot for FFXI (Final Fantasy XI) that I wrote a while ago. Instructions on how to use it are fairly lengthy and cryptic, so I won't get into it. You need to edit the program to suit your needs anyways. Use at your own risk.