3

My question is, can you detect if desktop is currently visible in batch scripting(For Vista)?

The Idea is this: I'm writing a script as a prank for my friend. Some of you may heard about Weeping Angels from Doctor Who. I'm trying to make the script so that each time you return to desktop(Like minimizing something you were looking at), wallpaper changes to another image of the angel, creating the illusion that it's moving when you aren't looking, just like in the series.

My idea for this was to detect when the desktop is not visible, and each time it became visible again, the wallpaper would cycle to the next image. Problem is, I have no idea about how to do that.

Aside from the actual question, any tips regarding the effect is appreciated.

Thank you.

4

2 回答 2

1

您可以使用一个名为Sikuli的 Java 库来进行屏幕模式匹配。您所做的就是按照您希望它在触发触发时出现的确切方式截取桌面,然后将单元测试设置为以 5 秒循环运行,始终检查桌面是否以某种方式出现,然后触发壁纸更改. 因此,它将采用 Java/JUnit/Sikuli 和批处理脚本的组合。此外,您必须以某种方式将批处理脚本放入他们的启动程序列表中。

于 2013-07-12T23:03:54.653 回答
1

好吧,这不是您所要求的(不确定是否可以检测到活动窗口)......但它有一些您正在寻找的部分。

基本上,它会每隔 x 不到 5 分钟将您的墙纸更改为文件夹中的墙纸之一,其中 x 是一个随机数。如果您对如何更改它/建议/问题有任何想法,请告诉我。

@echo off 
rem random number of milliseconds (0-5 minutes)
SET /A time=%RANDOM% * (300000 / 32768)
echo waiting %time% ms
PING 1.1.1.1 -n 1 -w %TIME% >NUL
echo done

rem index between 1 and 5
SET /A WALL_INDEX = %random% %% 5 + 1
rem create a folder with many wallpapers in it, and name them 1.png, 2.png, 3.png ... x.png
set WALL="C:\%WALL_INDEX%.png"

rem this is how you change the wallpaper, i stole this from some random site, but I tested it and it seemed to work... usually.
@echo off
reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f 
rem sets the wallpaper to the path in %WALL%
reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d %WALL% /f 
reg delete "hkcu\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperStyle /f
reg add "hkcu\control panel\desktop" /v WallpaperStyle /t REG_SZ /d 0 /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
于 2013-07-12T22:41:07.843 回答