#๐Ÿ”’ Help with pyautoGUI

5 messages ยท Page 1 of 1 (latest)

gusty trellisBOT
#

@warped vector

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

vital iris
#
def record_screen(filename, fps=30, duration=10):
    screen = pyautogui.size()
    screen_width, screen_height = screen

    # Define the codec and create VideoWriter object
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(filename, fourcc, fps, (screen_width, screen_height))

    # Record screen for the specified duration
    num_frames = fps * duration
    for _ in range(num_frames):
        # Capture screenshot using PyAutoGUI
        screenshot = pyautogui.screenshot()

        # Convert the screenshot to a numpy array
        frame = np.array(screenshot)

        # Convert RGB to BGR (OpenCV uses BGR)
        frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

        # Write frame to video file
        out.write(frame)

    # Release resources
    out.release()
if __name__ == "__main__":
    output_file = "task_record.mp4"
    recording_fps = 30  # Frames per second
    recording_duration = 10  # Duration in seconds

    record_screen(output_file, fps=recording_fps, duration=recording_duration)

this will help you how can o create i have sample code to record and save it as mp4 file

#

and for macro using pyautogui, it's hard because if you screen resolution of app resolution will change then poaition will not work correctly.

gusty trellisBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.