views:

363

answers:

3

Hello, just a quickie (or maybe not:] ):

Is it possible to get somehow list of running applications/processes and, while running in background, check which process is active?

Additionally - if somehow, the answer was yes, is it possible to react for change of active window / application react just as if it was Event, or bind to it custom event (e.g. Event.SystemActiveAppChange)?

Thank you for answers as well as pointers.

EDIT: Due to probable missunderstanding, I mean local applications - on your win/mac/linux machine - I would like to (in process of learning of language) track what apps I use the most, make a little graph maybe?

So, the point is: in AIR app, developed in FLEX, I would like to get/list all running applications/processes, as well as which one is active (on user's PC/Mac/Linux)

+1  A: 

You can use newconnection class to ping back and forth while applications are alive : http://www.adobe.com/livedocs/flex/3/langref/flash/net/NetConnection.html

  1. the main app can send netConnection.send(mainConnection,"sendMessageBack") running on timer que
  2. the child app will trigger in the sendMessageBack function netConnection.send(childConnection,"setStatusOk") .
  3. the main app can check ( on same timer que as 1 ) if setStatusOk was called if not shoot Event.SystemActiveAppChange
Eran
Hmmm, thank you, but there's is possible misunderstanding here :] Please, read edit.
Adam Kiss
+1  A: 

Unfortunately this isn't possible, since AIR can access neither process information nor system performance metrics.

Your only hope would be to create another service in .NET or Objective C (as in, not cross platform - assuming that is a requirement) that can provide the process information to your AIR app via a local NetConnection. I'm not sure about Java, but you might be able to get away with Mono.

Richard Szalay
Could you think of any `simple` solution? :D Probably not...
Adam Kiss
Unfortunately, no. If you're on Windows, you can try to get a .NET service up and running to provide the data to your AIR app. The .NET API you need is Process.GetProcesses() - http://msdn.microsoft.com/en-us/library/1f3ys1f9.aspx. Not sure about OSX/Linux, sorry!
Richard Szalay
Well this seems like another idea cut down - I'm in no mood learn another language right now :D
Adam Kiss
+1  A: 

Hey,

this is exactly the same thing I`m investigating!

While I think there are still no built in APIs to do this, with the new AIR 2.0 you can use NativeProcess, so you can scrape the output of command line tools like top or ps on OSX. I actually have a proof of concept up and running which makes it possible for an AIR application to monitor its CPU usage inside the app using ActionScript, although it's a bit slow, couldn't go below 1.5 sec sample frequency.

But don't want to digress too much, I couldn't yet find out what command line tools could be used to get the active application / window, but I just opened a question to find out, which might be the workaround for your question: Which command line tools can I use to get the currently active application / window on each platform?

dain
Great news then :) I will follow up:)
Adam Kiss