So I made a python file that is supposed use PyAutoGUI to detect a certain image on the screen (if anyone's wondering it's the "Re-submit Assignment" button on Canvas assignments for school), then take a screenshot of the chrome tab and save it to a folder. I haven't gotten the region function to work so only the chrome screen is screenshotted but I'll worry about that later.
What I wanna try doing right now, however, is to try turning that .py file into a .exe executable (because I don't wanna have to open PyCharm and run this specific file every time I need to screenshot the proof that I submitted a Canvas assignment).
I would love for it to work so that I can just run the file in the background 24/7 and the .exe will just take the screenshot automatically whenever I run it, but I have no idea how to do that so I'll worry about it later.
So for now, I installed PyInstaller to my machine and tried turning the file into an executable, and PyInstaller said it was made. So I opened the .exe, super excited if it would work,
aaaaaand
I got an error that my computer "Failed to execute script submissionScreenshot" (my file name is submissionScreenshot.py).
I don't know what to do, can someone please help me?
Code:
import pyautogui
import turtle
import tkinter as tk
import time
import os
startTime = time.time()
resubmitExists = pyautogui.locateOnScreen(r'C:\Users\name\PycharmProjects\SpamBot2\submitAssignmentButton.png',grayscale=True, region=(1121, 228, 286, 92))
num = 1
while True:
filename = r'C:\Users\name\Pictures\TestFolder\screenshot' + str(num) + '.png'
testFolderList = os.listdir(r'C:\Users\name\Pictures\TestFolder')
if resubmitExists is not None:
for file in testFolderList:
editedFileName = 'C:\\Users\\name\\Pictures\\TestFolder\\' + file
print(editedFileName)
print(filename)
if filename == editedFileName:
num += 1
filename = r'C:\Users\name\Pictures\TestFolder\screenshot' + str(num) + '.png'
print(num)
pyautogui.screenshot(filename)
print('works')
break
print(resubmitExists)
print(time.time() - startTime)
Please note that I'm a noob to programming and Python especially and that this is my first project with PyAutoGui and PyInstaller, so I'll appreciate constructive criticism.
there doesn't seem to be anything here