A syntaxic question...

Hi guys,

I've posted about this on this very forum before, but I can't find my own question... and the answers that you people provided, so I'll do it again: what's wrong with the following, knowing that I have Developer Tools installed and that I clearly remember writing a script along those lines a long time ago, when I was still using Tiger?

Here goes:

"move mouse
720, 450 {from left, from top}"

Where the goal is to move the mouse pointer center screen on startup (don't bother about compiling and saving as an app, just about the right syntax). Something's missing, but I can't put my finger on it...

MacBook Pro 2006, Mac OS X (10.6.5), 2GB RAM - Longing for a 17" MacBook Pro with the i5 chip...

Posted on Nov 12, 2010 1:00 AM

Reply
9 replies

Nov 12, 2010 7:21 AM in response to OneCatFamily

I've only been able to do a mouse move in python.
You can include it in an applescript by a do shell script call


do shell script ""$HOME/Desktop/mousemove.py""

mousemove.py

from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
ourEvent = CGEventCreate(None);
mousemove(720,450);


See: http://www.geekorgy.com/index.php/2010/06/python-mouse-click-and-move-mouse-in-a pple-mac-osx-snow-leopard-10-6-x/
and http://developer.apple.com/mac/library/documentation/Carbon/Reference/QuartzEven tServicesRef/Reference/reference.html

Nov 12, 2010 10:44 AM in response to Tony T1

Actually, I kinda involuntarily Googled myself! I found the old thread I had posted (here: http://discussions.apple.com/thread.jspa?threadID=2033852 ), and after installing Osax in the proper folder, AppleScript finally knew what "mouse" meant...

Now, my script:

move mouse {720, 450} -- {from left, from top}
click mouse

That's it. I saved it as an application, put it in my Login Items list, and sure enough, every time my MBP starts up, my mouse pointer ends up center screen.

Message was edited by: OneCatFamily

Nov 12, 2010 11:43 AM in response to rccharles

You're right, of course! I wasn't exactly in a hurry, but I thought of Googling the issue instead of searching this forum first... That should tell you how strong Google's grip is on some of us... Anyway, I remember how useful your input was on the subject of moving my mouse pointer around on startup. Thanks again, albeit belatedly!

Now I have to solve another mystery/problem, but I think this one is going to be a lot tougher: even after adding two "click mouse" lines under the main "move mouse" line, I've noticed that my pointer is stuck on the Desktop, and won't move when I apply my first stroke on the Trackpad. I have to move my finger around for a second or two before the pointer actually moves.

Paint me perfectionist...

Nov 12, 2010 3:33 PM in response to OneCatFamily

Now I have to solve another mystery/problem, but I think this one is going to be a lot tougher: even after adding two "click mouse" lines under the main "move mouse" line, I've noticed that my pointer is stuck on the Desktop, and won't move when I apply my first stroke on the Trackpad. I have to move my finger around for a second or two before the pointer actually moves.


This is a mystery.

Perhaps there is some snafu with clicking the mouse too quick.

You might try putting in a delay.
This is from the xtool doc.
click mouse v
click mouse [point] : where to do the mouse click
[times integer] : how many times you want to clik the mouse
[delay integer] : delay between two mouse clicks
[using primary button | secondary button | middle button] : which mouse button


Of course, the doc doesn't tell the time factor!

try moving the mouse after the clicks. Maybe that will wake it up.

are you running the program from startup? What happens when you run from script editor. Post code.

Thanks for the fine compliments.

Robert

Nov 13, 2010 1:16 AM in response to rccharles

Actually, I've replaced the original Trackpad driver with another one called Sidetrack (now discontinued), that will let me scroll up and down with only one finger, add hot corners to the Trackpad, etc...

The app developer once told me that the delay in activating the mouse was built-in, because it took the Trackpad some time (usually no more than a second or two) to fully activate. So I guess I can't get anything better than what I already have: at least I don't accidentally trigger the Apple menu by trying to move my mouse pointer to screen center...

FWIW, here's the code, before modification:

move mouse {720, 450} -- {from left, from top}
click mouse
click mouse
move mouse {730, 460} -- {from left, from top}

I'm going to add a two-second delay between the two mouse clicks, just in case. I'll keep you posted. As for the compliment, it's amply deserved, and I'm not the only one on this forum who says so...

Cheers!

Nov 13, 2010 10:59 AM in response to OneCatFamily

The app developer once told me that the delay in activating the mouse was built-in, because it took the Trackpad some time (usually no more than a second or two) to fully activate. So I guess I can't get anything better than what I already have: at least I don't accidentally trigger the Apple menu by trying to move my mouse pointer to screen center...

Well, trying to stress my brain to figure out an impossible solution. 🙂


FWIW, here's the code, before modification:

move mouse {720, 450} -- {from left, from top}
click mouse

delay 0.1
click mouse

delay 0.1
move mouse {730, 460} -- {from left, from top}

I'm going to add a two-second delay between the two mouse clicks, just in case. I'll keep you posted. As for the compliment, it's amply deserved, and I'm not the only one on this forum who says so...

I you are trying to simulate a double click, you need to make the delay closer to what a human would do. Two seconds will most likely turn the double click into two single click.
2

All this is probably not need since you fessed up to it being a driver problem.
Cheers!

Thanks again for your rewarding comments.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

A syntaxic question...

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.