GIF录制过程中怎么录制鼠标和鼠标样式?
By
admin
at 2017-11-22 • 0人收藏 • 1236人看过
如题:
感谢aardio群里的Kio1 ,提供测试代码:
import console; import soImage; console.open() var gifFile = soImage.gifFile("/test.gif"); class CURSORINFO{ INT cbSize = 20; INT flags; pointer hCursor; struct ptScreenPos = {int x;int y}; } var img = soImage(); var img2 = soImage() for(i=1;20;1){ img.capture(); //截屏 var info = CURSORINFO() //获取鼠标信息 ::User32.GetCursorInfo(info) //取得鼠标样式 img2.fromIcon(info.hCursor) //混合图片,注意最后一个参数 img.mix(img2,info.ptScreenPos.x,info.ptScreenPos.y,6/*_MIX_SCREEN*/); gifFile.write(img ); //写入GIF文件 console.log("已录制",gifFile.count() ); sleep(10); } gifFile.close(); console.pause();
mainForm.开启.oncommand = function(id,event){ thread.set("startOrend",true); gifThr = thread.create( function( mainForm,caphwnd,gifPath ){ import soImage; import win.ui ; import com; import console import mouse class CURSORINFO{ INT cbSize = 20; INT flags; pointer hCursor; struct ptScreenPos = {int x;int y}; } var mouseCursor = soImage(); var img = soImage(); var gifFile = soImage.gifFile(gifPath); while(thread.get("startOrend")){ var info = CURSORINFO() //获取鼠标信息 ::User32.GetCursorInfo(info) //取得鼠标样式 mouseCursor.fromIcon(info.hCursor) var x,y,cx,cy = mainForm.picturebox.getPos();//坐标 x , y 宽 高 var xx,yy = win.toScreen(mainForm.hwnd,x,y); var pic = com.picture.snap(caphwnd,xx,yy,cx,cy); img.fromBitmap(pic.Handle); //混合图片,注意最后一个参数 var mx,my = win.toClient(mainForm.picturebox.hwnd,info.ptScreenPos.x,info.ptScreenPos.y); img.mix(mouseCursor,mx,my,0xA/*_MIX_XOR*/); gifFile.write(img,false,,,3); //写入GIF文件 sleep(50);//50HZ } gifFile.close();//释放录制 // console.log("录制完毕") },mainForm,win.getDesktop(),gifPath ) owner.disabled = true; mainForm.停止.disabled = false; mainForm.暂停.disabled = false; mainForm.继续.disabled = true; }
登录后方可回帖