Hello.
I was so tired of having to type stuff like applescript text item’s delimiters from AS Editor, so I thought I could have a script installed in its contextual menu to do that for me. Then I realized that there were no keyboard shortcut to invoke the contextual menu with.
First of all I looked for something that could actually make the click with the control key. I found cliclick by Carsten Blühm which can be downloaded from here.
Then I discovered this post to obtain the mouse position. Regulus solution works wonderful, I just did a minor change in order to get more "integer like coordinates.
[code]#import <AppKit/AppKit.h>
const char origin[] = “http://www.macscripter.net/viewtopic.php?id=33468 Regulus6633” ;
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSPoint mouseLoc = [NSEvent mouseLocation]; //get current mouse position
NSString* locString = [NSString stringWithFormat:@“%.0f, %.0f”, mouseLoc.x,mouseLoc.y];
printf(“%s\n”, [locString UTF8String]);
[pool drain];
return 0;
}[/code]
Then I created this AppleScript, which I have installed as a short key cut with Spark which can be downloaded from here
You will have to change the hardcoded paths to what suits your installation policy.
-- macscripter.net/viewtopic.php?pid=132022#p132022 McUsr
set mouseLoc to (do shell script "/usr/local/opt/MouseLocation")
set {astid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
tell mouseLoc to set {mouseX, mouseY} to {"c" & it's text item 1, it's text item 2}
set mouseY to 1200 - (mouseY as integer)
set mouseLoc to mouseX & " " & mouseY
do shell script "/usr/local/opt/cliclick " & mouseLoc
set AppleScript's text item delimiters to astid
I have assigned it to ctrl opt cmd space Since all other combinations with space is taken. Logically it should really have been put on ctrl space, as you simulate a mouse click with a space, but there may be both quicksilver and spotlight on these places so.
Edit: It appears to be some discrepancies with the mouse position given of the mouse location returned by MouseLocation, so I wonder What I will have to do to adjust the geometry, and if this is possible.
It looks like the Y coordinate is put some 400 pixels below its original position, this may have something to do with the short cut I use, as it changes to crosshairs. I’ll update this when I have investigated it more thoroughly