I have 2 Function the 1st one is atomization using Pywinauto and the second function is screenshot recording using opencv
this is my code on my second function
def record():
# display screen resolution, get it from your OS settings
SCREEN_SIZE = pyautogui.size()
isRecording = True
# define the codec
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
# create the video write object
file_name = asksaveasfilename(confirmoverwrite=True,defaultextension='.mp4')
out = cv2.VideoWriter(file_name, fourcc, 20.0, SCREEN_SIZE)
print("Recording Started...\n")
while isRecording == True:
# make a screenshot
img = pyautogui.screenshot()
# convert these pixels to a proper numpy array to work with OpenCV
frame = np.array(img)
# convert colors from BGR to RGB
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
cv2.imshow("Recording...", frame)
if isRecording == True:
out.write(frame)
if cv2.waitKey(1) == ord("q"):
cv2.destroyAllWindows()
out.release()
break
so While isRecording is True it will continue to write.
On my Main Function or the first Function
def installer():
installer.child_window(auto_id='deviceSelectionNextButton').invoke()
progress = app.Dialog.ProgressBar
status = progress.exists()
while status == True:
isRecording = False
if progress.exists() == False:
isRecording = True
this is waiting for the progress bar to finish or disappear.
What I am trying to get here is when its Loading it will turn isRecording to False which will making the function recording stop write and when its done loading it will turn isRecording to True and continue write.
Recording is running at the same time as Installer. Since Recording constantly screenshot and installer is an atomization of an application, the Installer function runs the Atomization and the Record Function records the Atomization