问题
I am new to programming, I want to write a program (just for self-use) that will repeat a preset set of keyboard actions every time it is run, can anyone give me some advice? are there any applications that can do this already?
回答1:
There are a pretty good variety of programs out there that do what you're looking for. If you're on windows, autoHotKey will set you right. On Mac, it's automator (built-in) or Keyboard Maestro to the rescue.
These use a domain specific language for creating macros, which will be much simpler than attempting something yourself from scratch in a more general purpose language.
回答2:
You should use global keyboard hook.
There are .dll files that provide access to functions which enable you to send global keystrokes.
In Windows they are located in User32.dll but you can use wrappers if you're not familiar with hooking to DLL functions. For what language do you need this?
回答3:
What language do you program in? Java is a popular beginners language, you could read-up about the Robot class. It has functions that do "sendKeys"-type things.
来源:https://stackoverflow.com/questions/13551710/a-program-to-simulate-keyboard-presses