Windows API触发墙纸随机播放

问题描述 投票:6回答:4

有没有办法在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);

我运行代码时没有任何反应,也没有错误。

.net windows winapi windows-7
4个回答
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
投票

OH WAIT,刚刚发现你只想洗牌。 Flot2011's answer是要走的路。

您可以通过以下方式找到当前用户主题的完整路径:

HKCU \软件\微软\的Windows \ CurrentVersion \主题\ CurrentTheme

如果有任何api,它可能不会暴露。如果我是你,我会做的最好的事情是模拟桌面上下文菜单中的“下一个桌面背景”选项。有几种方法可以做到这一点,但我建议你使用GetDesktopWindow api,模拟鼠标右键并发送'n'键。我不完全确定这会产生什么效果,但它应该有效。

另外看看这个:http://www.technixupdate.com/keyboard-shortcut-or-hotkey-to-switch-to-next-windows-7-desktop-wallpaper/


0
投票

注册表项

HKEY_CURRENT_USER \控制面板\个性化\桌面幻灯片

包含值,可以让您控制功能的几个方面。


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开/关指示灯。我不知道为什么。它可能正在改变。

© www.soinside.com 2019 - 2024. All rights reserved.