I’m new to AppleScript. I’m trying to deal with a game program that is deliberately script-hostile. In UIEI it just exposes a graphics window. To see the kind of thing I’m getting, use UIEI on the main window in Netscape 7.2, for example. We all know there are “clickable” places on those Netscape pages, but there is no way to address them. (The problem is NOT in Netscape at all, but in the game program. I just used Netscape as an example to show what I get from UIEI.)
What I need is a way to have a macro put my mouse at a specific location on the screen, click there, wait, move and click that, wait some more, move and click somewhere else, and then repeat the sequence a given number of times. The Windows folks have lots of MacroExpress macros available, and are ribbing me about getting a “real computer” that can do that stuff. A dozen years ago, we had “Quick Keys” and other programs that could do this. Has the Mac lost so much that this is no longer possible?
You have “click” and “keystroke” (just in case you could use combos of tabs, enters or spaces) in “System Events”, and a entire “Cursor Suite” within the XTool scripting addition: http://www.osaxen.com/xtool.html
btw, clicking (or similar behaviours) in web pages is very easy writing a bit of javascript (unless you are talking about Flash, Java or other things).
I read the docs for the XTool suite, and it seems that it involves only list manipulation. I was only able to download V 1.0, not 1.1. The docs and the package itself both contain only eight commands, all of which deal with list processing. None of the neat mouse commands described in http://www.osaxen.com/additions/xtool.html actually seem to be available, nor is there a link to anything that would let me download the later (1.1) version.
Thank you very much. I now have V1.1, and am working on combining the mouse commands with Wait commands to create the macro I need. Oh, and measuring the screen moves as well, although I think I can probably crib them from the existing WinXP MacroExpress macros.
I am having a problem with the XTool mouse click command. It does not seem to work as expected.
I have Preview with the XTool instructions open, and the red “close” button is located on my screen at {16. 34}. I activate the Script editor before going any further, but the Preview application is still visible underneath.
If I physically move the mouse to {16.34} and physically click it, Preview will close. However, if I write a script like the one below and execute it in the Script editor, my cursor moves to the right location, but the “click” action never happens (or if it does it has no effect).
move mouse (16, 34)
mouse click
I have tried adding an “activate” command at the start of the macro, but that doesn’t do anything either. I know I’m doing something wrong, but I don’t understand what.
Can anyone help?
The actual application (a game program) I am trying to use this on is Applescript-hostile, and doesn’t even respond properly to an “activate” command.
I can get this script to activate the game window, but it still will not accept a mouse click from me. I’ve tried the “click” command and the XTools “mouse click” command, and neither one works.
Anybody got a way to get a mouse click in to a recalcitrant program?
I’m having the same problem with a java-based game in a browser(safari) window. I can position the mouse, but clicking doesn’t process. I found that the game doesn’t recognize the mouse unless a “real” mouse move has occured. Then clicking is possible by hand not script.
Is there a way to script “real” mouse movements rather than just positioning the mouse at specific coordinates?
Hmmm… actually I just realized that it might be possible if I could just run a script from Safari without leaving it… I don’t know how to implement this though.
Well, I’ve learned a little more about the way the game program works. It is running under FLTK with 3D graphics via OpenGL. Apparently AppleScript is just sending the click to the underlying window, and not to the OpenGL application. The FLTK (game) app is using “Quartz” to get its instructions from the OS X window (presumably object) manager.
So the real question is, how do I get into that food chain via AppleScript (or additions thereto)?
A workaround is available. I can use QuicKeys, the commercial application, to send mouse clicks successfully to the game program. But this means I can only share my macros with those fellow Mac gamers willing to shell out $100 (or $60 academic pricing) for the QuicKeys app. Why QuicKeys works and AppleScript fails I have no clue.
I’d SURE rather be able to do this in AppleScript, though. Any further thoughts?
Just a different idea… (Can I d/l the game to test?) You can drive some games using the keyboard (eg, space = fire, a = increase energy, enter = purchase item), or just using the basics, such as: space = click selected button, tab = go to next button/text field… Could you use this with System Events’ “keystroke” command?
Well, I tried sending the app a “mouse click” via the character, which is the keyboard shortcut in the app for a mouse click.
Once again, I can get it to work fine when done manually (i.e., position the real mouse in a location and physically push the key), but nothing happens when I try to send the click via typing a key in Applescript.
Try using SEC Helper from salling clicker if you are desperate. www.salling.com. I happen to know SEC Helper will always respond to commands even if you dont have a bluetooth phone, or a bluetooth enabled mac, or a registered copy. It is actually a very powerfull little scriptable app. Try it!
Oh and BTW, SEC Helper can click where no scripting addtion has clicked before…hehe
OK, I’ve downloaded the trial of Salling Clicker. But it has next to zero information about what SEC Helper is, or how it is used. There seems to be no information available on how to access it or use it.
Do you know where I can get some help with this thing?