From f6399423fa99baeb549b20be56009a10d2333873 Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 8 Jul 2022 14:09:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=B1=D0=B0=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2,=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BC=D0=B0=20=D0=B2=D1=8B=D0=B7=D1=8B=D0=B2=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=B6=D0=B4=D1=8B=D0=B5=203=20=D1=81=D0=B5=D0=BA=D1=83=D0=BD?= =?UTF-8?q?=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 2b7e7f2..6a39531 100644 --- a/main.py +++ b/main.py @@ -26,6 +26,7 @@ class Nasa: key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, key_value, 0, reg.KEY_ALL_ACCESS) reg.SetValueEx(key, user, 0, reg.REG_SZ, address) reg.CloseKey(key) + print("Программа добавлена в автозапуск") def download_photo(self): full_page = requests.get(self.url, headers=self.headers) @@ -33,6 +34,7 @@ class Nasa: lnk = str for link in soup.select("img"): lnk = link["src"] + print(f"Сохарняю картинку — {self.url + lnk}") img = urllib.request.urlopen(self.url + lnk).read() out = open(self.photoName, "wb") @@ -41,18 +43,22 @@ class Nasa: def set_wallpaper(self): path = os.path.abspath(self.photoName) + print("Установлено фоновое изображение") ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 0) def start(self): - if not ctypes.windll.shell32.IsUserAnAdmin() != 0: - elevate(show_console=False, graphical=False) self.download_photo() self.set_wallpaper() + print("Можно закрывать программу") + if ctypes.windll.shell32.IsUserAnAdmin() != 0: + elevate(show_console=False, graphical=False) + self.autorun() + print("Программа добавлена в автозапуск, можете закрывать программу") if __name__ == "__main__": nasa = Nasa() nasa.start() - schedule.every(3).seconds.do(nasa.start) + schedule.every(1).day.do(nasa.start) while True: schedule.run_pending()