远程桌面显示

admin2021-12-29  2.4K+

// @Author  : popy32
// @Contact : 74o5o27o8#qq.com
// @File    : RemoteDesktopServer.aardio
// @Comment : 

import console;
import win.ui;
/*DSG{{*/
var winform = win.form(text="远程桌面服务器端";right=486;bottom=348;border="thin";edge=1;parent=...)
winform.add(
button={cls="button";text="开始";left=56;top=272;right=179;bottom=320;db=1;z=1};
button2={cls="button";text="停止";left=312;top=272;right=435;bottom=320;db=1;z=2}
)
/*}}*/

import wsock.tcp.simpleHttpServer; 
import inet.http; 
import inet.url;
import com.picture;
import fsys.stream;
//import crypt.bin;
import process;

$serverMain = wsock.tcp.simpleHttpServer.mainThread( 
	function(response,request,session){ 
		
		import com.picture;
		import fsys.stream;
		//import crypt.bin;
		import gdip;
		import soImage;
		
		if(request.path=="/desktop"){ 
			
			/*
			com.picture.snap 有时会黑屏 原因不清楚
            var picture = com.picture.snap()
            var bmp = gdip.bitmap(picture);
			var stream = fsys.stream();
            */
			
			//图像写到内存流
			//var stream = fsys.stream();
			//bmp.saveToStream(stream, "*.jpg", 80);
			//var jpg = stream.readAll()
            //var bmpb64 = crypt.bin.encodeBase64( stream.readAll() );
			
			//response.contentType = "text/plain";
			//response.write(bmpb64);
			
			var img = soImage();
            img.capture();
            var jpg = img.getBytes("*.jpg");
			
			response.contentType = "image/jpeg";
			response.write( jpg );
		} 
		
		if(request.path=="/mouse"){
		    // 鼠标的处理逻辑
		}
		
		if(request.path=="/keyboard"){
		    // 键盘的处理逻辑
		}
	} 	
);

$serverMain.threadNum = 2; 

runStatus = false;

winform.button.oncommand = function(id,event){
	if(runStatus == true) {
	    return;
	}
	var ok,err = $serverMain.start( "0.0.0.0", 9133 );
	if(!ok){ 
		win.msgboxErr("启动失败");
		return;
	} else {
		runStatus = true;
	    win.msgbox("启动成功");
	    process.explore("http://127.0.0.1:9133/desktop");
	}
}

winform.button2.oncommand = function(id,event){
	if(runStatus == false) {
	    return;
	}
	
	$serverMain.stop();
	runStatus = false;
}

winform.onClose = function(hwnd,message,wParam,lParam){
    runStatus = false;
    winform.button2.oncommand();
}


winform.show() 
win.loopMessage();
转载请注明原文地址: https://aardio.net/read-281.html
最新回复(0)
aardio问答
aardio编程语言