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

CodePudding user response:

refer to the second floor qq_41622282 response:
you can try to use an administrator to run, or put the project into exe, run as an administrator, I give you a similar before, but I was more than the keyboard operation, when the game going to operate the mouse, 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, games do the protection will be reminded of his way to the

Later I use C language use keybd_event implements, which is the must use an administrator to run, game open the chat window can simulate the keyboard output, but small game in game when the button is useless, estimation is the game has a protective mechanism or the trigger condition is not normal, ha ha ha, too complicated in force in the game to achieve typing calculate,
  • Related