Java control OS mouse/keyboard
i was wondering how i would go about creating a Java program that is able to grab control of the mouse cursor and keyboard, and for example, have it click open and close windows, type some words in textpad or a URL location in a browser, browse around a bit, and close and shutdown the computer --- as if a person was actually using the mouse and keyboard, but all done automatically through the program code. so in effect, running the Java program would be like watching a pre-recorded video of somebody doing all this stuff. i suppose this has potential as a prank-type of program, but that's not my intention; i'm looking for a way to make a Java program that can automate tasks on this level, of mouse clicking and dragging and keyboard input. it'd be cool if somebody could also elaborate on grabbing control and processing other low-level input data, but mouse and keyboard are my main thoughts right now.
any ideas? btw, i have a Windows XP workstation.
thanx for any help and replies,