ScreenshotService

Captures all or part of the screen.

# Methods

[{"index":"ScreenshotError, string CaptureFullScreenAsFileAndWait(string fileName, boolean includeUI = true) (ClientOnly) (Yield)","0":"Captures the entire screen and saves it as a PNG file. Used to share captured images in combination with MobileShareService. Once it's saved, it will display an error code and save path. Stops script execution while performing. Supported in Windows PC, macOS, Android, and iOS environments.Save Path* Windows: My PC > Pictures > MapleStory Worlds > World ID > fileName.png* Mac: Home > Pictures > MapleStory Worlds > World ID > fileName.png* Android: Internal memory > Android > data > com.nexon.mod > files > MapleStory Worlds > Screenshots > World ID > fileName_*.png* iOS: My Files > My iPhone > MapleStory Worlds > Screenshots > World ID > fileName_*.png"}]

[{"index":"void CaptureFullScreenAsFileAsync(string fileName, func callbackFunction, boolean includeUI = true) (ClientOnly)","0":"Captures the entire screen and saves it as a PNG file. Used to share captured images in combination with MobileShareService. It is performed asynchronously, and once it is saved, the function passed to callbackFunction is called. The first parameter of callbackFunction is the error code, and the second is the storage path. Supported in Windows PC and Mac environments."}]

[{"index":"ScreenshotError, RawImage CaptureFullScreenAsPixelDataAndWait(boolean includeUI = true) (ClientOnly) (Yield)","0":"Returns the result of capturing the entire screen. Stops script execution while performing. The total number of pixels in the image is automatically scaled to be less than 800x600. If the capture area is too large, you will get a scaled-down image. This is supported in Windows PC, macOS, Android, and iOS environments."}]

[{"index":"void CaptureFullScreenAsPixelDataAsync(func callbackFunction, boolean includeUI = true) (ClientOnly)","0":"Returns the result of capturing the entire screen. It is performed asynchronously, and once it is saved, it calls the function passed to callbackFunction. The first parameter of callbackFunction is the error code, and the second is the captured image. The total number of pixels in the image is automatically scaled to be less than 800x600. If the capture area is too large, you will get a scaled-down image. This is supported in Windows PC and macOS environments."}]

[{"index":"ScreenshotError, string CaptureFullScreenToPhotoLibraryAndWait(string fileName, boolean includeUI = true) (ClientOnly) (Yield)","0":"Captures the entire screen and saves it as a PNG file in your photo gallery. Once it is saved, it will display an error code and the save path. Stops script execution while performing. Supported in Windows PC, Mac, Android, and iOS environments.Save Path* Windows: My PC > Pictures > MapleStory Worlds > World ID > fileName.png* macOS: Home > Pictures > MapleStory Worlds > World ID > fileName.png* Android : Gallery > Maplestory Worlds Album* iOS : Photos"}]

[{"index":"ScreenshotError, string CaptureScreenRegionAsFileAndWait(string fileName, Vector2 from, Vector2 to, boolean includeUI = true) (ClientOnly) (Yield)","0":"Captures part of the screen and saves it as a PNG file. Once it is saved, it will display an error code and the save path. Stops script execution while performing. Supported in Windows PC, macOS, Android, and iOS environments."}]

[{"index":"void CaptureScreenRegionAsFileAsync(string fileName, Vector2 from, Vector2 to, func callbackFunction, boolean includeUI = true) (ClientOnly)","0":"Captures part of the screen and saves it as a PNG file. It is performed asynchronously, and once it is saved, the function passed to callbackFunction is called. The first parameter of callbackFunction is the error code, and the second is the storage path. Supported in Windows PC and macOS environments."}]

[{"index":"ScreenshotError, RawImage CaptureScreenRegionAsPixelDataAndWait(Vector2 from, Vector2 to, boolean includeUI = true) (ClientOnly) (Yield)","0":"Returns the result of capturing a part of the screen. Script executions are suspended during the operation. The total number of pixels in the image is automatically scaled to be less than 800x600. If the capture area is too large, you will get a scaled-down image. This is supported in Windows PC, macOS, Android, and iOS environments."}]

[{"index":"void CaptureScreenRegionAsPixelDataAsync(Vector2 from, Vector2 to, func callbackFunction, boolean includeUI = true) (ClientOnly)","0":"Returns the result of capturing the selected rectangular area. It is performed asynchronously, and once it is saved, it calls the function passed to the callbackFunction. The first parameter of the callbackFunction is an error code, and the second is the pixel data. The total number of pixels in the image is automatically scaled to be less than 800x600. If the capture area is too large, you will get a scaled-down image. This is supported in Windows PC and macOS environments."}]

[{"index":"ScreenshotError, string CaptureScreenRegionToPhotoLibraryAndWait(string fileName, Vector2 from, Vector2 to, boolean includeUI = true) (ClientOnly) (Yield)","0":"Captures a portion of the screen and saves it as a PNG file in your photo gallery. Once it is saved, it will display an error code and the save path. Stops script execution while performing. Supported in Windows PC, macOS, Android, and iOS environments."}]

##### inherited from Service:

[{"index":"EventHandlerBase ConnectEvent(string key, IScriptFunction eventHandler)","0":"Links events. When a key-type event occurs in this service, a handler is notified. The handler receives event parameters."}]

[{"index":"EventHandlerBase ConnectEvent(Type eventType, IScriptFunction eventHandler)","0":"Links events. This service notifies a handler when an eventType event occurs. The handler receives event parameters."}]

[{"index":"boolean DisconnectEvent(string key, EventHandlerBase eventHandler)","0":"Disconnects the event with the key-type event and the handler."}]

[{"index":"boolean DisconnectEvent(Type eventType, EventHandlerBase eventHandler)","0":"Disconnects the eventType event from its handler."}]

[{"index":"void SendEvent(EventType sendEvent)","0":"Generates an event."}]

# Examples

#### CaptureFullScreenAsFileAndWait
    
    
    @Component
    script ScreenshotCapture extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            -- Capture the entire screen and save it as an image file named "Screenshot.png".
            -- You can get the entire path of the saved file and the error code showing the capture result as the return value.
            local error, fullPath = _ScreenshotService:CaptureFullScreenAsFileAndWait("Screenshot")
            
            if error == ScreenshotError.Success then
            	log ("It has been saved. " .. fullPath)
            end
        end
    end
    

#### CaptureScreenRegionAsFileAndWait
    
    
    @Component
    script ScreenRegionCapture extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
            -- Capture a specific area and save it as an image file with the name "Screenshot.png".
            -- You can get the entire path of the saved file and the error code showing the capture result as the return value.
            local startPixel = Vector2(100, 100)
            local endPixel = Vector2(900, 900)
            local error, fullPath = _ScreenshotService:CaptureScreenRegionAsFileAndWait("Screenshot", startPixel, endPixel)
            
            if error == ScreenshotError.Success then
            	log ("It has been saved. " .. fullPath)
            end
        end
    end
    

# SeeAlso

  * MobileShareService
  * [Screenshots and Dynamic Sprites](/docs?postId=829)
  * [Taking and Sharing Screenshots](/docs?postId=756)