Window.Screenshot
-----------------

Creates screenshot from a window.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Window](component_Window.md) | [5.4](newinversion54.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ✅ Yes |

MBS( "Window.Screenshot"; WindowRef { ; MarginLeft; MarginTop; MarginRight; MarginBottom; ImageType; FileName } ) 

**MBS**( **"Window.Screenshot";** /\* Creates screenshot from a window. \*/  
**$WindowRef**; /\* Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window.e.g. 0 \*/   
**$MarginLeft**; /\* Optional; The margin from left to cut away border.e.g. 0 \*/   
**$MarginTop**; /\* Optional; The margin from top to cut away border.e.g. 0 \*/   
**$MarginRight**; /\* Optional; The margin from right to cut away border.e.g. 0 \*/   
**$MarginBottom**; /\* Optional; The margin from bottom to cut away border.e.g. 0 \*/   
**$ImageType**; /\* Optional; The type of image to return.   
Either JPEG, PNG, GIF or BMP. Default is JPEG.e.g. "JPEG" \*/   
**$FileName**) /\* Optional; The filename to use for the picture.   
Default is "image" with the extension matching the image type.  
The image is not written to disk. This file name is just added to the container for later export.e.g. "test.jpg" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| WindowRef | Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window. | 0 |  |
| MarginLeft | The margin from left to cut away border. | 0 | Optional |
| MarginTop | The margin from top to cut away border. | 0 | Optional |
| MarginRight | The margin from right to cut away border. | 0 | Optional |
| MarginBottom | The margin from bottom to cut away border. | 0 | Optional |
| ImageType | The type of image to return.    Either JPEG, PNG, GIF or BMP. Default is JPEG. | "JPEG" | Optional |
| FileName | The filename to use for the picture.    Default is "image" with the extension matching the image type.   The image is not written to disk. This file name is just added to the container for later export. | "test.jpg" | Optional |

### Result

Returns image or error.

### Description

Creates screenshot from a window.  
Returns the image as container value, so you can assign it to a container field or save to disk with [Container.WriteFile](ContainerWriteFile.md) function.  
Margins are different for Mac and Windows.   
  
Added iOS support in version 8.5, but margins are not supported there, so we always take full screen.  
  
On Windows may get wrong rectangle if Windows runs desktop with 200% resolution, but you have a 100% resolution screen.  
If you change zoom in Windows display controls while FileMaker runs, the plugin may not notice the change until you restart FileMaker.  
### Examples

Creates screenshot:

 MBS ("Window.Screenshot"; Get(WindowName); Window Screenshot::Margin Left; Window Screenshot::Margin Top; Window Screenshot::Margin Right; Window Screenshot::Margin Bottom)  
Screenshot of current window as JPEG:

 MBS ( "Window.Screenshot"; 0)  
### See also

- [Container.WriteFile](ContainerWriteFile.md)
- [Screenshot](Screenshot.md)
- [WebView.Screenshot](WebViewScreenshot.md)
- [Window.FindByIndex](WindowFindByIndex.md)
- [Window.FindByTitle](WindowFindByTitle.md)
- [Window.Screen](WindowScreen.md)

### Release notes

- **Version 9.0**
    - Changed [WebView.Screenshot](http://www.mbsplugins.eu/WebViewScreenshot.shtml), [Window.Screenshot](http://www.mbsplugins.eu/WindowScreenshot.shtml) and [Screenshot](http://www.mbsplugins.eu/component_Screenshot.shtml) function to mark image with resolution for Windows.
- **Version 8.5**
    - Added [WebView.Screenshot](http://www.mbsplugins.eu/WebViewScreenshot.shtml) and [Window.Screenshot](http://www.mbsplugins.eu/WindowScreenshot.shtml) for iOS.

### Example Databases

- [Window/PDF from Window (Mac)](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/PDF%20from%20Window%20%28Mac%29.shtml#2ScriptAnchor_)
- [Window/Window Screenshot](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Window%20Screenshot.shtml#1Button53.0000000414.000000084.0000000556.0000000LayoutObjectAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 8.6pr5](https://www.mbsplugins.de/archive/2018-12-23/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 8.5 - Über 5500 Funktionen in einem Plugin](https://www.mbsplugins.de/archive/2018-11-27/Neues_MBS_FileMaker_Plugin_85_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 8.5 - More than 5500 Functions In One Plugin](https://www.mbsplugins.de/archive/2018-11-27/MBS_FileMaker_Plugin_85_-_More/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.5pr5](https://www.mbsplugins.de/archive/2018-11-02/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.4pr4](https://www.mbsplugins.de/archive/2015-10-29/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 27th October 2015 , last changed 23th September 2021

  
[Window.Screen](WindowScreen.md) - [Window.Scrollbar.GetScrollElasticity](WindowScrollbarGetScrollElasticity.md)

[HTML Version](WindowScreenshot.shtml)