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 TestAccessibilityPerform(hwnd uintptr, label, action, value string) bool
- func TestActivateAccelerator(hwnd uintptr, acc string) bool
- func TestActivateMenuItem(hwnd uintptr, path ...string) error
- func TestBrowserAcceleratorKeys(hwnd uintptr) (on, ok bool)
- func TestCaptionButtons(hwnd uintptr) []string
- func TestCaptionColor(hwnd uintptr, name string) (r, g, b uint8, ok bool)
- func TestChoosePopupItem(label string) bool
- func TestClickSurface(hwnd uintptr, x, y float64) 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 TestInputClick(hwnd uintptr, x, y float64) (ok bool, missed string)
- func TestLoseComposition(removed bool) bool
- func TestMaximizeButton(hwnd uintptr, press bool) uintptr
- func TestMenuBarColors(hwnd uintptr) (bar, line uint32, ok bool)
- func TestMenuBarShown(hwnd uintptr) bool
- func TestPanelStyles(hwnd uintptr) (tool, topmost, owned bool)
- func TestPinchSurface(hwnd uintptr, x, y, scale float64) (float64, bool)
- func TestPopups() [][]string
- func TestPressCaptionButton(hwnd uintptr, name string) bool
- func TestPressKeys(keys ...byte)
- func TestRecentDocuments() []string
- 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 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) 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 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 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").
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 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 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 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 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 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 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 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 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 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) 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 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
- clipboard.go
- com.go
- compositor.go
- content_rules.go
- cookies.go
- darkmenu.go
- deeplink.go
- dialog.go
- flyout.go
- icon.go
- jumplist.go
- locale.go
- login.go
- menu.go
- menudraw.go
- network.go
- power.go
- registry.go
- replace.go
- secrets.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
- trash.go
- tray.go
- uia_text.go
- watch.go
- webview.go
- webview2.go
- webview2_options.go
- webview_embed.go
- win32.go
- window.go