Created
February 11, 2014 14:17
-
-
Save stevelippert/8935608 to your computer and use it in GitHub Desktop.
Bing Wallpaper Downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use URI; | |
| use LWP::Simple; | |
| use File::Spec; | |
| use File::Copy; | |
| use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>1 ); | |
| use Data::Dumper; | |
| use 5.14.0; | |
| my $debug = 0; | |
| my $content = get("http://www.bing.com"); | |
| die "Error contacting Bing" unless defined $content; | |
| $content =~ /g_img=\{url:'(.+?)'/; | |
| my $image = $1; | |
| $debug && say "Image: " . $image; | |
| my $uri = URI->new( $image ); | |
| $uri->scheme( 'http' ); | |
| $uri->host( 'www.bing.com' ); | |
| $debug && say $uri; | |
| my( undef, undef, $filename) = File::Spec->splitpath( $image ); | |
| my $ultimateTarget = File::Spec->catfile('C:', 'Users', 'steve.lippert', 'AppData', 'Roaming', 'Microsoft', 'Windows', 'Themes', 'TranscodedWallpaper.jpg'); | |
| my $target = File::Spec->catfile( 'C:', 'Users', 'steve.lippert', 'Dropbox', 'Photos', 'Wallpapers', 'Bing', $filename ); | |
| my $imageDownload = getstore($uri, $target); | |
| copy($target,$ultimateTarget); | |
| my $desktopKey = $Registry->{"HKEY_CURRENT_USER/Control Panel/Desktop//Wallpaper"}; | |
| my $desktop = $desktopKey->[0]; | |
| $Registry->{"HKEY_CURRENT_USER/Control Panel/Desktop//Wallpaper"} = $desktop; | |
| system "RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment