Home > Back-end > Java method to control the computer hardware have?
Java method to control the computer hardware have?
Time:09-24
Recently in play a little game, similar to qq dazzle dance, but which much simpler than, and just kept have to do is press a button, so I'm going to write a program, the main function is to press a button, keyboard and to understand the Java awt. Robot, wrote a piece of code, after test no problem, then prepare to test in the game, then the question arises - programs running outside of the time no problem, whether in notepad or other time can do have been normal press a button, but after the click to enter the game interface, the code is ineffective, I try to open the game inside the dialog box, also does not have any output, is represented in the game, can't normal operation procedure, but a little outside is ok, I think it is also a virtual machine code and game, Java all want to know is there any way can directly control the hardware keyboard output, such as calling Windows API or how, is no matter in what circumstances do similar real press a button, the hope can help to solve,
CodePudding user response:
Or is there any more at the bottom of the API can complete keyboard simulation,
CodePudding user response:
You can try to use an administrator to run, or the project into exe, run as an administrator, I give you a similar before, but I was more than the keyboard operation, at the time the game also the mouse operation, then there will be another problem, coordinates is right but obviously every time corresponding will appear deviation, probably because the game itself has also done a protection, because robot is not real hardware input, did protection will be reminded of his way to the game