2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python3でWindowsの壁紙を変更する

Last updated at Posted at 2019-03-29

#環境

  • Windows 10
  • Python3.7.1 (Anaconda)

#方法
 お馴染みのctypesを使う.絶対パス指定じゃないと上手くいかなかったので注意.

import ctypes

ctypes.windll.user32.SystemParametersInfoW(20, 0, "画像ファイルの絶対パス" , 0)

 デュアルモニタなので不安だったが普通に動いた.

#ちなみに
 Pythonのバージョン(2系 or 3系)によって関数名が違う.文字の扱いがバージョンによって違うからだと思う.
 Python3系はSystemParametersInfoWで動作したが,Python2系の場合もSystemParametersInfoAに名前を一文字変えるだけで使えるっぽい(未確認).

#参考
stack overflow : Creating a background changer in python with ctypes, not working

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?