[Flashcoders] Calling applescript from Adobe AIR
Hi All, Is there any way by which I can call Applescript from Adobe air? Any help or suggestion on this regard would be great. Regards Sumeet Kumar ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling applescript from Adobe AIR
Hi, Not sure, but if AppleScript files can be executable like shell scripts in Linux, then you can call them from Air desktop using the Native Process API. If you download Air Launchpad and get it to generate the source code example for the Native Process API, you can then hack it to try your code, see my example below which starts an SSH session using putty on Windows - did not try on Mac as I don't have one, but should also be able to make it work on Linux. Glen protected function runProcess():void { var file:File = new File(); try { if (Capabilities.os.toLowerCase().indexOf(win) -1) { file = new File(C:\\Documents and Settings\\Will\\Desktop\\Downloads\\Progs\\putty.exe); } else if (Capabilities.os.toLowerCase().indexOf(mac) -1) { file = new File(/sbin/ssh); if (file == null) file = new File(/bin/ssh); else if (file == null) file = new File(/usr/bin/ssh); } else if (Capabilities.os.toLowerCase().indexOf(linux) -1) { file = new File(/sbin/ssh); if (file == null) file = new File(/bin/ssh); else if (file == null) file = new File(/usr/bin/ssh); } var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.executable = file; var args:Vector.String = new Vector.String; args.push(-P); args.push(50030) args.push(-l); args.push(username); args.push(-pw); args.push(password); args.push(-L); args.push(2080:localhost:2080); args.push(-L); args.push(7766:localhost:7766); args.push(192.168.0.19); nativeProcessStartupInfo.arguments = args; process = new NativeProcess(); process.start(nativeProcessStartupInfo); process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdout); process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onError); } catch (e:Error) { Alert.show(e.message, Error); } } On 20/07/2011 07:42, Sumeet Kumar wrote: Hi All, Is there any way by which I can call Applescript from Adobe air? Any help or suggestion on this regard would be great. Regards Sumeet Kumar ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Calling applescript from Adobe AIR
Thanks a lot for the help Glen, One more question, I am using flex builder 3 and flex SDK 3.2.0, But I am not able to find the nativeprocess API in this configuration. I tried overlaying adobe air 2.0 on flex SDK 3.2.0 as mentioned in some forums but still it does not work. Do I need flash builder 4 to make the nativeprocess API work. Thanks Again, Sumeet Kumar -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Wednesday, July 20, 2011 2:35 PM To: Flash Coders List Subject: Re: [Flashcoders] Calling applescript from Adobe AIR Hi, Not sure, but if AppleScript files can be executable like shell scripts in Linux, then you can call them from Air desktop using the Native Process API. If you download Air Launchpad and get it to generate the source code example for the Native Process API, you can then hack it to try your code, see my example below which starts an SSH session using putty on Windows - did not try on Mac as I don't have one, but should also be able to make it work on Linux. Glen protected function runProcess():void { var file:File = new File(); try { if (Capabilities.os.toLowerCase().indexOf(win) -1) { file = new File(C:\\Documents and Settings\\Will\\Desktop\\Downloads\\Progs\\putty.exe); } else if (Capabilities.os.toLowerCase().indexOf(mac) -1) { file = new File(/sbin/ssh); if (file == null) file = new File(/bin/ssh); else if (file == null) file = new File(/usr/bin/ssh); } else if (Capabilities.os.toLowerCase().indexOf(linux) -1) { file = new File(/sbin/ssh); if (file == null) file = new File(/bin/ssh); else if (file == null) file = new File(/usr/bin/ssh); } var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.executable = file; var args:Vector.String = new Vector.String; args.push(-P); args.push(50030) args.push(-l); args.push(username); args.push(-pw); args.push(password); args.push(-L); args.push(2080:localhost:2080); args.push(-L); args.push(7766:localhost:7766); args.push(192.168.0.19); nativeProcessStartupInfo.arguments = args; process = new NativeProcess(); process.start(nativeProcessStartupInfo); process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdout); process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onError); } catch (e:Error) { Alert.show(e.message, Error); } } On 20/07/2011 07:42, Sumeet Kumar wrote: Hi All, Is there any way by which I can call Applescript from Adobe air? Any help or suggestion on this regard would be great. Regards Sumeet Kumar ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling applescript from Adobe AIR
Hi, I am using FlashDevelop with flex_sdk_4.1.0.16076 and Air 2.5 SDK - can you change the Flex SDK your Flex Builder uses? I think the Native Process API requires AIR 2.0 at least. You also have to setup your #AppName-app.xml file to have the extendedDesktop permissions: supportedProfilesextendedDesktop desktop/supportedProfiles I think Launchpad will automatically generate the correct file for you. Make sure that application.xml has the correct AIR version: application xmlns=http://ns.adobe.com/air/application/2.0; Hope this helps - I am not sure about Flex vs Flashbuilder and SDK versions. Glen On 20/07/2011 10:38, Sumeet Kumar wrote: Thanks a lot for the help Glen, One more question, I am using flex builder 3 and flex SDK 3.2.0, But I am not able to find the nativeprocess API in this configuration. I tried overlaying adobe air 2.0 on flex SDK 3.2.0 as mentioned in some forums but still it does not work. Do I need flash builder 4 to make the nativeprocess API work. Thanks Again, Sumeet Kumar -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Wednesday, July 20, 2011 2:35 PM To: Flash Coders List Subject: Re: [Flashcoders] Calling applescript from Adobe AIR Hi, Not sure, but if AppleScript files can be executable like shell scripts in Linux, then you can call them from Air desktop using the Native Process API. If you download Air Launchpad and get it to generate the source code example for the Native Process API, you can then hack it to try your code, see my example below which starts an SSH session using putty on Windows - did not try on Mac as I don't have one, but should also be able to make it work on Linux. Glen protected function runProcess():void { var file:File = new File(); try { if (Capabilities.os.toLowerCase().indexOf(win) -1) { file = new File(C:\\Documents and Settings\\Will\\Desktop\\Downloads\\Progs\\putty.exe); } else if (Capabilities.os.toLowerCase().indexOf(mac) -1) { file = new File(/sbin/ssh); if (file == null) file = new File(/bin/ssh); else if (file == null) file = new File(/usr/bin/ssh); } else if (Capabilities.os.toLowerCase().indexOf(linux) -1) { file = new File(/sbin/ssh); if (file == null) file = new File(/bin/ssh); else if (file == null) file = new File(/usr/bin/ssh); } var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.executable = file; var args:Vector.String = new Vector.String; args.push(-P); args.push(50030) args.push(-l); args.push(username); args.push(-pw); args.push(password); args.push(-L); args.push(2080:localhost:2080); args.push(-L); args.push(7766:localhost:7766); args.push(192.168.0.19); nativeProcessStartupInfo.arguments = args; process = new NativeProcess(); process.start(nativeProcessStartupInfo); process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdout); process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onError); } catch (e:Error) { Alert.show(e.message, Error); } } On 20/07/2011 07:42, Sumeet Kumar wrote: Hi All, Is there any way by which I can call Applescript from Adobe air? Any help or suggestion on this regard would be great. Regards Sumeet Kumar ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com