I got click at to work for Safari, but not minecraft. I saw cliclick but I don't want people to have to install that. This procedure is being used in an application I'm making, so I need actual code.
Install the resulting shell command in your App's bundle, and call it with a 'do shell script' or an Objective C launchedTaskWithLaunchPath:arguments:.