Documentation
¶
Overview ¶
Package windows implements the Golet backend for Windows: Win32 windows hosting WebView2, called through the syscall package (no cgo).
Index ¶
- func LinkContentRules()
- func LinkContextMenus()
- func LinkMenuIcons()
- func LinkNowPlaying()
- func TestAccessibilityPerform(hwnd uintptr, label, action, value string) bool
- func TestActivateAccelerator(hwnd uintptr, acc string) bool
- func TestActivateMenuItem(hwnd uintptr, path ...string) error
- func TestBackgroundThrottlingOff(hwnd uintptr, webView bool) (off bool, settings int)
- func TestBrowserAcceleratorKeys(hwnd uintptr) (on, ok bool)
- func TestCanCompose() bool
- func TestCaptionButtons(hwnd uintptr) []string
- func TestCaptionColor(hwnd uintptr, name string) (r, g, b uint8, ok bool)
- func TestChoosePageMenuItem(label string) bool
- func TestChoosePopupItem(label string) bool
- func TestClickSurface(hwnd uintptr, x, y float64) bool
- func TestCloaked(hwnd uintptr) (cloaked, drawn bool)
- func TestComposeOver(hwnd uintptr, text string, caret int, commit bool, from, length int) bool
- func TestComposed(hwnd uintptr) (noRedirect, composed bool)
- func TestDocumentFeed(hwnd uintptr) (text string, start, length int, ok bool)
- func TestDragFiles(hwnd uintptr, x, y float64, paths []string) (dropped bool)
- func TestDragSurface(hwnd uintptr, points [][2]float64) bool
- func TestDropData(hwnd uintptr, x, y float64, d transfer.Data, ops transfer.Operation) (operation transfer.Operation, dropped bool)
- func TestDropFiles(hwnd uintptr, x, y float64, paths []string) (over, dropped bool)
- func TestEndMenu()
- func TestEnterMenuBar(hwnd uintptr) bool
- func TestFailWebViews(n int)
- func TestForeground(hwnd uintptr) bool
- func TestGDIObjects() int
- func TestHitTest(hwnd uintptr, x, y int32) uintptr
- func TestInputClick(hwnd uintptr, x, y float64) (ok bool, missed string)
- func TestLoseComposition(removed bool) bool
- func TestMaximizeButton(hwnd uintptr, press bool) uintptr
- func TestMaximizedRects(hwnd uintptr) (window, shown, client, monitor, work [4]int32, zoomed bool)
- func TestMenuBarColors(hwnd uintptr) (bar, line uint32, ok bool)
- func TestMenuBarShown(hwnd uintptr) bool
- func TestMenuItemEnabled(hwnd uintptr, path ...string) (bool, error)
- func TestMenuItemIcon(hwnd uintptr, path ...string) (width, height int, checked bool, err error)
- func TestPageGestures(hwnd uintptr, webView int) (swipe, pinch, ok bool)
- func TestPageMenu() ([]string, bool)
- func TestPanelStyles(hwnd uintptr) (tool, topmost, owned bool)
- func TestPinchSurface(hwnd uintptr, x, y, scale float64) (float64, bool)
- func TestPopupItemEnabled(label string) (enabled, ok bool)
- func TestPopups() [][]string
- func TestPressCaptionButton(hwnd uintptr, name string) bool
- func TestPressKeys(keys ...byte)
- func TestRecentDocuments() []string
- func TestRightClickPage(hwnd uintptr, x, y float64) bool
- func TestRightClickSurface(hwnd uintptr, x, y float64) bool
- func TestSetDroppedFiles(hwnd uintptr, paths []string)
- func TestSideButton(hwnd uintptr, back bool) bool
- func TestSurfaceKey(hwnd uintptr, vk byte, mods ...byte) bool
- func TestSurfacePixel(hwnd uintptr, x, y float64) (r, g, b uint8, ok bool)
- func TestTopNonClient(hwnd uintptr) (px, want int32)
- func TestUndrawnCloaked() (n int, cloaked bool)
- func TestWheelSurface(hwnd uintptr, x, y float64) bool
- func TestWindowEdges(hwnd uintptr) (edges [4][3]uint8, in int32, ok bool)
- func TestWindowPixelsUnderSurface(hwnd uintptr) (off string, ok bool)
- func TestWindowTitle(hwnd uintptr) string
- type Backend
- func (b *Backend) App() platform.AppController
- func (b *Backend) Applications() ([]platform.Application, error)
- func (b *Backend) Clipboard() platform.Clipboard
- func (b *Backend) Dialogs() platform.Dialogs
- func (b *Backend) Init(h platform.AppHandler, opts platform.AppOptions) error
- func (b *Backend) IsMainThread() bool
- func (b *Backend) Name() string
- func (b *Backend) Network() platform.Network
- func (*Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)
- func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)
- func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
- func (b *Backend) NotificationsSupported() bool
- func (b *Backend) NowPlaying() platform.NowPlaying
- func (b *Backend) PopupMenu(m *platform.Menu, pw platform.Window, pos *platform.Point)
- func (b *Backend) Power() platform.Power
- func (b *Backend) Quit()
- func (b *Backend) RegisterHotkey(id int, acc string) error
- func (b *Backend) RemoveAllNotifications()
- func (b *Backend) RemoveNotification(id string)
- func (*Backend) ReplaceFile(target, replacement string) error
- func (b *Backend) Run() error
- func (b *Backend) Screen() platform.Screen
- func (b *Backend) Secrets() platform.Secrets
- func (b *Backend) SetApplicationMenu(m *platform.Menu)
- func (b *Backend) Shell() platform.Shell
- func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
- func (b *Backend) Signal()
- func (b *Backend) Step()
- func (b *Backend) Theme() platform.Theme
- func (b *Backend) UnregisterHotkey(id int)
- func (b *Backend) UpdateMenuItem(it *platform.MenuItem)
- func (b *Backend) Wake()
- func (b *Backend) WebViewAvailable() bool
- type GUID
- type PopupItemWidth
- type TestAccessNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LinkContentRules ¶ added in v0.1.8
func LinkContentRules()
LinkContentRules links the code of content rules, when the app first compiles rules.
func LinkContextMenus ¶ added in v0.1.13
func LinkContextMenus()
LinkContextMenus links the code of pages' context menus, when the app first listens to them (Page.OnContextMenu).
func LinkMenuIcons ¶ added in v0.1.13
func LinkMenuIcons()
LinkMenuIcons links the code of the icons of menu items, when the app first gives an item one.
func LinkNowPlaying ¶ added in v0.1.13
func LinkNowPlaying()
LinkNowPlaying links the code of NowPlaying, when the app first shows what it plays.
func TestAccessibilityPerform ¶
TestAccessibilityPerform acts on the element labeled label as UI Automation's clients do: "press", "increment", "decrement", "focus", or "value" to set its text to value. It reports whether the element can.
func TestActivateAccelerator ¶
TestActivateAccelerator runs the menu item of a window's shortcut, as its keys do in the page, and reports whether there is one.
func TestActivateMenuItem ¶
TestActivateMenuItem activates an item of a window's menu bar, found by the labels along its path, e.g. TestActivateMenuItem(hwnd, "File", "New"). plugins/automation's menu request chooses items with it too.
func TestBackgroundThrottlingOff ¶ added in v0.1.13
TestBackgroundThrottlingOff reports whether the page of a window, or of its first web view, keeps running while it can't be seen: WebView2's browser runs with unthrottledArguments, the one setting, which all pages share.
func TestBrowserAcceleratorKeys ¶ added in v0.1.8
TestBrowserAcceleratorKeys reports whether WebView2's own keys (F5 and Ctrl+R reloading, Ctrl+P printing, ...) work in a window's page; ok is false without a web view or a runtime with ICoreWebView2Settings3.
func TestCanCompose ¶ added in v0.1.13
func TestCanCompose() bool
TestCanCompose reports whether DirectComposition is available, which windows without a redirection bitmap need.
func TestCaptionButtons ¶
TestCaptionButtons returns the window controls of a window with a hidden title bar, left to right, named after what WM_NCHITTEST answers over their middles, which Windows' snap layouts rely on.
func TestCaptionColor ¶
TestCaptionColor puts the pointer over a window control of a hidden title bar, "minimize", "maximize" or "close", as far as the control knows, and returns the color on the screen beside its glyph once Windows has composed it: what the user sees, through UpdateLayeredWindow or DirectComposition. The pointer leaves after.
func TestChoosePageMenuItem ¶ added in v0.1.13
TestChoosePageMenuItem chooses the item labeled label, without its mnemonic's ampersand, of that menu, and reports whether it has one.
func TestChoosePopupItem ¶
TestChoosePopupItem chooses the item labeled label of a popup menu the main thread shows, with the keys a keyboard presses in it, and reports whether there is one.
func TestClickSurface ¶
TestClickSurface clicks (x, y), in DIPs, in a window showing native UI, with the messages a mouse sends. It reports false for a window showing a web page.
func TestCloaked ¶ added in v0.1.15
TestCloaked reports whether DWM keeps the window hwnd out of sight (DWMWA_CLOAKED), and whether the first frame of its native UI reached its surface.
func TestComposeOver ¶
TestComposeOver does what an input method that converts typed text again does: unless from is -1, it settles the reconversion of length runes from rune from of the text around the caret; then it composes text with the caret at caret, or commits it.
func TestComposed ¶
TestComposed reports whether a window has no redirection bitmap, for the material behind its page, and whether the controls of its hidden title bar show through the DirectComposition device in use.
func TestDocumentFeed ¶
TestDocumentFeed returns the text around the caret that input methods get from a window showing native UI with IMR_DOCUMENTFEED, and the selection in it, in runes.
func TestDragFiles ¶
TestDragFiles drags files from another application to (x, y), in DIPs, of a window showing native UI and drops them there, as OLE does: through the window's drop target, with the production IDataObject, asking the target again while the window runs until it takes them, as the page of a web view answers later, for a few seconds. It reports whether the drop took them.
func TestDragSurface ¶
TestDragSurface presses the primary button at the first of points, in DIPs, in a window showing native UI, moves the pointer through the others, and releases it at the last, with the messages a mouse sends.
func TestDropData ¶
func TestDropData(hwnd uintptr, x, y float64, d transfer.Data, ops transfer.Operation) (operation transfer.Operation, dropped bool)
TestDropData uses the production IDataObject and OLE destination with no process-local token, exercising serialized data and delayed rendering.
func TestDropFiles ¶
TestDropFiles drags files from Explorer to (x, y), in DIPs, of a window showing native UI and drops them there, through its drop target, and reports whether the content took them over there and when dropped.
func TestEnterMenuBar ¶
TestEnterMenuBar takes the keyboard to a window's menu bar, as Alt and F10 do, and returns once it leaves the menus. It reports false when the window cannot come to the front, which the keyboard needs.
func TestFailWebViews ¶
func TestFailWebViews(n int)
TestFailWebViews makes the next n creations of webviews fail, as WebView2 reports a failure, when it would have created them; 0 lets them be.
func TestForeground ¶
TestForeground brings a window to the front, where the keyboard types, and reports whether it came.
func TestGDIObjects ¶ added in v0.1.13
func TestGDIObjects() int
TestGDIObjects returns how many GDI objects the process holds, which a menu's bitmaps count in.
func TestHitTest ¶ added in v0.1.13
TestHitTest reports what Windows' hit test answers at a point of a window, in pixels from the top-left of its client area (negative from the right or the bottom): the answer of the topmost visible window there, the top edge above the webview or the surface, or the window itself.
func TestInputClick ¶
TestInputClick clicks a point of a window showing native UI with the system's input, as a mouse does: the window it lands on activates as for the user. The system delivers the click later, through the thread's queue: TestInputClick handles the messages that come until the release reaches a window of the app, so that the app handled the click when it returns. It reports false for a window showing a web page, and when no release came in 10 seconds, missed describes the window under the point, which took the click.
func TestLoseComposition ¶
TestLoseComposition takes the DirectComposition device away, as a draw that finds it invalid does, or, with removed, signals that its GPU device was removed. It reports false without a device, or, with removed, without the event (Windows 10 before 1607).
func TestMaximizeButton ¶ added in v0.1.8
TestMaximizeButton reports what Windows' hit test answers in the middle of the maximize button the content draws (SetMaximizeButton), and, when press, presses and releases it there as the mouse does: with the non-client messages that a window answering HTMAXBUTTON gets. It reports 0 when no window is over the button.
func TestMaximizedRects ¶ added in v0.1.13
TestMaximizedRects returns, in pixels, a window's rectangle, the part of it DWM shows (without its invisible borders), its client area on the screen, and the monitor and work area it is on, and whether it is zoomed.
func TestMenuBarColors ¶
TestMenuBarColors draws a window as it shows and returns the colors, as COLORREFs, of its menu bar past the last item and of the line below it.
func TestMenuBarShown ¶
TestMenuBarShown reports whether a window shows its menu bar.
func TestMenuItemEnabled ¶ added in v0.1.15
TestMenuItemEnabled reports whether an item of a window's menu bar, found as TestActivateMenuItem finds it, is enabled once its menu opens.
func TestMenuItemIcon ¶ added in v0.1.13
TestMenuItemIcon reports the size, in DIPs, of the icon an item of a window's menu bar shows, 0 by 0 for none, and whether it is checked.
func TestPageGestures ¶ added in v0.1.13
TestPageGestures reports whether a swipe navigates and a pinch zooms the page of a window, or with webView 0 or more, of its web view of that index, as its WebView2 settings say. ok is false without that page's web view or a runtime with ICoreWebView2Settings6.
func TestPageMenu ¶ added in v0.1.13
TestPageMenu returns the labels of the items of the popup menu the main thread shows, without their mnemonics' ampersands, "-" for separators, and false when it shows none: a page's context menu Golet draws. The menu WebView2 draws itself is not Golet's to read.
func TestPanelStyles ¶
TestPanelStyles reports whether a window is a topmost tool window without a window menu, owned by the hidden application window, as panels are.
func TestPinchSurface ¶ added in v0.1.8
TestPinchSurface pinches a touchpad at (x, y), in DIPs, in a window showing native UI, by scale, with the message Windows sends for it: the wheel with Ctrl held, by less than a notch at a time. It reports the scale the message makes, which rounds scale to a 360th of a doubling.
func TestPopupItemEnabled ¶ added in v0.1.15
TestPopupItemEnabled reports whether the item labeled label of a popup menu the main thread shows is enabled, and whether there is one.
func TestPopups ¶
func TestPopups() [][]string
TestPopups returns the labels of the items of the popup menus the main thread shows, "-" for separators.
func TestPressCaptionButton ¶
TestPressCaptionButton clicks a window control of a window with a hidden title bar: "minimize", "maximize" or "close".
func TestPressKeys ¶
func TestPressKeys(keys ...byte)
TestPressKeys presses virtual keys together and releases them, like a keyboard would.
func TestRecentDocuments ¶
func TestRecentDocuments() []string
TestRecentDocuments returns the paths in the Recent category of the app's jump list, newest first.
func TestRightClickPage ¶ added in v0.1.13
TestRightClickPage right-clicks (x, y), in CSS pixels, in the page of a window's web view, with the mouse events of the DevTools protocol, as a mouse does. The page's context menu opens later. It reports false for a window without a web view.
func TestRightClickSurface ¶
TestRightClickSurface clicks (x, y), in DIPs, in a window showing native UI with the secondary button, as TestClickSurface does with the primary.
func TestSetDroppedFiles ¶
TestSetDroppedFiles makes paths the files of the next drop on a window's page, as if they had been dragged there.
func TestSideButton ¶
TestSideButton clicks a mouse's back or forward button (XBUTTON1 and XBUTTON2) in a window showing native UI, with the messages a mouse sends.
func TestSurfaceKey ¶ added in v0.1.8
TestSurfaceKey presses and releases a key in a window showing native UI, with the modifiers held, as the thread's keyboard state tells them while it handles the messages: the window needs not be in front.
func TestSurfacePixel ¶
TestSurfacePixel returns the color the screen shows at (x, y), in DIPs, in a window showing native UI, once what was drawn shows: there, in a window without a redirection bitmap, the frames over the material.
func TestTopNonClient ¶
TestTopNonClient returns how many pixels at the top of a window are not its client area, and how many a hidden title bar keeps there on this version of Windows: one on Windows 11, none on Windows 10.
func TestUndrawnCloaked ¶ added in v0.1.15
TestUndrawnCloaked reports how many windows of native UI have not had their first frame reach their surface, and whether DWM keeps all of them out of sight: a window's first frame may build while NewWindow creates it, before a test has its handle.
func TestWheelSurface ¶ added in v0.1.15
TestWheelSurface turns a mouse's wheel a notch down at (x, y), in DIPs, in a window showing native UI, with the message Windows sends for it, over whatever shows there: the content, or a web view's page.
func TestWindowEdges ¶ added in v0.1.15
TestWindowEdges returns the colors the screen shows at the middle of the window's left, top, right and bottom edges, on the outermost pixels of what DWM shows of it (DWMWA_EXTENDED_FRAME_BOUNDS, within the invisible borders), inset by in pixels: on Windows 11, the thickness of the border DWM draws there (DWMWA_VISIBLE_FRAME_BORDER_THICKNESS), so the colors are the content's just inside it. ok is false when they cannot be read.
func TestWindowPixelsUnderSurface ¶ added in v0.1.14
TestWindowPixelsUnderSurface reads the window's own pixels (its redirection bitmap) across its client area, under the surface showing native UI too, which DWM shows where the surface shrinks before the window does (fillUnder), and returns the first that is not the content's background, as "(x, y) is #rrggbb", or "" when all are. ok is false when it cannot tell: the content has no opaque background yet, the window has no pixels of its own, or the frames are drawn into them (GDI).
func TestWindowTitle ¶
TestWindowTitle returns the text of a window's title bar.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is the Windows (Win32 + WebView2) implementation of platform.Backend.
func (*Backend) App ¶
func (b *Backend) App() platform.AppController
func (*Backend) Applications ¶
func (b *Backend) Applications() ([]platform.Application, error)
Applications lists the apps of the Start menu's All apps list, the shell's Applications folder (FOLDERID_AppsFolder): desktop apps by their shortcuts and packaged apps alike, as PowerToys' Command Palette lists them. An app's ID is its AppUserModelID, or for a desktop app without one, its path under a known folder; its Path is the shell item, shell:AppsFolder\<ID>, which FileIcon draws and OpenApplication starts. It runs on a thread of its own, in its own COM apartment.
func (*Backend) Init ¶
func (b *Backend) Init(h platform.AppHandler, opts platform.AppOptions) error
func (*Backend) IsMainThread ¶
func (*Backend) NewFileWatch ¶
func (*Backend) NewWindow ¶
func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
func (*Backend) NotificationsSupported ¶
func (*Backend) NowPlaying ¶ added in v0.1.13
func (b *Backend) NowPlaying() platform.NowPlaying
func (*Backend) Quit ¶
func (b *Backend) Quit()
Quit ends the event loop. Modal loops (dialogs, menus) end too: they forward WM_QUIT to the loop they run in.
func (*Backend) RemoveAllNotifications ¶
func (b *Backend) RemoveAllNotifications()
func (*Backend) RemoveNotification ¶
func (*Backend) ReplaceFile ¶
ReplaceFile replaces target with ReplaceFileW, which keeps the target's security descriptor, attributes, alternate data streams and creation time, as Office and NSDocument's replacement do. Another program holding the target open without sharing deletes (an indexer, an antivirus, a cloud client) gets a moment to let go.
func (*Backend) SetApplicationMenu ¶
func (*Backend) ShowNotification ¶
func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
func (*Backend) UnregisterHotkey ¶
func (*Backend) UpdateMenuItem ¶
func (*Backend) WebViewAvailable ¶
WebViewAvailable reports whether a window showing a web page can have one: the WebView2 Runtime is installed, or a loader next to the executable loads a fixed version runtime or the installed one itself. It starts nothing; once a window showing a page created the environment, it says whether that worked. It reads the registry and the disk only, so any goroutine may call it, before Init too.
type PopupItemWidth ¶ added in v0.1.15
PopupItemWidth is how wide an item Golet draws of a popup menu shows, and how wide it needs to be for all it draws, in pixels.
func TestPopupItemWidths ¶ added in v0.1.15
func TestPopupItemWidths(hwnd uintptr) (items []PopupItemWidth, known bool)
TestPopupItemWidths returns the widths of the items Golet draws of the popup menus the main thread shows for a window, but separators: none where Windows draws them (Windows 10). known is whether Golet knows, from items drawn, how much Windows widens them at the window's DPI.
type TestAccessNode ¶
type TestAccessNode struct {
Role, Label, Value string
// contains filtered or unexported fields
}
TestAccessNode is an element of native UI as UI Automation reads it: the name of its control type, its name, and its value.
func TestAccessibility ¶
func TestAccessibility(hwnd uintptr) ([]TestAccessNode, bool)
TestAccessibility reads the elements of a window showing native UI as UI Automation's clients do, in order, and reports false when it cannot.
Source Files
¶
- abi_amd64.go
- app.go
- apps.go
- auth.go
- clipboard.go
- com.go
- compositor.go
- content_rules.go
- context_menu.go
- cookies.go
- darkmenu.go
- deeplink.go
- dialog.go
- flyout.go
- icon.go
- jumplist.go
- locale.go
- login.go
- menu.go
- menudraw.go
- menuicon.go
- network.go
- nowplaying.go
- power.go
- registry.go
- replace.go
- secrets.go
- session.go
- surface.go
- surface_access.go
- surface_drag.go
- surface_drop.go
- surface_input.go
- system.go
- taskbar.go
- testhooks.go
- testhooks_surface.go
- titlebar.go
- topedge.go
- trash.go
- tray.go
- uia_text.go
- watch.go
- webview.go
- webview2.go
- webview2_options.go
- webview_embed.go
- win32.go
- window.go