OFW + Applescript?

Hi OF crew…

I’m wondering if anyone has any ideas for how to get an OFW application using applescript to talk to an external application?

I’ve figured out how to get Python and Applescript behaving nicely here…

So I figure getting Applescripts called in C++/OFW has something to do with this…

If anyone has seen this done or has any ideas as to how I might proceed in figuring this out, it would be so much appreciated!

Thanks kindly!


_ note for some reason phpbb isn’t letting me type system with a ( ), perhaps it’s a php issue? so I have added a space below between system and ( )_

hi -

I’m not on a mac, so I have to guess, but I think you could do this with this call:

system (".....");  

we’ve actually implemented it in 0.03 for loading urls in browsers, but you can do all kinds of stuff with it (basically anything from the command line) like play mp3s, run scripts, etc.

I can’t test the mac, but I think this could work (and put your computer to sleep…)

system ("osascript -e 'tell app "Finder" to sleep'");  

take care!!

ps some info on system here:

take care!!

zach- thanks so much for the tip… that was exactly what I needed!

What I’m doing is talking to Google Earth, which has a nice little Applescript dictionary:

I’m now able to send whatever I want to GE, but I’m stuck on getting values back. When I make a request for something in Applescript to return a value, it comes up in the run log (ie. if I do system (“ls -l”) it returns the directory listing in the run log).

So now I’m wondering how to redirect that info back into my OFW application. Would that be something to do with redirecting the output stream? Something with pipes? or an exec () call? :?

Any ideas?

thanks again!


could you do:

system (“ls -l > dirList.txt”);

then read the file dirList.txt ?

on windows … > output.txt at the command line pipes the output into a text file “output.txt”

hope that helps -

take care!

thanks zach!

i know this thread is very old.

but i also had to use apple script with OF and i had to modify the code a bit to this:

std::system(“osascript -e ‘tell app “Finder” to sleep’”);

and this is how i mount an other computer in my osx local network

std::system("osascript -e 'mount volume “afp://” as user name “userName” with password “password” ’ ");


hey, … and how can I ‘insert’ a variable into an appleScript?
I mean, what if I want to convert an int to string to use it inside the script or just like a line for every volume changing values?

systemVolumeValueStr = ofToString(systemVolumeValue); //systemVolumeValue is the changing value
systemAppleScript = "osascript -e \"set Volume " + systemVolumeValueStr + "\"";