Window

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

Up and coming

Open a real desktop window from code: give it a title and a menu bar, ask before it closes, and have it come back where you left it.

A Window shows while it is in your program's tree, from the start of the run or from when code parents one in; with Parent nil it hides and stays alive. Sizes are in logical pixels, and SizeChanged is the one resize hook, where a scripted layout starts. A confirm box and the Windows file and folder pickers are ready-made on every Window. Once your code has returned and nothing else is running, closing the last window ends the run.

Made with Instance.new("Window") or Clone().

Passes shot check todayLuau
local function example(x : Window)
	local window = Instance.new("Window")
	window.Title = "Manager"
	window.SizeChanged:Connect(function(size : Vector2)
		print(size.X)
	end)
end

Properties

NameTypeDefaultDescription
Titlestring
IconIcon?The picture in the title bar and on the taskbar button.
SizeVector2The inside of the window in logical pixels; resizing the window by hand changes it too.
MinSizeVector2The system stops a resize at this size, so your scripted layout has a floor.
PositionVector2?Where the window sits on the desktop, in logical pixels; nil centres it on the main monitor.
State"Normal" | "Maximized" | "Minimized"
Resizableboolean
AlwaysOnTopboolean
BackgroundColorColor3Near-white by default: windows are light mode.
SaveKeystring?Remembers the size, position and state for each user under this name and restores them on the next run.
DpiScalenumberread-only1.5 at 150% scaling; everything is in logical pixels, and text is redrawn sharp when the window moves to another monitor.
Focusedbooleanread-only
FocusedObjectUIObject?read-onlyThe TextBox or Button that has the keyboard; Tab and Shift+Tab move it through them in tree order.
MousePositionVector2read-onlyThe pointer's position, in window coordinates.

Methods

NameArgumentsReturnsDescription
Focus()()Brings the window to the front; Windows may flash its taskbar button instead.
Flash()()Flashes the window's taskbar button until you look at it.
Notify(text: string, color: Color3?, seconds: number?)()Shows a toast that slides in at the bottom and fades out.
Close()()Closes the window, as Destroy does; setting Parent to nil only hides it, and putting it back shows it again.
IsKeyDown(key: KeyCode)boolean
SetClipboard(text: string)()
GetClipboardAsync
yields
()string
ConfirmAsync
yields
(title: string, text: string, buttons: { string })string?Shows a confirm box drawn in the window's own look and waits for a button; Enter picks the first, Escape gives nil.
PickFolderAsync
yields
(title: string?, start: string?)string?Opens the Windows folder picker and waits for the pick.
PickFilesAsync
yields
(filters: { [string]: string }?, multiple: boolean?){ string }Opens the Windows file picker and waits for the pick; filters look like {Images = "png;jpg"}.
PickSaveFileAsync
yields
(name: string?, filters: { [string]: string }?)string?Opens the Windows picker for a file to save and waits for the pick.

Events

NamePassesDescription
SizeChanged(Vector2)Fires with the new size; the one resize hook, where a scripted layout starts, with no size listeners on each element.
CloseRequested()While connected, the window stays open until your code calls Close, so it can ask first; with nothing connected, it closes.
Closed()
FocusChanged(boolean)
DpiChanged(number)
InputBegan(InputObject)Fires for keys and buttons anywhere in the window, after the focused control has had them.
InputEnded(InputObject)
FilesDropped({ string }, Vector2)Fires when files dragged in from File Explorer land on no DropTarget, passing their paths and where they landed.
From ScreenItem 2
From ShotInstance 33

Subclasses