2

I have a Java application that I want to bring to the front at regular intervals, but I haven't been able to do this.

[Aside to people wanting to offer user interface advice. Yes, this is normally horrible, but I'm the only one using the app. It's my time&billing app, and I'm tired failing to record billable hours!]

I've tried with AppleScript, and have no problem getting Firefox to do this, with the following script:

tell application "Firefox"
repeat
    activate
    delay 10
end repeat
end tell

But I don't know how reference a Java app in AppleScript (that is, I don't know what to put for the appication's name).

  • tell application "java" doesn't work (and there may be several Java apps running).
  • tell application "NameShowingInMenu" doesn't work, either.
  • I've tried setting "-Xdoc:name", that works for setting the name shown in the menu, but not for a "tell" target.

Any ideas?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
ThoughtfulHacking
  • 1,189
  • 2
  • 8
  • 23
  • It works like this with my Java applications using their process name from Activity Monitor. – Chris Feb 27 '11 at 22:01

2 Answers2

2

I was able to do this, using the "Jar Bundler" app, which is included with Max OS X.

Once I packaged my code using that, it behaved as a standard mac application and the script in my original question worked with no problems.

ThoughtfulHacking
  • 1,189
  • 2
  • 8
  • 23
0

If you can do this in the Java app itself, you could get a hint from:

How to bring a window to the front?

Community
  • 1
  • 1
Arve
  • 8,058
  • 2
  • 22
  • 25
  • Tried that. It only controls window position within your app. That is, it will make that window the front window in your app. It doesn't bring the whole app to the front. – ThoughtfulHacking Feb 27 '11 at 23:30