Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Refreshing Desktop Wallpaper with Java.

Options
  • 01-04-2002 8:28pm
    #1
    Registered Users Posts: 1,783 ✭✭✭


    Is this possible? I have a program that basically picks a random image from a given folder and saves it as random.jpg. This works fine.

    I have my Wallpaper set as random.jpg and the batch file for the Java program in my Start Up folder in the hopes that I will get a different pic everytime I restart my machine.

    Doesn't work though. :(

    Windows keeps the same old pic as my desktop untill I go into properties and select random.jpg as my wallpaper, even though that's what it was set at anyway.

    I posted this in MS Apps/OS too -> http://www.boards.ie/vbulletin/showthread.php?s=&postid=414522#post414522

    I'm now looking for someway to use the program I have written to refresh my desktop wallpaper. Is this possible?


Comments

  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    If such a method existed it would be somewhere in the Java Native Interface. By using this, you instantly make your software platform dependent. It still runs in a VM, but interacts with a specific platform now.

    I personally don't know of any methods to do this, but what you could do (it would be a lot easier, because it's windows we're talking about here) is to write a quick VB app that does it for you. AFAIK you can do what you want in 1 or 2 lines of code.

    But if you are like me, you will probably try and solve the problem using Java as opposed to venturing off somewhere else. But anyway if you do use the VB option, you can still use your Java code, and simply Runtime.exec(the_VB_Refresh_Desktop_app).

    It's a suggestion, there probably will be other better ones though :( . Coz personally I don't like this one myself, but nevertheless it would work.

    ;-phobos-)


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    Does it keep the old background even when you reboot? I did a program just like yours a while ago, also in Java, and had similar problems. However once I rebooted the background changed to the new one.

    So if you think about it, as long as you run the program every time you boot, then the background for your next boot will be different to your current background. Does it make a difference if it's one step behind? Once you get it going then no, it doesn't.

    I was using 95, so I'm not sure if this would work on any other versions, but it worked just fine for me.


  • Registered Users Posts: 1,783 ✭✭✭Puck


    Yeah phobos I know I could do it simply if I chose VB. But I like Java so I think I'll try to do it the hard way. It's not like I have to do this, it's just a bit of fun to see if I can do it.

    Jazz it keeps the same background no matter how many times I reboot. It's always the same untill I set it manually.

    Oh btw, I'm using Windows XP. Thanks for the input guys, this is an interesting little problem.:)


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    It is an interesting problem, and I would be interested in knowing how you got this working (if you do!).

    You see as I said earlier changing the wallpaper is not the problem, it's refreshing the desktop, to update the changes, during the same windows session that is. (that's just for anyone else that jumps in on this, so we don't have the same conclusions re-occuring).

    Ah, this is a problem of mine, that I seem to be doing a lot (especially on this board). I don't fully read people's initial problem posts, I just look for key words and then express my opinion.

    Right it turns out you want to have a new image each time you boot. That's actually different from what I thought you wanted. OK in the windows.ini file there is a Wallpaper variable that points to a filepath\image_filename.bmp. What you can do is have a list of image filenames in a file, or in a directory (or whatever), and randomly select on of those, as an init value for the Wallpaper variable in win.ini . All this involves is some file I/O code.

    Now here's the key part: This program should be executed by autoexec.bat while the PC boots. So effectively you will either call the batch file you have already written, or else insert a:

    java yourProg
    in the autoexec.bat

    The Windows variable will not have been processed until after autoexec.bat has finished. So when you finally get in to windows, the new wallpaper should be visible. :cool:

    ;-phobos-)


  • Registered Users Posts: 1,783 ✭✭✭Puck


    Ah... couple of problems there.

    I can't find either autoexec.bat or windows.ini in Windows XP. I'm guessing you meant win.ini. I checked win.ini but there's no Wallpaper variable.

    I get what you're saying though. I'm just new to XP.


  • Advertisement
  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    Originally posted by phobos
    Right it turns out you want to have a new image each time you boot. That's actually different from what I thought you wanted. OK in the windows.ini file there is a Wallpaper variable that points to a filepath\image_filename.bmp. What you can do is have a list of image filenames in a file, or in a directory (or whatever), and randomly select on of those, as an init value for the Wallpaper variable in win.ini . All this involves is some file I/O code.

    In the above quote I mentioned both windows.ini & win.ini, sorry I meant just win.ini (but got carried away).

    Now the fact that your autoexect.bat doesn't exist means only one thing (you need to create one).

    All I say you do is create a file as follows:

    @echo off
    call your_bacth_file.bat
    rem or enter your java yourProg.class entry yourself

    Save as autoexec.bat in the root directory of your boot drive (usually C:\)

    I hope what I have told you is true, coz I'm very drunk after the Galway Drinkies session (as on the After Hours board).

    ;-phobos-)


Advertisement