flex4.6做的 一个系统操作小工具

转载请注明:cls站点http://www.chenlinsheng.com

 

实现的功能:
定时关机,待机,注销,注销,修改系统时间
取消关机
窗口半透明拖动
最小化到托盘
托盘右键还原,退出….

 

获取系统权限:

private function runProcess():void
			{
				if (!NativeProcess.isSupported)
				{
					Alert.show("当前系统不支持");
					return;
				}
				
				try
				{
					var file:File;
					// Use default paths for ping... modify if your system does not use the default path
					if (Capabilities.os.toLowerCase().indexOf("win") > -1)
					{
						file = new File("c://windows//system32//cmd.exe");
					}
					else if (Capabilities.os.toLowerCase().indexOf("mac") > -1)
					{
						//
					}
					else if (Capabilities.os.toLowerCase().indexOf("linux") > -1)
					{
						//
					}
					
					var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
					nativeProcessStartupInfo.executable = file;					
					process = new NativeProcess();
					process.start(nativeProcessStartupInfo);
					
					process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, stdoutHandler);
					process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA,errorHandler);
				}
				catch (e:Error)
				{
					Alert.show(e.message, "Error");
				}
			}
			private function stdoutHandler(event:ProgressEvent):void
			{
				var process:NativeProcess = event.target as NativeProcess;
				var data:String = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
			}
			
			private function errorHandler(event:ProgressEvent):void
			{
				var process:NativeProcess = event.target as NativeProcess;
				var data:String = process.standardError.readUTFBytes(process.standardError.bytesAvailable);
			}

 

 如果对这个有兴趣的话,可以到我的个人网站有源文件的下载地址

你可能感兴趣的:(Flex,AIR,as3,系统操作,actionscript)