Windows: Game: mouse clicks and key press not accepted

Asked by Tony

I'm trying to use Sikuli to do some mouse clicks in a game, Team Fortress 2.

I've discovered that it wont left mouse click within the game, and I'm guessing its because the game uses a different way of determining mouse clicks and as such sikuli wont work.

I did however think that I might be able to use Windows's MouseKeys, which uses the plus sign on the numpad as the left mouse button.

However:
keyDown(Key.ADD)
keyUp(Key.ADD)

This works in notepad and puts in the plus sign, when I press the key with my finger I get a left mouse click, but sikuli doesn't wont use it as a click.

Is what I'm trying possible?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

I guess the game is generally blocking the use of Java Robot class, which is internally used by Sikuli for simulating mouse and keyboard actions. This is the case for some games and other applications that do not want to allow programatic control.

Another thing that sometimes shows up: When running the Sikuli script with admin rights, mouse and keyboard actions start to work.

Revision history for this message
Tony (mrthaggar) said :
#2

Thanks RaiMan, that solved my question.

Revision history for this message
Tony (mrthaggar) said :
#3

The problem was solved by running Sikuli with admin rights. Thanks very much!

Oh while I'm thinking. Is there anyway for Sikuli to read numbers on screen?

Thanks again

Revision history for this message
RaiMan (raimund-hocke) said :
#4

You might try Region.text()

But be aware: bug 710586

The other possibility: If manually copy&paste is possible, you might simulate the copy with mouse actions and finally use Env.getClipboard(), to get the text containing the numbers.