Почему код не работает, если я пытаюсь его открыть на рабочем столе, но через IDLE он работает

Я пробовал по совету друга менять расширение файла на pyw, но это не сработало. Если вкратце, то код должен доставать гвард для стима и вставлять его в лаунчер.

Я немного напортачил с метками, помогите их расставить, чтоб все было по правилам.

Вот пример кода:

#!/usr/bin/env python3

import sched
import pyperclip
import hmac
import math
import time
import base64
import hashlib
import os
import re
import pyautogui

def get_guard_code(key, timestamp=time.time()):
    steam_guard_code_table = [50, 51, 52, 53, 54, 55, 56, 57, 66, 67, 68, 70, 71,
                              72, 74, 75, 77, 78, 80, 81, 82, 84, 86, 87, 88, 89]
    decoded_shared_secret = base64.b64decode(bytes(key, "utf-8"))
    time_bytes = int(int(timestamp) / 30).to_bytes(8, byteorder="big")
    time_left = 30 - int(timestamp) % 30
    hmac_generator = hmac.new(decoded_shared_secret, time_bytes, hashlib.sha1)
    hashed_data = hmac_generator.digest()
    b = hashed_data[19] & 0xF
    code_point = (hashed_data[b] & 0x7F) << 24 | \
                 (hashed_data[b + 1] & 0xFF) << 16 | \
                 (hashed_data[b + 2] & 0xFF) << 8 | \
                 (hashed_data[b + 3] & 0xFF)
    code_array = []
    for i in range(5):
        code_array.append(steam_guard_code_table[code_point % len(steam_guard_code_table)])
        code_point = math.floor(code_point / len(steam_guard_code_table))
    return ''.join(chr(i) for i in code_array), time_left
files = os.listdir(path=r"C:\Authenticator\maFiles")
account = pyperclip.paste()
i = 0
while i < len(files):
    try:
        profileid = files[i].replace('.maFile', '')
        mafilelink = r'C:\Authenticator\maFiles\\' + profileid + '.maFile'
        f = open(mafilelink, 'r')
        mafiletext = [line.strip() for line in f]
        f.close()
        mafiletext = str(mafiletext)
        if account in mafiletext:
            print(mafiletext)
            SHARED_SECRET = (re.search('"shared_secret":"(.*?)","', mafiletext)).group(1)
            print(SHARED_SECRET)
            break
        i += 1
    except:
        i += 1




# if __name__ == "__main__":
#     s = sched.scheduler(time.time, time.sleep)663T4

#
#     def update_guard_code():
#         code, sec = get_guard_code(SHARED_SECRET, time.time())
#         print("{0}    Update in {1}s ".format(code, sec), end="\r")
#         s.enter(1, 1, update_guard_code)
#
#     s.enter(1, 1, update_guard_code)
#     s.run()

code, sec = get_guard_code(SHARED_SECRET, time.time())
print(code, sec)
#pyperclip.copy(code)
pyautogui.click(x=1066, y=588)
time.sleep(0.05)
pyautogui.write(code)
time.sleep(0.05)
pyautogui.press('Enter')

Ответы (0 шт):