Quantcast

Maximum PC

It is currently Fri Apr 18, 2014 7:48 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 19 posts ] 
Author Message
 Post subject: Change desktop Background
PostPosted: Fri Jul 17, 2009 8:26 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
So, i'm looking for a quick and dirty way to change my desktop background at work. I have enough rights to do so, but I want to automatically get a new desktop background every so often. I use Display Fusion at home to do this and it’s PERFECT. I only have one screen here, and I was wondering if I could use a batch file or something else similar to randomly switch my desktop.

I was thinking, isn't there a pic somewhere under "system" where I can use a batch file to copy another picture to and over right it to get a new desktop? Am I anywhere close to being where I need to be?

Thanks!


Top
  Profile  
 
 Post subject:
PostPosted: Fri Jul 17, 2009 8:46 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
http://www.anappaday.com/downloads/2006 ... paper.html


Top
  Profile  
 
 Post subject:
PostPosted: Fri Jul 17, 2009 9:44 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
That is a sweet program and ill file it away for later use,

but i had forgot to mention that i have a giant folder of images. I'd like to randomly choose from a directory.

Thanks though!


Top
  Profile  
 
 Post subject:
PostPosted: Fri Jul 17, 2009 10:44 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Wed Nov 01, 2006 11:44 am
Posts: 2680
Location: Up in you attic...Wi-Fi is delicious
Couldn't you just get a big batch of wallpapers, and randomly right-click and image "Set as Desktop Background?"


Top
  Profile  
 
 Post subject:
PostPosted: Fri Jul 17, 2009 11:31 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
yeah, thats probably what im going to have to do, but im lazy and i like automatic stuff :P


Top
  Profile  
 
 Post subject:
PostPosted: Sun Jul 19, 2009 1:59 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Use the source code from that application I posted to get the images from a directory and not Google. It isn't too hard and you will learn something in the process.

I didn't mean for that application to be the answer to your question, so much as a spring board :P


Top
  Profile  
 
 Post subject:
PostPosted: Sun Jul 19, 2009 4:54 pm 
Team Member [Top 500]*
Team Member [Top 500]*
User avatar

Joined: Thu Jun 24, 2004 2:22 pm
Posts: 8712
Location: Cleveland, Ohio
Quote:
I was thinking, isn't there a pic somewhere under "system" where I can use a batch file to copy another picture to and over right it to get a new desktop? Am I anywhere close to being where I need to be?


Yes, you can do it with a batch file or a script. You are changing a registry setting. Vista and XP are the same at this point:

HKEY_CURRENT_USER\Control Panel\Desktop

Note the file path for Wallpaper in the right pane after you hilight Desktop. That tells you where the image is on the system.

Vista and XP seem to differ after that. I have been messing with a script (VBScript) to randomly select 1 of 6 images and make the change which happen on the next boot but haven't gotten quite there yet, first I had to fight UAC when enabled.

Anyway it is set from the registry as well as TileWallpaper and WallPaperStyle.

What OS are you working on doing this to?

Ron


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 11:06 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
Ron, im using XP Pro x86 SP3. I recently got a kickass new computer at work, Core2duo E8600 3.33ghz, 4gbs DDR800 (i assume its DDR800) and a Radeon 3470. Pretty big jump from my Xeon with RDRAM, i tell you that...

CrashTECH, Source code eh? i know what that is, but no idea how to get there. I know enough about dos, but i know nothing about any other programming language(well, a tad of HTML). I'm good at learning though... What software do i need to crack open that app and see the source code?

Thanks for the responses folks!


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 11:11 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Visual Studio Express (C#).

The guy released the source code tall all those applications so you don't have to "crack it open".


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 11:31 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
CrashTECH wrote:
Visual Studio Express (C#).

The guy released the source code tall all those applications so you don't have to "crack it open".


Well, that makes life easy, now dosn't it? I'll try that one out tonight at home! i doubt my company will like me installing C# on my computer...


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 11:55 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Yup yup.

Or you could wait a while... I have been thinking of writing a display fusion clone. :)


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 12:03 pm 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
CrashTECH wrote:
Yup yup.

Or you could wait a while... I have been thinking of writing a display fusion clone. :)


That sounds good! I'll probably take this opportunity to learn a little bit about another language. DOS is great, but very limited. i think that the next step will be VB... Let me know when you get that done! if you need a beta tester, you know where to find me!


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 1:10 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Does isn't a language btw.

C# man. That is what that source code is in. I think there is more C# than VB out and about honestly.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jul 20, 2009 4:30 pm 
Team Member [Top 500]*
Team Member [Top 500]*
User avatar

Joined: Thu Jun 24, 2004 2:22 pm
Posts: 8712
Location: Cleveland, Ohio
I like Crash's ideas on this and will likely play with that a little. I was going to give just VB a shot. Hey, I am not a programmer type. :lol: However...

Based on your earlier post and reference to a Batch File to change wallpaper automatically I came up with a simple script written in VBScript simply because a .bat file isn’t my forte and a .vbs file works for me. The script is a modified version of a script from Microsoft. Personally I like using scripts for all sorts of things. Before we worry about the script itself we should focus on the wallpaper settings Windows XP uses.

Since wallpaper is a user function and since any machine can have several users each liking different wallpaper the wallpaper settings are in the registry under HKEY_CURRENT_USER\Desktop\Wallpaper which really makes sense. If you navigate the registry to HKEY_CURRENT_USER\Desktop and look in the Right Pane you will see wallpaper as well as the path to the wallpaper Windows is currently using. The default for the standard wallpaper that comes with Windows XP is C:\Windows\Web\Wallpaper\somedamnpaper.bmp on my XP machine. However, wallpaper can be anywhere as long as the registry can point to it and it is where the registry points.

So here is what I did to simplify things. I took 6 pictures and named them Wallpaper1, Wallpaper2, … Wallpaper6. Notice my very complex naming conventions. I saved the images as .bmp (Bitmap) files to the folder C:\Windows\Web\Wallpaper along with the existing wallpaper in there. I could have placed them anywhere as long as the code in the script pointed to them. I could have saved them as .jpg and it would still work or I could have just used existing images in the folder in my script. I am sure you get the idea and if not just ask.

Something else you will notice are a few other wallpaper related things. TileWallpaper and WallpaperStyle are in there with REG_SZ values also. TileWallpaper value = 0 centers the image on the screen and 1 tiles it across the screen (depends on the actual image size). WallpaperStyle = 0 will just center the image and = 2 will Stretch to Fit the image. All of that could be added to the code for a specific image selected at random but I didn’t bother with those settings.

The code itself just runs and randomly selects 1 of 6. The code can easily be modified changing the intHighNumber and adding more Case Statements. I quit at 6. Looking at the code I am sure you will see what is going on and get the idea.

So what to do? Copy and paste the code into Note Pad and name the file something like Wallpaper Changer.vbs the important thing here is the .vbs extension or when you save the file you will have saved it as a .txt file and a plain text file won’t do anything. Save the file to somewhere like the root of your C:\ drive. Double clicking the file will run it but we want it to run automatically.

Next we have a small problem to overcome. I used the XP task scheduler and scheduled the task to run at Logon. Just make sure that you set the task scheduler to run correctly and to run the file at logon for yourself. The script will not change the wallpaper in real time or on the fly. However each time the user logs off the next logon should have new wallpaper. Screw with the scheduler and edit the code for your needs and system. Just make sure you get the code correct as the registry is very funny about upper & lower case for example. Also I would be remiss if I didn’t tell you to backup the registry before doing or clicking anything. There are other ways to do this in VBScript but this one works.

Code:
'Basic script to change the wallpaper in Windows XP
'Define the constant Name & set a value to it.

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

'Randomly select 1 of 6 Wallpapers using 2 variables as high and low.

intLowNumber = 1
intHighNumber = 6

Randomize

intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)

'We have a number between 1 and 6. We use select case to assign the RND #
'to a wallpaper.

Select Case intNumber
    Case 1
        strValue = "C:\Windows\Web\Wallpaper\Wallpaper1.bmp"
    Case 2
        strValue = "C:\Windows\Web\Wallpaper\Wallpaper2.bmp"
    Case 3
        strValue = "C:\Windows\Web\Wallpaper\Wallpaper3.bmp"
    Case 4
        strValue = "C:\Windows\Web\Wallpaper\Wallpaper4.bmp"
    Case 5
        strValue = "C:\Windows\Web\Wallpaper\Wallpaper5.bmp"
    Case 6
        strValue = "C:\Windows\Web\Wallpaper\Wallpaper6.bmp"
End Select

'We change the registry key that points to the wallpaper Windows will use.

strKeyPath = "Control Panel\Desktop"
ValueName = "Wallpaper"

objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue


You can mess with that and see what it does. Keep in mind this is quick and dirty.

Ron


Top
  Profile  
 
 Post subject:
PostPosted: Tue Jul 21, 2009 10:25 am 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Wed Nov 01, 2006 11:44 am
Posts: 2680
Location: Up in you attic...Wi-Fi is delicious
Just saying through the magic and power of "google", inputting "wallpaper changer" gave me a free "wallpaper changer" at http://www.wallpaperchanger.de/ . :wink:

*also a MS made one here found by "google".


Top
  Profile  
 
 Post subject:
PostPosted: Tue Jul 21, 2009 10:50 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24218
Location: Granite Heaven
Wow .. you guys like making things complicated, huh? ;)

Set your background to 'WallPaper.bmp'.

Create a script that randomly chooses an image from your collection and copies it over 'WallPaper.bmp'

BAM!


Top
  Profile  
 
 Post subject:
PostPosted: Tue Jul 21, 2009 12:08 pm 
Team Member [Top 500]*
Team Member [Top 500]*
User avatar

Joined: Thu Jun 24, 2004 2:22 pm
Posts: 8712
Location: Cleveland, Ohio
Jipstyle wrote:
Wow .. you guys like making things complicated, huh? ;)

Set your background to 'WallPaper.bmp'.

Create a script that randomly chooses an image from your collection and copies it over 'WallPaper.bmp'

BAM!


I was going to go that route but took the other route instead. I still may screw with it doing as suggested. So Jip, how to fully automate? Got any ideas for a simple minded type like myself lacking programming skills.

Ron


Top
  Profile  
 
 Post subject:
PostPosted: Tue Jul 21, 2009 12:37 pm 
Million Club - 2 Plus
Million Club - 2 Plus
User avatar

Joined: Sat Jun 07, 2008 9:29 am
Posts: 1105
guys, Thanks for all of your responses! i found some code on the internet and decided to change it a little, and it works great! you just drop this batch file in a dir of BMPs, change the path of where your default wallpaper is, and BAM! you get a new desktop background. Now to automate it, i used Scheduled Tasks to run this program whenever i log into my coputer, but you can make it run once a day or whatever you want.

Code:
@ECHO OFF

IF EXIST Files.txt DEL Files.txt

IF EXIST OutFile.txt DEL OutFile.txt

FOR /F %%F IN ('"DIR /B *.bmp | FIND /V /C "::""') DO SET /A Number=(%Random% %%%%F)


SET DONE==N

IF %Number%==0 GOTO No_Skip


FOR /F "SKIP=%Number%" %%D IN ('"DIR /B *.bmp | FIND /V "::""') DO ECHO %%D >>Files.txt

FOR /F "TOKENS=*" %%L IN (Files.txt) DO CALL :1 %%L

GOTO Next


:1

IF %DONE%==Y GOTO :eof

ECHO %*>OutFile.txt

SET DONE=Y

GOTO :eof


:No_Skip

FOR /F %%D IN ('"DIR /B *.bmp | FIND /V "::""') DO ECHO %%D>>Files.txt

FOR /F "TOKENS=*" %%L IN (Files.txt) DO CALL :2 %%L

GOTO Next

:2

IF %DONE%==Y GOTO :eof

ECHO %*>OutFile.txt

SET DONE=Y

GOTO :eof

:Next

FOR /F %%Z IN (OutFile.txt) DO SET File=%%Z

XCOPY %File% "C:\Documents and Settings\denis\Local Settings\Application Data\Microsoft\Wallpaper1.bmp" /Y

IF EXIST OutFile.txt DEL OutFile.txt

IF EXIST Files.txt DEL Files.txt
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters



Whaddua think?

EDIT: i believe that this tihng supports up to 9999 pics. since my fractal library is pushing 400, im set! plus IT dosn't give a damn about batch files, they get pissy about anything, so it seems.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Jul 21, 2009 1:57 pm 
Team Member [Top 500]*
Team Member [Top 500]*
User avatar

Joined: Thu Jun 24, 2004 2:22 pm
Posts: 8712
Location: Cleveland, Ohio
Thar ya go. Does what you want, works fine, and last a long time. :)

Really matters not what it is as long as it gets things done the way you want.

Ron


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group