3 remarks:
1) it will have done a new sweep, so it will not work for dumping data you got via more complex situations, like manual sweeps or single shot/paused gated sweeps.
2) after the screenshot is done, it will have removed any info that was printed as extra on screen. Example: Config/Show Options and do a screenshot. The options will be visible in the screenshot, but will become invisible on screen afterwards (but the menu still thinks they are displayed). Or try with "Display Cal data".
Now I understand why this happens, so to make the script more versatile, it would be nice to add a command line option "keep screen as is", admittedly sacrificing coloring in that case.
3) on my installation (python 3.14.2, PyVISA==1.16.1, PyVISA-py==0.8.1), I need to either remove the line "inst.close()" or change it into "rm.close()"