5 Replies - 775 Views - Last Post: 17 February 2015 - 01:22 AM Rate Topic: -----

#1 codepanda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 15

Unable to set wallpaper in Win 7 64x

Posted 05 February 2015 - 04:15 PM

import ctypes

SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "wp.jpg", 0)


The above code does nothing when I run it. Not sure what is the issue. Any idea?
Is This A Good Question/Topic? 0
  • +

Replies To: Unable to set wallpaper in Win 7 64x

#2 andrewsw  Icon User is online

  • say what now
  • member icon

Reputation: 6409
  • View blog
  • Posts: 25,903
  • Joined: 12-December 12

Re: Unable to set wallpaper in Win 7 64x

Posted 05 February 2015 - 04:34 PM

Is the image in the same location as the Python file?

I would try supplying the full path to the image.
Was This Post Helpful? 0
  • +
  • -

#3 codepanda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 15

Re: Unable to set wallpaper in Win 7 64x

Posted 06 February 2015 - 12:41 AM

I tried:
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, os.getcwd() + "\\" + "wp.jpg", 0)


and

ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "D:\\Dropbox\\Code\\py\\wp.jpg", 0)


Anyway I can find the error. I am just using sublime text and cmd line for running.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • say what now
  • member icon

Reputation: 6409
  • View blog
  • Posts: 25,903
  • Joined: 12-December 12

Re: Unable to set wallpaper in Win 7 64x

Posted 06 February 2015 - 02:59 AM

You can or you can't?

Maybe the process differs for x64, but I've exhausted any knowledge I had on this subject.

This post has been edited by andrewsw: 06 February 2015 - 03:30 AM

Was This Post Helpful? 0
  • +
  • -

#5 witeboy724  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 84
  • View blog
  • Posts: 208
  • Joined: 21-June 12

Re: Unable to set wallpaper in Win 7 64x

Posted 16 February 2015 - 11:18 AM

View Postcodepanda, on 06 February 2015 - 12:41 AM, said:

I tried:
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, os.getcwd() + "\\" + "wp.jpg", 0)

and
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "D:\\Dropbox\\Code\\py\\wp.jpg", 0)



I got it to work on my Windows 7 x64 by setting SPI_SETDESKWALLPAPER to 0x14 and SPIF_UPDATEINIFILE to 0x1 to replace the last 0 in the call. You will still need the full path. Try this and let me know if it works:
SPI_SETDESKWALLPAPER = 0x14
SPIF_UPDATEINIFILE   = 0x1

ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "D:\\Dropbox\\Code\\py\\wp.jpg", SPIF_UPDATEINIFILE)


Was This Post Helpful? 0
  • +
  • -

#6 Akitsushima  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-February 15

Re: Unable to set wallpaper in Win 7 64x

Posted 17 February 2015 - 01:22 AM

Have you tried forward slashes instead of backward slashes?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1