Periodically changing desktop wallpaper using Ruby
Here is small ruby script that picks up a random image from a given folder and sets it as the desktop wallpaper.
1: require 'Win32API'
2:
3: SPI_SETDESKWALLPAPER = 20
4: SPIF_SENDCHANGE = 0x2
5: SOURCE_FOLDER = "C:\\Users\\Gaurav\\Pictures\\Best\\"
6:
7: files = Dir.entries(SOURCE_FOLDER) - [".", ".."]
8: file = files[rand(files.length)]
9:
10: systemParametersInfo = Win32API.new("user32","SystemParametersInfo",["I", "I", "P", "I"],"I")
11: p systemParametersInfo.call(SPI_SETDESKWALLPAPER, 1, SOURCE_FOLDER + file, SPIF_SENDCHANGE)
The constant SOURCE_FOLDER can be changed to point at the folder which contain all your wallpaper and the script then randomly chooses a wallpaper from the collection.
You can also set your task scheduler to run this script automatically after a fixed interval so that your desktop wallpaper keeps changing.
Here is the pastie.
2 Comments to Periodically changing desktop wallpaper using Ruby
Leave a comment
Blogroll
Recent Posts
- Autocompleting ssh, rake, cap command parameters using PowerShell
- Using RubyAmf for creating a CRUD application in Rails
- Multiple ways to open PowerShell in the current Explorer window
- Context sensitive auto-completion using PowerShell, PowerTab and GIT
- Displaying GIT Branch on your PowerShell prompt
XBox Live
Songs I like
Categories
- adobe (4)
- amarok (1)
- C# (2)
- chat application (1)
- crud (2)
- cygwin (1)
- explorer (1)
- expression blend (1)
- flex (4)
- FOSS (2)
- free (1)
- GIT (3)
- ID3 (1)
- java (1)
- microsoft (3)
- mxml (2)
- nokia (1)
- open source (5)
- perl (1)
- powerpoint (2)
- powershell (3)
- rails (3)
- right click (1)
- ruby (9)
- ruby on rails (3)
- security (3)
- silverlight (4)
- smart playlist (1)
- socket (1)
- software (7)
- ssh (1)
- sudo (1)
- tabs (1)
- tomcat (1)
- user interface (6)
- vista (9)
- vista, security (2)
- visual studio 2008 (1)
- win32ole (1)
- windows (13)
- windows media player (1)
- wpf (1)
- xaml (4)
- XP (3)

Nice script….:)
Thanks, Arjun :)