windows

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 39 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for windows/amd64

Overview

Package windows implements the Golet backend for Windows: Win32 windows hosting WebView2, called through the syscall package (no cgo).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestAccessibilityPerform

func TestAccessibilityPerform(hwnd uintptr, label, action, value string) bool

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

func TestActivateAccelerator(hwnd uintptr, acc string) bool

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

func TestActivateMenuItem(hwnd uintptr, path ...string) error

TestActivateMenuItem activates an item of a window's menu bar, found by the labels along its path, e.g. TestActivateMenuItem(hwnd, "File", "New").

func TestCaptionButtons

func TestCaptionButtons(hwnd uintptr) []string

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

func TestCaptionColor(hwnd uintptr, name string) (r, g, b uint8, ok bool)

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

func TestChoosePopupItem(label string) bool

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

func TestClickSurface(hwnd uintptr, x, y float64) bool

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

func TestComposeOver(hwnd uintptr, text string, caret int, commit bool, from, length int) bool

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

func TestComposed(hwnd uintptr) (noRedirect, composed bool)

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

func TestDocumentFeed(hwnd uintptr) (text string, start, length int, ok bool)

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

func TestDragFiles(hwnd uintptr, x, y float64, paths []string) (dropped bool)

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

func TestDragSurface(hwnd uintptr, points [][2]float64) bool

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

func TestDropFiles(hwnd uintptr, x, y float64, paths []string) (over, dropped bool)

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 TestEndMenu

func TestEndMenu()

TestEndMenu leaves the menus, as Escape does.

func TestEnterMenuBar

func TestEnterMenuBar(hwnd uintptr) bool

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

func TestForeground(hwnd uintptr) bool

TestForeground brings a window to the front, where the keyboard types, and reports whether it came.

func TestInputClick

func TestInputClick(hwnd uintptr, x, y float64) (ok bool, missed string)

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

func TestLoseComposition(removed bool) bool

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 TestMenuBarColors

func TestMenuBarColors(hwnd uintptr) (bar, line uint32, ok bool)

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

func TestMenuBarShown(hwnd uintptr) bool

TestMenuBarShown reports whether a window shows its menu bar.

func TestPanelStyles

func TestPanelStyles(hwnd uintptr) (tool, topmost, owned bool)

TestPanelStyles reports whether a window is a topmost tool window without a window menu, owned by the hidden application window, as panels are.

func TestPopups

func TestPopups() [][]string

TestPopups returns the labels of the items of the popup menus the main thread shows, "-" for separators.

func TestPressCaptionButton

func TestPressCaptionButton(hwnd uintptr, name string) bool

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

func TestRightClickSurface(hwnd uintptr, x, y float64) bool

TestRightClickSurface clicks (x, y), in DIPs, in a window showing native UI with the secondary button, as TestClickSurface does with the primary.

func TestSetDroppedFiles

func TestSetDroppedFiles(hwnd uintptr, paths []string)

TestSetDroppedFiles makes paths the files of the next drop on a window's page, as if they had been dragged there.

func TestSideButton

func TestSideButton(hwnd uintptr, back bool) bool

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 TestSurfacePixel

func TestSurfacePixel(hwnd uintptr, x, y float64) (r, g, b uint8, ok bool)

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

func TestTopNonClient(hwnd uintptr) (px, want int32)

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

func TestWindowTitle(hwnd uintptr) string

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 New

func New() *Backend

New creates the Windows 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) Clipboard

func (b *Backend) Clipboard() platform.Clipboard

func (*Backend) Dialogs

func (b *Backend) Dialogs() platform.Dialogs

func (*Backend) Init

func (*Backend) IsMainThread

func (b *Backend) IsMainThread() bool

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) Network

func (b *Backend) Network() platform.Network

func (*Backend) NewFileWatch

func (*Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)

func (*Backend) NewTray

func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)

func (*Backend) NewWindow

func (*Backend) NotificationsSupported

func (b *Backend) NotificationsSupported() bool

func (*Backend) PopupMenu

func (b *Backend) PopupMenu(m *platform.Menu, pw platform.Window, pos *platform.Point)

func (*Backend) Power

func (b *Backend) Power() platform.Power

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) RegisterHotkey

func (b *Backend) RegisterHotkey(id int, acc string) error

func (*Backend) RemoveAllNotifications

func (b *Backend) RemoveAllNotifications()

func (*Backend) RemoveNotification

func (b *Backend) RemoveNotification(id string)

func (*Backend) ReplaceFile

func (*Backend) ReplaceFile(target, replacement string) error

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) Run

func (b *Backend) Run() error

func (*Backend) Screen

func (b *Backend) Screen() platform.Screen

func (*Backend) Secrets

func (b *Backend) Secrets() platform.Secrets

func (*Backend) SetApplicationMenu

func (b *Backend) SetApplicationMenu(m *platform.Menu)

func (*Backend) Shell

func (b *Backend) Shell() platform.Shell

func (*Backend) ShowNotification

func (b *Backend) ShowNotification(n *platform.Notification, done func(error))

func (*Backend) Signal

func (b *Backend) Signal()

func (*Backend) Step

func (b *Backend) Step()

func (*Backend) Theme

func (b *Backend) Theme() platform.Theme

func (*Backend) UnregisterHotkey

func (b *Backend) UnregisterHotkey(id int)

func (*Backend) UpdateMenuItem

func (b *Backend) UpdateMenuItem(it *platform.MenuItem)

func (*Backend) Wake

func (b *Backend) Wake()

func (*Backend) WebViewAvailable

func (b *Backend) WebViewAvailable() bool

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 GUID

type GUID struct {
	Data1 uint32
	Data2 uint16
	Data3 uint16
	Data4 [8]byte
}

GUID is a COM interface or class identifier.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL