For the record, here's the question in the state it was deleted:
How can you programmatically simulate a keypress / mousemove?
I'm trying to write a program that simulates key-press events and/or mouse-move events, without any interaction by the user.
For example with a command like
a key press event would be sent to the focused window.
How can this be done in java or python?
You're doing the answer a bit of a disservice: while it is probably not the right answer for the asker's situation, a key-pressing robot is the way people who manufacture devices test user interaction. For a device with an external keyboard, it's easier to use a fake keyboard that generates events directly as signals on e.g. a PS/2 or USB bus, but some devices don't have external keyboards. This approach is only used when testing devices as a whole — when testing an application the right approach is of course to inject keyboard events at the OS or library stack level. So this is not purely a joke answer — but it deserves downvoting as not helpful.
Regarding the question, it's perfectly on-topic for SO — it's about programming. The question is incomplete because it doesn't say what operating system is being targeted. The answers are going to be completely different on different operating system. So the proper reaction to this question is to:
- Vote to close as “unclear what you're asking — Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking.”
- Write a comment asking what operating system the asker is running.
- Reopen the question once the missing information is added. If that information never comes, delete the question.
The question was closed as “Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself.” This makes no sense since this question does not concern a problem with code. It's a pretty common case of abuse of close reasons on Stack Overflow, unfortunately.
I've voted to undelete the question, because it isn't so bad that it needs to be deleted — it just required a little clarification, which no one bothered to ask for. Unfortunately, it's probably too late for this question — we've probably lost one more asker who might have asked a good question with just a little bit of guidance (that would have taken less time to write than the joke answer and all the associated comments).