tried to make a steam download Automator using schedule subprocess pyautogui time requests
(and steam cmd)
im thinking the problem might come from steam cmd but I’m not too sure
when the time hits that its supposed to download it just does nothing everything other than the downloading works any help would be appreciated
heres the code
<code>import schedule
import subprocess
import pyautogui
import time
import requests
def get_steam_app_id(game_name):
search_url = f"https://store.steampowered.com/api/storesearch/?term={game_name}&cc=us"
try:
response = requests.get(search_url)
response.raise_for_status()
results = response.json().get('items', [])
if results:
first_result = results[0]
app_id = first_result.get('id')
game_title = first_result.get('name')
print(f"Found '{game_title}' with app ID: {app_id}")
return app_id
else:
print(f"No results found for {game_name}.")
return None
except requests.RequestException as e:
print(f"Error fetching app ID: {e}")
return None
def connect_to_wifi():
wifi_name = "your wifi name"
try:
subprocess.run(f'netsh wlan connect name="{wifi_name}"', check=True, shell=True)
print(f"Connected to {wifi_name}")
except subprocess.CalledProcessError as e:
print(f"Failed to connect to {wifi_name}: {e}")
def start_steam_download(app_id):
try:
print(f"Starting Steam download for app ID: {app_id}...")
command = (
'C:\steamcmd\steamcmd +login anonymous '
f'+app_update {app_id} validate +quit'
)
subprocess.run(command, shell=True, check=True)
print("Steam download started.")
except subprocess.CalledProcessError as e:
print(f"Failed to start the download: {e}")
def pause_steam_download():
print("Pausing Steam download...")
time.sleep(2)
x_coord = 1819
y_coord = 359
pyautogui.click(x_coord, y_coord)
print(f"Clicked pause at coordinates ({x_coord}, {y_coord}). Steam download paused.")
def schedule_tasks(app_id):
schedule.every().day.at("09:17").do(lambda: connect_to_wifi())
schedule.every().day.at("09:17").do(lambda: start_steam_download(app_id))
schedule.every().day.at("09:19").do(lambda: pause_steam_download())
print("Tasks scheduled")
if __name__ == "__main__":
game_name = input("Enter the game name: ")
app_id = get_steam_app_id(game_name)
if app_id:
schedule_tasks(app_id)
while True:
schedule.run_pending()
time.sleep(5)
else:
print("Unable to schedule tasks without a valid app ID.")
</code>
<code>import schedule
import subprocess
import pyautogui
import time
import requests
def get_steam_app_id(game_name):
search_url = f"https://store.steampowered.com/api/storesearch/?term={game_name}&cc=us"
try:
response = requests.get(search_url)
response.raise_for_status()
results = response.json().get('items', [])
if results:
first_result = results[0]
app_id = first_result.get('id')
game_title = first_result.get('name')
print(f"Found '{game_title}' with app ID: {app_id}")
return app_id
else:
print(f"No results found for {game_name}.")
return None
except requests.RequestException as e:
print(f"Error fetching app ID: {e}")
return None
def connect_to_wifi():
wifi_name = "your wifi name"
try:
subprocess.run(f'netsh wlan connect name="{wifi_name}"', check=True, shell=True)
print(f"Connected to {wifi_name}")
except subprocess.CalledProcessError as e:
print(f"Failed to connect to {wifi_name}: {e}")
def start_steam_download(app_id):
try:
print(f"Starting Steam download for app ID: {app_id}...")
command = (
'C:\steamcmd\steamcmd +login anonymous '
f'+app_update {app_id} validate +quit'
)
subprocess.run(command, shell=True, check=True)
print("Steam download started.")
except subprocess.CalledProcessError as e:
print(f"Failed to start the download: {e}")
def pause_steam_download():
print("Pausing Steam download...")
time.sleep(2)
x_coord = 1819
y_coord = 359
pyautogui.click(x_coord, y_coord)
print(f"Clicked pause at coordinates ({x_coord}, {y_coord}). Steam download paused.")
def schedule_tasks(app_id):
schedule.every().day.at("09:17").do(lambda: connect_to_wifi())
schedule.every().day.at("09:17").do(lambda: start_steam_download(app_id))
schedule.every().day.at("09:19").do(lambda: pause_steam_download())
print("Tasks scheduled")
if __name__ == "__main__":
game_name = input("Enter the game name: ")
app_id = get_steam_app_id(game_name)
if app_id:
schedule_tasks(app_id)
while True:
schedule.run_pending()
time.sleep(5)
else:
print("Unable to schedule tasks without a valid app ID.")
</code>
import schedule
import subprocess
import pyautogui
import time
import requests
def get_steam_app_id(game_name):
search_url = f"https://store.steampowered.com/api/storesearch/?term={game_name}&cc=us"
try:
response = requests.get(search_url)
response.raise_for_status()
results = response.json().get('items', [])
if results:
first_result = results[0]
app_id = first_result.get('id')
game_title = first_result.get('name')
print(f"Found '{game_title}' with app ID: {app_id}")
return app_id
else:
print(f"No results found for {game_name}.")
return None
except requests.RequestException as e:
print(f"Error fetching app ID: {e}")
return None
def connect_to_wifi():
wifi_name = "your wifi name"
try:
subprocess.run(f'netsh wlan connect name="{wifi_name}"', check=True, shell=True)
print(f"Connected to {wifi_name}")
except subprocess.CalledProcessError as e:
print(f"Failed to connect to {wifi_name}: {e}")
def start_steam_download(app_id):
try:
print(f"Starting Steam download for app ID: {app_id}...")
command = (
'C:\steamcmd\steamcmd +login anonymous '
f'+app_update {app_id} validate +quit'
)
subprocess.run(command, shell=True, check=True)
print("Steam download started.")
except subprocess.CalledProcessError as e:
print(f"Failed to start the download: {e}")
def pause_steam_download():
print("Pausing Steam download...")
time.sleep(2)
x_coord = 1819
y_coord = 359
pyautogui.click(x_coord, y_coord)
print(f"Clicked pause at coordinates ({x_coord}, {y_coord}). Steam download paused.")
def schedule_tasks(app_id):
schedule.every().day.at("09:17").do(lambda: connect_to_wifi())
schedule.every().day.at("09:17").do(lambda: start_steam_download(app_id))
schedule.every().day.at("09:19").do(lambda: pause_steam_download())
print("Tasks scheduled")
if __name__ == "__main__":
game_name = input("Enter the game name: ")
app_id = get_steam_app_id(game_name)
if app_id:
schedule_tasks(app_id)
while True:
schedule.run_pending()
time.sleep(5)
else:
print("Unable to schedule tasks without a valid app ID.")
tried reinstalling steam cmd i was expecting it to connect to the Wi-Fi provided and then start the download to then stop the download with the coordinates given to pyautogui
1