0

I'm having a weird issue. I'm trying to do some clicking with the robot class in java. All works fine except for when chrome is in focus. This is my method:

public static void click(int X, int Y) {
    PointerInfo info = MouseInfo.getPointerInfo();
    Point p = info.getLocation();
  //robo.mouseRelease(InputEvent.BUTTON1_MASK);
    robo.mouseMove(X, Y);
    robo.mousePress(InputEvent.BUTTON1_MASK);
    robo.mouseRelease(InputEvent.BUTTON1_MASK);
    System.out.println("Clicked at X: "+X+" Y: "+Y);
  //robo.mouseMove((int) p.getX(), (int) p.getY());
}

It just won't move or click when Chrome is focused. If I switch to notepad for example, it works.

Does Chrome have some kind of anti-macro stuff going on?

Thanks, have a nice day!

eltabo
  • 3,749
  • 1
  • 21
  • 33
Sorin Grecu
  • 1,036
  • 11
  • 30
  • What does Chrome have to do with Java? Are you developing an applet running that's inside Chrome? – markspace Aug 22 '14 at 22:08
  • I know it doesn't have anything to do with it or at least it shouldn't but it just won't move the mouse and click when Chrome is in focus. I can't figure out what the issue is. And no, it is not an applet. – Sorin Grecu Aug 22 '14 at 22:09
  • Dunno, does the Java program still run when Chrome is in the foreground? If your JVM is paused in the background it obviously won't run. – markspace Aug 22 '14 at 22:10
  • Yes. I'm doing the clicks inside a timer every 15 seconds, i have a countdown GUI that is always on top. If i switch to chrome, the mouse won't move or click. If i switch to teamviewer for example, or whatever other app, it will move and click. Very weird. – Sorin Grecu Aug 22 '14 at 22:13
  • Sounds more like a Windows/Linux/whatever your platform thing is. Chrome could be requesting some sort of exclusive focus, rather than a "normal" shared focus. I know Windows and Java both have "full screen exclusive" mode, so perhaps Chrome uses something like that? I'd ask again as a Windows question, you might get more info there. – markspace Aug 22 '14 at 22:22

1 Answers1

0

Well, I suspected that Windows was the issue from the very get go since after the last reinstall i had some issues with it. I had the same Windows from my hidden partition for 4 years now,reinstalling it every 4-6 months. Last week, when I reinstalled it, i had some permission issues, out of nowhere. I couldn't delete, move, copy, access stuff,etc. Had to play with ownership and stuff. Dunno where this came from, I didn't allow any windows updates thru. Unless it updated my hidden partition setup files, which I don't know if it is possible.

So last night I figured hey, lets activate the hidden Administrator account and see if the issue is still there. Well, it isn't. And now I went back to my normal account and all is fine now.

Short version: Enabled the hidden Administrator account on Windows 7, the issue is now gone on both accounts. Have a good day and thanks for your help!

Sorin Grecu
  • 1,036
  • 11
  • 30