桌面动态壁纸

By o3o_o3o_o3o at 2022-11-27 • 0人收藏 • 725人看过

我们首先需要把win.ui.glass库中的几段代码改一下:

  1. 把第15行的winform.text改成"玻璃窗口"。

  2. 把第84行改成注释。

然后运行代码:

import win.ui;
/*DSG{{*/
var winform = win.form(text="114514";right=759;bottom=469;acceptfiles=1;bgcolor=15793151;border="none";exmode="toolwindow";min=false)
winform.add(
listview={cls="listview";left=0;top=0;right=428;bottom=459;acceptfiles=1;bgcolor=15793151;mode="icon";z=1}
)
/*}}*/

var VideoForm = win.form(text="视频播放器";right=759;bottom=469;acceptfiles=1;min=false)
VideoForm.add(
ffWindow={cls="custom";text="自定义控件";left=26;top=26;right=693;bottom=427;bgcolor=0;z=1}
)
import win.ui.glass;
win.ui.glass(winform,,1,,0);
import mpvPlayer;
import string;
import fsys.lnk;
import fsys.file;
import fsys.info;
import fsys.table;
import key.hotkey;
import win.ui.explorer;
import win.imageList;
import process;
import soImage;
import console;
import win.ui.menu;
winform.popmenu = win.ui.popmenu(winform);
var mplayer = mpvPlayer(VideoForm.ffWindow);
var lnk = fsys.lnk();
var Img = soImage();
var F={};
var a=0,o=0;
var IfMove = 0;//避免重复setPos导致卡顿
var VideoPath = "C:\Users\Lenovo\Videos\Captures\Phigros痉挛桌面动态壁纸.mp4";//视频地址
VideoForm.show(true);
hotkey = key.hotkey(winform);
var fsystable = fsys.table("/paths.table")
winform.enableDpiScaling();
var add = function(filePath,dontsave){
	var sfi = fsys.info.get(filePath, 0x100/*_SHGFI_ICON*/|0x4000/*_SHGFI_SYSICONINDEX*/)
	var imageList = win.imageList(topointer(sfi.returnValue))
	winform.listview.setImageList( imageList,0/*_LVSIL_NORMAL*/ )
	var spth = io.splitpath(filePath)
	var itemtext = spth.file
	if(!#itemtext) itemtext = spth.drive
	winform.listview.addItem(itemtext,,sfi.iIcon)
	::DestroyIcon(sfi.hIcon)
	imageList.destroy()
	if(dontsave) return ;
	if(!fsystable) fsystable = fsys.table("/paths.table")
	table.push(fsystable,filePath)
	fsystable.save()
}
for(k,v in fsystable){
	if(k = "_gc") continue ;
	if(!io.exist(fsystable[k])){
		fsystable[k] = null
		fsystable.save()
		continue;
	}
	add(fsystable[k],true)
}
winform.listview.onnotify = function(id,code,ptr){
	select(code) {
		case 0xFFFFFFFD/*_NM_DBLCLK*/ {
			var nm = winform.listview.getNotifyMessage(code,ptr)
			if(nm.iItem){
				process.execute(fsystable[nm.iItem])
			}
		}
		case 0xFFFFFFFB/*_NM_RCLICK*/{
			var nm = winform.listview.getNotifyMessage(code,ptr)
			if(nm.iItem){
				winform.popmenu.add("打开",function(){process.execute(fsystable[nm.iItem])})
				winform.popmenu.add('删除',function(){winform.listview.delItem(nm.iItem)})
				winform.popmenu.popup()
				win.delay(100)
				winform.popmenu.remove(1)
				winform.popmenu.remove(1)
			}
		}
	}
}
hotkey.reg(
	"Ctrl","D",
	function(hFocusWnd,...){
		if(win.msgboxTest("你是否要清空?","提示")){
			fsystable = null
        	collectgarbage("collect")
        	string.save("/paths.table","{}" )
        	winform.listview.clear()
		}
	} 
)
winform.wndproc = function(hwnd,message,wParam,lParam){ 
	winform.listview.setPos(0,0,winform.width,winform.height)
}
//winform.listview.orphanWindow()
mplayer.loadFile(VideoPath);
var tmId = VideoForm.setInterval(  
	function(){ 
		event = mplayer.waitEvent(0);
	},1
)
mplayer.onEndFile = function(reason,err){
	mplayer.loadFile(VideoPath);
}
mplayer.setVolume(0);
VideoForm.ffWindow.setPos(0,0,VideoForm.width-18,VideoForm.height-46);
VideoForm.wndproc = function(hwnd,message,wParam,lParam){ 
	if(message==5/*_WM_SIZE*/){
		VideoForm.ffWindow.setPos(0,0,VideoForm.width-18,VideoForm.height-46)
	}
	if(message==3/*_WM_MOVE*/){
		Ifmove=1;
		var x,y,cx,cy,pos = VideoForm.getPos();
		win.setPos(win.find(,"玻璃窗口"),-10,-10,5,5,0/*_HWND_TOP*/)//这行代码是为了不让玻璃窗口碍事,但是这行代码有时会引起程序在关闭窗口时报错
		winform.setPos(x+9,y+38,cx-18,cy-47,0/*_HWND_TOP*/);
	}
	else{
		Ifmove=0;
	}
	if(message==0x233/*_WM_DROPFILES*/){
		var tmpfiletab = win.getDropFile(wParam)
        for(i=1;#tmpfiletab;1){
        	add(tmpfiletab[i])
        }
	}
}
VideoForm.onClose = function(){
	winform.close();
}
winform.onClose = function(hwnd,message,wParam,lParam){
    VideoForm.close();
    fsystable = null
    collectgarbage("collect")
    string.save("/paths.table","{}" )
    winform.listview.clear()
}
winform.show(true);
while(winform.valid==true){
	if(Ifmove==0){
		var x,y,cx,cy,pos = VideoForm.getPos();
		win.setPos(win.find(,"玻璃窗口"),-10,-10,5,5,0/*_HWND_TOP*/)//这行代码是为了不让玻璃窗口碍事,但是这行代码有时会引起程序在关闭窗口时报错
		winform.setPos(x+9,y+38,cx-18,cy-47,0/*_HWND_TOP*/);
		win.delay(100)
	}
}
win.loopMessage();
return winform;

你就可以得到一个像这样的桌面动态壁纸了:

虽然总体效果很好,但是依然有一些问题:

  1. 关闭窗口时可能会有报错的声音,但是没有消息框。

  2. 删除一个文件会发生这样的事情:

桌面壁纸.PNG

(而且同一个文件可以添加多次)

  3. 有的时候listview下方会出现滑动条:

n.PNG

  4. 文字周围有白框。

  5. 我希望文件是竖着排放的,但它是横着的。

  6. 视频播放完之后桌面动态壁纸还会黑一下:

希望有哪位大神能帮我解决这几个问题,谢谢。

2 个回复 | 最后更新于 2022-11-28
2022-11-28   #1

没啥,一开始以为做的是动态屏保,忽略就行了

2022-11-28   #2

登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...