Adobe AIR to execute program
Asked Answered
I

10

32

I would like to press a button from an Adobe AIR application and execute some installed program. For example, I would have a button named "Start Winamp". When this is pressed it should start Winamp.exe directly...I don't want some command line thing executed, I only want an exe to start. Or...is it the same thing ? Please, let me know if this is possible.

Thank you.

Imperative answered 23/3, 2009 at 2:6 Comment(3)
No offense, but it's been asked.Interrelated
@Le dorfier, Where? I think this is the first asking of this question.Agnosia
Would you consider revising the accepted question now that NativeProcess exists?Horme
T
11

There's no direct way of doing it. Try CommandProxy.

Read the blog post very carefully. You really need to create two different projects: a native OS executable and an AIR app. The native executable fires up your AIR application. The AIR application in turn requests for the executable to process OS-level requests.

Download the source from Google Code and create two projects -- a Visual Studio/Mono for the sample C# exe and another -- for the AIR application. Here is a link that describes how to set up the former.

In your AIR app's main MXML file, you need to do the following:

  • Create a CommandProxy object, add a few event listeners, for connection detection, and Command response and error.

  • Connect to the native exe via a connect call

  • In the event handler for connect, create a new Command e.g. ScreenshotCommand and execute it (via CommandProxy.execute method)

... and that's it!

Hope this helps.

Ternate answered 23/3, 2009 at 8:0 Comment(8)
I really don't know how to make it work. Do you have a working example ? ThnksImperative
CommandProxy? What issues are you facing? I don't have anything ready, but can give it a try later tomorrow.Ternate
I just don't know how to...start the whole thing...what files to use..how to compile properly. I really need an example of something from AIR sending a command like "calc" on Windows. Thnank you!Imperative
Update my post. Let me know if you have more questions.Ternate
This is nice. Now we're talking. Is there any chance that I may press a button from AIR and trigger the OS command ? :-s Thank you !!Imperative
That is exactly what happens.Ternate
+1 for your patient explanation of this thinger... I personally think that Mono/.Net is a terrible choice for a command proxy, but saying "install Ruby and make one with Webrick" is not really a good answer.Agnosia
See the answer below for a new solution, built in to AIR.Callipygian
M
67

With AIR 2.0 you now can:

if(NativeProcess.isSupported)
{
    var file:File = File.desktopDirectory;
    file = file.resolvePath("StyleLookupold.exe");

    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.executable = file;
    var process:NativeProcess = new NativeProcess();

    process.start(nativeProcessStartupInfo);

}

You also need to add this to your descriptor file.

<supportedProfiles>extendedDesktop</supportedProfiles> 
Mares answered 17/12, 2009 at 15:25 Comment(2)
where is the descriptor file? I'm using flash CS5Skittle
@Skittle Good question, In Flash CS5 you will want to go to File>Adobe Air 2 Settings There will be a section called Profiles: with 4 check-boxes. Make sure Extended Desktop is the only one checked.Mares
T
11

There's no direct way of doing it. Try CommandProxy.

Read the blog post very carefully. You really need to create two different projects: a native OS executable and an AIR app. The native executable fires up your AIR application. The AIR application in turn requests for the executable to process OS-level requests.

Download the source from Google Code and create two projects -- a Visual Studio/Mono for the sample C# exe and another -- for the AIR application. Here is a link that describes how to set up the former.

In your AIR app's main MXML file, you need to do the following:

  • Create a CommandProxy object, add a few event listeners, for connection detection, and Command response and error.

  • Connect to the native exe via a connect call

  • In the event handler for connect, create a new Command e.g. ScreenshotCommand and execute it (via CommandProxy.execute method)

... and that's it!

Hope this helps.

Ternate answered 23/3, 2009 at 8:0 Comment(8)
I really don't know how to make it work. Do you have a working example ? ThnksImperative
CommandProxy? What issues are you facing? I don't have anything ready, but can give it a try later tomorrow.Ternate
I just don't know how to...start the whole thing...what files to use..how to compile properly. I really need an example of something from AIR sending a command like "calc" on Windows. Thnank you!Imperative
Update my post. Let me know if you have more questions.Ternate
This is nice. Now we're talking. Is there any chance that I may press a button from AIR and trigger the OS command ? :-s Thank you !!Imperative
That is exactly what happens.Ternate
+1 for your patient explanation of this thinger... I personally think that Mono/.Net is a terrible choice for a command proxy, but saying "install Ruby and make one with Webrick" is not really a good answer.Agnosia
See the answer below for a new solution, built in to AIR.Callipygian
A
4

The answer comes in two parts. One, if you really MUST run a .exe file, the only way to go is to use a command proxy. Personally, using one in .Net/Mono is a bit overblown. I don't know Mono, but asking your users to install .Net and AIR would scare just about all of them away. Plus, if I was going to ask users to install Mono, why not just write the UI in Mono and be done with it...?

You could write a simple command proxy in Ruby which really would be cross-platform and low hassle in about 5 minutes (I just did it, if you want the code comment me here and I'll post it). If you want control of the process after it's launched, it's a more serious endeavor. For distribution, etc., I believe that Ruby would be easier.

On the other hand, check this idea out. Jeff suggests using a URL request from AIR. Basically, if your browser would interpret it correctly, you're ready to go. The code looks like this

var request : URLRequest = new URLRequest('C:\\playlists\\test.m3u');

I think that, with a bit of creativity (with Mime types, particularly), this second solution might even work for Winamp (e.g.., a playlist or something).

Good luck and thank you for the question, which is probably a dupe but Google only found this one so you've won :)

Agnosia answered 20/7, 2009 at 10:14 Comment(0)
V
3

I think FluorineFx does what you want: http://aperture.fluorinefx.com/?p=5

Valeryvalerye answered 5/8, 2009 at 13:56 Comment(1)
FlourineFX is a web messaging gateway and has nothing to with native application launch in Air...Marianamariand
H
3

AIR 2.0 will have this capability.

It's expected to come out in beta by year end (2009) and ship first half of 2010.

http://blogs.adobe.com/air/2009/10/previewing_adobe_air_2_at_adob.html

Native process API Beginning with AIR 2, developers will have access to a native process API that will enable applications to invoke and communicate with native applications on the local machine. In order to preserve the cross platform nature of the .air file format, applications that take advantage of the native process API must be deployed as native installers such as .exe and .dmg. The AIR runtime SDK will include support for generating basic native installers.

Hypochondrium answered 9/11, 2009 at 23:10 Comment(0)
I
1

See this blog post: Run an exe file from AIR

Short summary:

"If you really need to run external exe files, and there is no other way of solving your problem, then you will make sure that the user runs that another software before launching the AIR application."

Ishtar answered 23/3, 2009 at 2:23 Comment(0)
M
1

Right now, there's no way to do this natively with AIR. There are some options, though:

  • Shu
  • Red5 running on localhost
  • Create a service that runs on the user's machine and connect to it using sockets.
Morphia answered 23/3, 2009 at 2:26 Comment(0)
M
1

Another way of doing this is launching simple webserver on local machine (in background), and call it's methods using HTTPService.

The background webserver could be for example in python: http://fragments.turtlemeat.com/pythonwebserver.php

And it can launch executables and provide functionality that AIR cannot.

This keeps Flex code clean because it only implements REST interface and python (or other language) the rest of work. You can also benefit from using python as a interface to sqlite database or you can launch whole django as a webserver.

The only drawback is that the server must be already running on localhost .. and listening to some port (ie. 81). you can probably do this by launching the server on start of system.

It's not the best way but in some cases it could help your project as it did for me.

Maxon answered 10/2, 2010 at 9:22 Comment(0)
F
0

in mac os x, if you want to launch an .app file, then you have to write the following for the file path. (Assume that the name of the app is xxx)

if(NativeProcess.isSupported)
{
    //not correct
    //file = file.resolvePath("/Applications/xxx.app");

    //correct
    file = file.resolvePath("/Applications/xxx.app/Contents/MacOS/xxx");

    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.executable = file;
    var process:NativeProcess = new NativeProcess();

    process.start(nativeProcessStartupInfo);

}
Foeticide answered 27/9, 2013 at 13:45 Comment(0)
G
0

Or simple my website create custom installer to new application read more

http://board.flashkit.com/board/showthread.php?834579-Embed-exe-file-from-swf-to-write-to-local-directory

Bonus Tip: We recommend you use Enigma Virtual Box because it is free and it is very good for Application Virtualization or Exe-Packer like BoxedApp Packer but it costs very much than Enigma Virtual Box Thanks!

Gesticulation answered 6/10, 2015 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.