有没有办法在Windows壁纸幻灯片中触发随机播放? 我可以使用.net
编辑:所以我正在尝试使用IActiveDesktop界面,我是从here获得的,我试图像这样使用它:
public static IActiveDesktop GetActiveDesktop()
{
Type typeActiveDesktop = Type.GetTypeFromCLSID(new Guid("{75048700-EF1F-11D0-9888-006097DEACF9}"));
return (IActiveDesktop) Activator.CreateInstance(typeActiveDesktop);
}
然后像这样调用它:
IActiveDesktop dt = GetActiveDesktop();
dt.ApplyChanges(AD_APPLY.ALL | AD_APPLY.FORCE | AD_APPLY.BUFFERED_REFRESH);
运行代码时没有任何反应,也没有错误。
答案 0 :(得分:3)
尝试以下方法:
您的主题位于C:\ Users \ USERNAME \ AppData \ Local \ Microsoft \ Windows \ Themes \ .theme
打开.theme文件并更新[幻灯片放映]部分中的随机播放标记:
[Slideshow]
Shuffle=1
然后使用IActiveDesktop接口重新加载主题,使用以下参数调用ApplyChange:
AD_APPLY_ALL | AD_APPLY_FORCE | AD_APPLY_BUFFERED_REFRESH
答案 1 :(得分:1)
OH WAIT,刚发现你只想洗牌。 Flot2011's answer是要走的路。
您可以通过以下方式找到当前用户主题的完整路径:
HKCU \软件\微软\的Windows \ CurrentVersion \主题\ CurrentTheme
如果有任何api,它可能不会暴露。如果我是你,我会做的最好的事情是模拟桌面上下文菜单中的“下一个桌面背景”选项。有几种方法可以做到这一点,但我建议您使用 GetDesktopWindow
api,模拟鼠标右键并发送'n'键。我不完全确定这会产生什么影响,但它应该有效。
答案 2 :(得分:0)
注册表项
HKEY_CURRENT_USER \控制面板\个性化\桌面幻灯片
包含的值可以让您控制该功能的多个方面。
答案 3 :(得分:0)
如果所有人都需要一个快速,hacky脚本,这似乎对powershell有用,如果你不介意几秒延迟并且窗口关闭然后再备份:
Function Next-Slide() {
$shellApp = New-Object -ComObject Shell.Application
$wScript = New-Object -ComObject WScript.Shell
# stack.push(...)
# I guess this is assuming we aren't on the desktop already...
$shellApp.ToggleDesktop();
# This doesn't seem to be needed...
#$desktopLoc = $wScript.SpecialFolders('Desktop');
#$wScript.AppActivate($desktopLoc);
#Give time to get to the desktop
sleep 1;
# Hack to make sure something is selected on the desktop
# if there is something to select.
$wScript.SendKeys('{RIGHT}');
$wScript.SendKeys('{UP}');
$wScript.SendKeys('{LEFT}');
$wScript.SendKeys('{DOWN}');
# Now undo the selection so that we get the desktop context
# menu, not the icon one. This toggles selection on desktop.
$wScript.SendKeys("^ ");
# Open a context menu and select the option to see the next slide
$wScript.SendKeys("+{F10}");
$wScript.SendKeys("n");
$wScript.SendKeys("~"); #This is ENTER
# Give the key commands time to be read
sleep 1;
# stack.pop()
$shellApp.ToggleDesktop();
}
警告:当我运行时,我看到屏幕右下角会弹出numlock开/关指示灯。我不知道为什么。它可能正在改变。