problem during script execution
Blender doesn't update the GUI by default when a script is running. See Update viewport while running script
Add bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) after you change frames to update the GUI.
Also, you can take Blender screenshots with a BPY op like this bpy.ops.screen.screenshot( filepath=path, check_existing=False) so you might not need pyautogui.
import bpy
#import pyautogui
import time
c=1
while c&lt;=50:
    bpy.context.scene.frame_current =c
    bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
    time.sleep(0.5)
    path='C:\\tmp\\script_screenshot\\'+str(c)+'.png'
#    pyautogui.screenshot(path)
    bpy.ops.screen.screenshot( filepath=path, check_existing=False)
    c=c+5