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…
http://www.macdevcenter.com/pub/a/mac/2007/05/08/using-python-and-applescript-to-get-the-most-out-of-your-mac.html?page=1

So I figure getting Applescripts called in C++/OFW has something to do with this…
http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/osascript.1.html

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!

-C

_ 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!!
zach

ps some info on system here:
http://www.cplusplus.com/reference/clib-…-ystem.html

take care!!
zach

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:
http://www.ogleearth.com/2006/09/google-earth-fo-6.html

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!

-C

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!
zach

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://10.0.1.239/hardDriveName” as user name “userName” with password “password” ’ ");

s.

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 + "\"";