2

I realise that there are other questions on this topic, all of which I have attempted to implement the answers of and failed. I would like to end up with a full blown answer, ideally with a demonstration, on how to, in Windows and only Windows set the desktop background instantly without having the user log in and out or lock and log back in. The approach that involves using the runtime console to push the registry entries about and then rundll32 user32.dll call UpdatePerUserSystemPreferences has yet to work for me. The desired behaviour is achieved when the user right clicks an image file in explorer and selects 'Set as desktop background'. I'd like to do that programatically even if it devolves to the level of opening a hidden explorer window and right-clicking a file in it as long as the user sees nothing of it. The application in question updates the user's desktop background image with useful system information. The image to be used will be generated and regenerated every five seconds.

Scruffy
  • 580
  • 8
  • 23
  • http://stackoverflow.com/questions/12207574/programmatically-change-the-desktop-wallpaper-periodically – Ya Wang Feb 15 '15 at 03:36
  • @Invexity I am aware of that. None of the answers there worked. Please give another or show one working. – Scruffy Feb 15 '15 at 03:37

1 Answers1

2

Can I change my Windows desktop wallpaper programmatically in Java/Groovy?

So the correct way is with JNA if you are not familiar with JNA or if you haven't used JNA the link above is for you. Otherwise you are right about using natives but you never stated how you are using them so I am just taking shots in the dark here.

Community
  • 1
  • 1
Ya Wang
  • 1,758
  • 1
  • 19
  • 41
  • Trying that, the UINT_PTR type is unrecognised. Where can I get `com.sun.jna.platform.win32.WinDef.UINT_PTR`? I'll accept your answer as the solution to this question if you explain. – Scruffy Feb 20 '15 at 20:26