How to take a ScreenShot of your Mechanical Application

Member, Employee Posts: 222
100 Comments 100 Likes Second Anniversary Name Dropper
✭✭✭✭
edited December 2023 in Structures

You might need to create Screen Shot of the graph or Table sometimes. You can get the coordinates and use the below script.

Tagged:

Best Answers

  • Member, Employee Posts: 222
    100 Comments 100 Likes Second Anniversary Name Dropper
    ✭✭✭✭
    Answer ✓

    The below Script Saves 2 PNG screen captures in your D:/ Drive

    1. import clr
    2. import os
    3. import sys
    4. clr.AddReference("System.Windows.Forms")
    5. clr.AddReference("System.Drawing")
    6.  
    7. from System.Drawing import Bitmap,Graphics,Point,Size
    8. from System.Windows.Forms import(
    9. Application,Button,Form,FormWindowState,
    10. PictureBox,Screen)
    11. UserFiles="D:"
    12. Fname="sample.png"
    13.  
    14. bmp=Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height)
    15. g=Graphics.FromImage(bmp)
    16. g.CopyFromScreen(0,0,0,0,bmp.Size)
    17. bmp.Save(os.path.join(UserFiles,Fname+".png"))
    18. g.Dispose()
    19.  
    20. Fname="PartScreen.png"
    21. bmp=Bitmap(550,1000)
    22. g=Graphics.FromImage(bmp)
    23. g.CopyFromScreen(0,0,0,0,Size(550,50))
    24. bmp.Save(os.path.join(UserFiles,Fname+".png"))
    25. g.Dispose()

Answers

  • Member, Moderator, Employee Posts: 891
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

    Warning. All the methods exposed here use unsupported/undocumented commands. There is no guarantee that the script will work and/or that the APIs will not change in between versions. Use at your own risk.

Welcome!

It looks like you're new here. Sign in or register to get started.