Created
June 4, 2011 15:45
-
-
Save peterblazejewicz/1007998 to your computer and use it in GitHub Desktop.
enumerate windowed applications and convert results to custom VO for better handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import mdm.System; | |
import spark.components.Application; | |
public class MyApplication extends Application | |
{ | |
[Bindable] | |
public var txt:String = ""; | |
// | |
public function debug(msg:*):void | |
{ | |
txt += msg.toString()+"\n"; | |
}; | |
// | |
public function initApp():void | |
{ | |
// get vector of active Windows | |
var windows:Vector.<WindowVO> = getWindowList(); | |
for each(var w:WindowVO in windows) | |
{ | |
var handle:uint = w.handle; | |
debug("window with handle: "+handle); | |
debug(w.toString()); | |
} | |
}; | |
// | |
// get list (array) of windowed appliations | |
// and convert them to custom object for better | |
// handling in actionscript | |
// | |
private function getWindowList():Vector.<WindowVO> | |
{ | |
var w:Vector.<WindowVO> = new Vector.<WindowVO>(); | |
// | |
var aWindows:Array = mdm.System.getWindowList(); | |
if(aWindows && aWindows.length > 0) | |
{ | |
var windowInfo:Array = null; | |
for(var i:Number = 0; i < aWindows.length; i++) | |
{ | |
windowInfo = aWindows[i]; | |
if(windowInfo) | |
{ | |
var windowVO:WindowVO = new WindowVO(); | |
if(windowInfo[0]) | |
{ | |
windowVO.title = windowInfo[0] as String; | |
}; | |
if(windowInfo[1]) | |
{ | |
windowVO.handle = parseInt(windowInfo[1]) as uint; | |
}; | |
if(windowInfo[2]) | |
{ | |
windowVO.x = parseInt(windowInfo[2]) as int; | |
}; | |
if(windowInfo[3]) | |
{ | |
windowVO.y = parseInt(windowInfo[3]) as int; | |
}; | |
if(windowInfo[4]) | |
{ | |
windowVO.width = parseInt(windowInfo[4]) as int; | |
}; | |
if(windowInfo[5]) | |
{ | |
windowVO.height = parseInt(windowInfo[5]) as int; | |
}; | |
w.push(windowVO); | |
} | |
} | |
} | |
return w; | |
} | |
} | |
} | |
// | |
[Bindable] | |
class WindowVO extends Object | |
{ | |
public var handle:uint; | |
public var height:int; | |
public var title:String; | |
public var width:int; | |
public var x:int; | |
public var y:int; | |
// | |
public function WindowVO() | |
{ | |
this.title = null; | |
this.handle = 0; | |
this.x = this.y = this.height = this.width = 0; | |
}; | |
public function toString():String | |
{ | |
var returnStr:String = "WindowVO: {handle:"+this.handle+", " + | |
"height: "+this.height+", " + | |
"title: "+this.title+", " + | |
"width: "+this.width+", " + | |
"x: "+this.x+", " + | |
"y: "+this.y+"}"; | |
return returnStr; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment