|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > Screenshot Tools - Screen capture operations > MCP Commands - Screenshot Tools |
MiniRobot Language (MRL) - MCP Screenshot Tools Commands
MCP.ShotGetLastRect / SHOT.GETLASTRECT
Get Last Screenshot Rectangle
Purpose
The SHOT.GETLASTRECT command retrieves the rectangle coordinates (X, Y, Width, Height) of the most recently captured screenshot. This information is useful for understanding what region was captured, performing follow-up captures of the same area, or calculating relative positions for subsequent operations.
This command is particularly useful when:
• Determining the coordinates of the last screenshot capture
• Re-capturing the same region with updated content
• Calculating relative positions within the captured area
• Implementing screen monitoring of a specific region
• Debugging screenshot capture operations
Syntax
SHOT.GETLASTRECT|$$X_VAR|$$Y_VAR|$$W_VAR|$$H_VAR
Parameters
$$X_VAR - The variable that will receive the X coordinate (left position) of the last screenshot.
$$Y_VAR - The variable that will receive the Y coordinate (top position) of the last screenshot.
$$W_VAR - The variable that will receive the width of the last screenshot in pixels.
$$H_VAR - The variable that will receive the height of the last screenshot in pixels.
Return Values
The command populates the four provided variables with the rectangle coordinates:
X_VAR - Left coordinate of the captured region
Y_VAR - Top coordinate of the captured region
W_VAR - Width of the captured region in pixels
H_VAR - Height of the captured region in pixels
If no screenshot has been taken in the current session, all variables will be set to 0.
Examples
' Example 1: Get rectangle of last screenshot
SHOT.SCREEN|$$FilePath
SHOT.GETLASTRECT|$$X|$$Y|$$W|$$H
PRT.Last screenshot at: ($$X, $$Y) size $$W x $$H
' Example 2: Re-capture the same region
' First, capture a region
SHOT.SCREEN|100|100|400|300|$$FirstShot
' Later, get the rectangle and capture again
SHOT.GETLASTRECT|$$LastX|$$LastY|$$LastW|$$LastH
SHOT.SCREEN|$$LastX|$$LastY|$$LastW|$$LastH|$$SecondShot
PRT.Re-captured same region: $$SecondShot
' Example 3: Calculate center of captured region
SHOT.SCREEN|$$FilePath
SHOT.GETLASTRECT|$$RLeft|$$RTop|$$RWidth|$$RHeight
' Calculate center point
MAT.($$RWidth/2)+$$RLeft|$$CenterX
MAT.($$RHeight/2)+$$RTop|$$CenterY
PRT.Center of screenshot: ($$CenterX, $$CenterY)
Remarks
The SHOT.GETLASTRECT command retrieves the rectangle data from the most recent screenshot capture, regardless of whether it was a full-screen or region capture. For full-screen captures, the X and Y values will be 0, and W and H will match the screen dimensions.
The rectangle information persists for the duration of the MCP server session. If the server is restarted, the last screenshot rectangle data is reset to zeros.
MCP.ShotGetLastRect and SHOT.GETLASTRECT are aliases for the same command. You can use either form.
Error Conditions
The command will fail with an error if:
• Any of the four return variable parameters are missing
• The ScreenshotTools feature is disabled in the server configuration
• Too many parameters are provided
See also:
• SHOT.SCREEN - Capture Screenshot
• SHOT.GETLASTRATIO - Get Last Screenshot Ratio
• SHOT.GETQUADCENTER - Get Quadrant Center