WindowAPI
WindowAPI (JavaScript) Documentation
The WindowAPI
provides various methods to interact with a window in the Pyloid application. Each method is available through JavaScript using window.pyloid.WindowAPI
and can be called with await
for asynchronous operation or as a Promise. Below is a detailed overview of each method available through this API.
Usage
To use any method in the WindowAPI
, simply call it using window.pyloid.WindowAPI.<methodName>()
. Most methods return a Promise and can be used with await
for synchronous-like behavior in an asynchronous environment.
1. getWindowId()
getWindowId()
Description: Returns the current window's ID.
Returns:
Promise<string>
- The window ID as a string.
Usage:
2. close()
close()
Description: Closes the current window.
Returns:
Promise<void>
Usage:
3. hide()
hide()
Description: Hides the current window.
Returns:
Promise<void>
Usage:
4. show()
show()
Description: Shows and focuses the current window.
Returns:
Promise<void>
Usage:
5. focus()
focus()
Description: Focuses the current window.
Returns:
Promise<void>
Usage:
6. showAndFocus()
showAndFocus()
Description: Shows and focuses the current window.
Returns:
Promise<void>
Usage:
7. fullscreen()
fullscreen()
Description: Enables fullscreen mode for the current window.
Returns:
Promise<void>
Usage:
8. toggleFullscreen()
toggleFullscreen()
Description: Toggles fullscreen mode for the current window.
Returns:
Promise<void>
Usage:
9. minimize()
minimize()
Description: Minimizes the current window.
Returns:
Promise<void>
Usage:
10. maximize()
maximize()
Description: Maximizes the current window.
Returns:
Promise<void>
Usage:
11. unmaximize()
unmaximize()
Description: Restores the window to its normal state.
Returns:
Promise<void>
Usage:
12. toggleMaximize()
toggleMaximize()
Description: Toggles the maximize state of the current window.
Returns:
Promise<void>
Usage:
13. isFullscreen()
isFullscreen()
Description: Checks if the current window is in fullscreen mode.
Returns:
Promise<boolean>
-true
if fullscreen, otherwisefalse
.
Usage:
14. isMaximized()
isMaximized()
Description: Checks if the current window is maximized.
Returns:
Promise<boolean>
-true
if maximized, otherwisefalse
.
Usage:
15. setTitle(title: string)
setTitle(title: string)
Description: Sets the title of the window.
Parameters:
title
(string
): The title to set for the window.
Returns:
Promise<void>
Usage:
16. setSize(width: number, height: number)
setSize(width: number, height: number)
Description: Sets the size of the window.
Parameters:
width
(number
): The desired width of the window.height
(number
): The desired height of the window.
Returns:
Promise<void>
Usage:
17. setPosition(x: number, y: number)
setPosition(x: number, y: number)
Description: Sets the position of the window.
Parameters:
x
(number
): The x-coordinate for the window position.y
(number
): The y-coordinate for the window position.
Returns:
Promise<void>
Usage:
18. setFrame(frame: boolean)
setFrame(frame: boolean)
Description: Sets the frame of the window (e.g., window border).
Parameters:
frame
(boolean
):true
to show the frame,false
to hide it.
Returns:
Promise<void>
Usage:
19. setContextMenu(contextMenu: boolean)
setContextMenu(contextMenu: boolean)
Description: Sets the context menu visibility for the window.
Parameters:
contextMenu
(boolean
):true
to enable the context menu,false
to disable it.
Returns:
Promise<void>
Usage:
20. setDevTools(enable: boolean)
setDevTools(enable: boolean)
Description: Enables or disables the developer tools for the window. Additionally, it allows or disallows opening the developer tools using the
F12
key.Parameters:
enable
(boolean
):true
to enable dev tools and allow opening withF12
.false
to disable dev tools and prevent opening withF12
.
Returns:
Promise<void>
Usage:
21. capture(savePath: string)
capture(savePath: string)
Description: Captures the current window's view and saves it to the specified path.
Parameters:
savePath
(string
): The file path where the captured image should be saved.
Returns:
Promise<string | null>
- The file path if successful, otherwisenull
.
Usage:
Notes
All methods return a
Promise
, allowing them to be used withawait
in asynchronous functions.Use these APIs responsibly, as some actions (e.g., closing or minimizing the window) can affect the user experience.
Last updated