go-tg-screenshot-bot
420 строк · 16.0 Кб
1// Copyright 2010 The win Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build windows
6
7package win8
9import (10"syscall"11"unsafe"12)
13
14type AnnoScope int15
16const (17ANNO_THIS = AnnoScope(0)18ANNO_CONTAINER = AnnoScope(1)19)
20
21type MSAAPROPID syscall.GUID22
23var (24PROPID_ACC_NAME = MSAAPROPID{0x608d3df8, 0x8128, 0x4aa7, [8]byte{0xa4, 0x28, 0xf5, 0x5e, 0x49, 0x26, 0x72, 0x91}}25PROPID_ACC_VALUE = MSAAPROPID{0x123fe443, 0x211a, 0x4615, [8]byte{0x95, 0x27, 0xc4, 0x5a, 0x7e, 0x93, 0x71, 0x7a}}26PROPID_ACC_DESCRIPTION = MSAAPROPID{0x4d48dfe4, 0xbd3f, 0x491f, [8]byte{0xa6, 0x48, 0x49, 0x2d, 0x6f, 0x20, 0xc5, 0x88}}27PROPID_ACC_ROLE = MSAAPROPID{0xcb905ff2, 0x7bd1, 0x4c05, [8]byte{0xb3, 0xc8, 0xe6, 0xc2, 0x41, 0x36, 0x4d, 0x70}}28PROPID_ACC_STATE = MSAAPROPID{0xa8d4d5b0, 0x0a21, 0x42d0, [8]byte{0xa5, 0xc0, 0x51, 0x4e, 0x98, 0x4f, 0x45, 0x7b}}29PROPID_ACC_HELP = MSAAPROPID{0xc831e11f, 0x44db, 0x4a99, [8]byte{0x97, 0x68, 0xcb, 0x8f, 0x97, 0x8b, 0x72, 0x31}}30PROPID_ACC_KEYBOARDSHORTCUT = MSAAPROPID{0x7d9bceee, 0x7d1e, 0x4979, [8]byte{0x93, 0x82, 0x51, 0x80, 0xf4, 0x17, 0x2c, 0x34}}31PROPID_ACC_DEFAULTACTION = MSAAPROPID{0x180c072b, 0xc27f, 0x43c7, [8]byte{0x99, 0x22, 0xf6, 0x35, 0x62, 0xa4, 0x63, 0x2b}}32PROPID_ACC_HELPTOPIC = MSAAPROPID{0x787d1379, 0x8ede, 0x440b, [8]byte{0x8a, 0xec, 0x11, 0xf7, 0xbf, 0x90, 0x30, 0xb3}}33PROPID_ACC_FOCUS = MSAAPROPID{0x6eb335df, 0x1c29, 0x4127, [8]byte{0xb1, 0x2c, 0xde, 0xe9, 0xfd, 0x15, 0x7f, 0x2b}}34PROPID_ACC_SELECTION = MSAAPROPID{0xb99d073c, 0xd731, 0x405b, [8]byte{0x90, 0x61, 0xd9, 0x5e, 0x8f, 0x84, 0x29, 0x84}}35PROPID_ACC_PARENT = MSAAPROPID{0x474c22b6, 0xffc2, 0x467a, [8]byte{0xb1, 0xb5, 0xe9, 0x58, 0xb4, 0x65, 0x73, 0x30}}36PROPID_ACC_NAV_UP = MSAAPROPID{0x016e1a2b, 0x1a4e, 0x4767, [8]byte{0x86, 0x12, 0x33, 0x86, 0xf6, 0x69, 0x35, 0xec}}37PROPID_ACC_NAV_DOWN = MSAAPROPID{0x031670ed, 0x3cdf, 0x48d2, [8]byte{0x96, 0x13, 0x13, 0x8f, 0x2d, 0xd8, 0xa6, 0x68}}38PROPID_ACC_NAV_LEFT = MSAAPROPID{0x228086cb, 0x82f1, 0x4a39, [8]byte{0x87, 0x05, 0xdc, 0xdc, 0x0f, 0xff, 0x92, 0xf5}}39PROPID_ACC_NAV_RIGHT = MSAAPROPID{0xcd211d9f, 0xe1cb, 0x4fe5, [8]byte{0xa7, 0x7c, 0x92, 0x0b, 0x88, 0x4d, 0x09, 0x5b}}40PROPID_ACC_NAV_PREV = MSAAPROPID{0x776d3891, 0xc73b, 0x4480, [8]byte{0xb3, 0xf6, 0x07, 0x6a, 0x16, 0xa1, 0x5a, 0xf6}}41PROPID_ACC_NAV_NEXT = MSAAPROPID{0x1cdc5455, 0x8cd9, 0x4c92, [8]byte{0xa3, 0x71, 0x39, 0x39, 0xa2, 0xfe, 0x3e, 0xee}}42PROPID_ACC_NAV_FIRSTCHILD = MSAAPROPID{0xcfd02558, 0x557b, 0x4c67, [8]byte{0x84, 0xf9, 0x2a, 0x09, 0xfc, 0xe4, 0x07, 0x49}}43PROPID_ACC_NAV_LASTCHILD = MSAAPROPID{0x302ecaa5, 0x48d5, 0x4f8d, [8]byte{0xb6, 0x71, 0x1a, 0x8d, 0x20, 0xa7, 0x78, 0x32}}44PROPID_ACC_ROLEMAP = MSAAPROPID{0xf79acda2, 0x140d, 0x4fe6, [8]byte{0x89, 0x14, 0x20, 0x84, 0x76, 0x32, 0x82, 0x69}}45PROPID_ACC_VALUEMAP = MSAAPROPID{0xda1c3d79, 0xfc5c, 0x420e, [8]byte{0xb3, 0x99, 0x9d, 0x15, 0x33, 0x54, 0x9e, 0x75}}46PROPID_ACC_STATEMAP = MSAAPROPID{0x43946c5e, 0x0ac0, 0x4042, [8]byte{0xb5, 0x25, 0x07, 0xbb, 0xdb, 0xe1, 0x7f, 0xa7}}47PROPID_ACC_DESCRIPTIONMAP = MSAAPROPID{0x1ff1435f, 0x8a14, 0x477b, [8]byte{0xb2, 0x26, 0xa0, 0xab, 0xe2, 0x79, 0x97, 0x5d}}48PROPID_ACC_DODEFAULTACTION = MSAAPROPID{0x1ba09523, 0x2e3b, 0x49a6, [8]byte{0xa0, 0x59, 0x59, 0x68, 0x2a, 0x3c, 0x48, 0xfd}}49)
50
51const (52STATE_SYSTEM_NORMAL = 053STATE_SYSTEM_UNAVAILABLE = 0x154STATE_SYSTEM_SELECTED = 0x255STATE_SYSTEM_FOCUSED = 0x456STATE_SYSTEM_PRESSED = 0x857STATE_SYSTEM_CHECKED = 0x1058STATE_SYSTEM_MIXED = 0x2059STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED60STATE_SYSTEM_READONLY = 0x4061STATE_SYSTEM_HOTTRACKED = 0x8062STATE_SYSTEM_DEFAULT = 0x10063STATE_SYSTEM_EXPANDED = 0x20064STATE_SYSTEM_COLLAPSED = 0x40065STATE_SYSTEM_BUSY = 0x80066STATE_SYSTEM_FLOATING = 0x100067STATE_SYSTEM_MARQUEED = 0x200068STATE_SYSTEM_ANIMATED = 0x400069STATE_SYSTEM_INVISIBLE = 0x800070STATE_SYSTEM_OFFSCREEN = 0x1000071STATE_SYSTEM_SIZEABLE = 0x2000072STATE_SYSTEM_MOVEABLE = 0x4000073STATE_SYSTEM_SELFVOICING = 0x8000074STATE_SYSTEM_FOCUSABLE = 0x10000075STATE_SYSTEM_SELECTABLE = 0x20000076STATE_SYSTEM_LINKED = 0x40000077STATE_SYSTEM_TRAVERSED = 0x80000078STATE_SYSTEM_MULTISELECTABLE = 0x100000079STATE_SYSTEM_EXTSELECTABLE = 0x200000080STATE_SYSTEM_ALERT_LOW = 0x400000081STATE_SYSTEM_ALERT_MEDIUM = 0x800000082STATE_SYSTEM_ALERT_HIGH = 0x1000000083STATE_SYSTEM_PROTECTED = 0x2000000084STATE_SYSTEM_HASPOPUP = 0x4000000085STATE_SYSTEM_VALID = 0x7fffffff86)
87
88const (89ROLE_SYSTEM_TITLEBAR = 0x190ROLE_SYSTEM_MENUBAR = 0x291ROLE_SYSTEM_SCROLLBAR = 0x392ROLE_SYSTEM_GRIP = 0x493ROLE_SYSTEM_SOUND = 0x594ROLE_SYSTEM_CURSOR = 0x695ROLE_SYSTEM_CARET = 0x796ROLE_SYSTEM_ALERT = 0x897ROLE_SYSTEM_WINDOW = 0x998ROLE_SYSTEM_CLIENT = 0xa99ROLE_SYSTEM_MENUPOPUP = 0xb100ROLE_SYSTEM_MENUITEM = 0xc101ROLE_SYSTEM_TOOLTIP = 0xd102ROLE_SYSTEM_APPLICATION = 0xe103ROLE_SYSTEM_DOCUMENT = 0xf104ROLE_SYSTEM_PANE = 0x10105ROLE_SYSTEM_CHART = 0x11106ROLE_SYSTEM_DIALOG = 0x12107ROLE_SYSTEM_BORDER = 0x13108ROLE_SYSTEM_GROUPING = 0x14109ROLE_SYSTEM_SEPARATOR = 0x15110ROLE_SYSTEM_TOOLBAR = 0x16111ROLE_SYSTEM_STATUSBAR = 0x17112ROLE_SYSTEM_TABLE = 0x18113ROLE_SYSTEM_COLUMNHEADER = 0x19114ROLE_SYSTEM_ROWHEADER = 0x1a115ROLE_SYSTEM_COLUMN = 0x1b116ROLE_SYSTEM_ROW = 0x1c117ROLE_SYSTEM_CELL = 0x1d118ROLE_SYSTEM_LINK = 0x1e119ROLE_SYSTEM_HELPBALLOON = 0x1f120ROLE_SYSTEM_CHARACTER = 0x20121ROLE_SYSTEM_LIST = 0x21122ROLE_SYSTEM_LISTITEM = 0x22123ROLE_SYSTEM_OUTLINE = 0x23124ROLE_SYSTEM_OUTLINEITEM = 0x24125ROLE_SYSTEM_PAGETAB = 0x25126ROLE_SYSTEM_PROPERTYPAGE = 0x26127ROLE_SYSTEM_INDICATOR = 0x27128ROLE_SYSTEM_GRAPHIC = 0x28129ROLE_SYSTEM_STATICTEXT = 0x29130ROLE_SYSTEM_TEXT = 0x2a131ROLE_SYSTEM_PUSHBUTTON = 0x2b132ROLE_SYSTEM_CHECKBUTTON = 0x2c133ROLE_SYSTEM_RADIOBUTTON = 0x2d134ROLE_SYSTEM_COMBOBOX = 0x2e135ROLE_SYSTEM_DROPLIST = 0x2f136ROLE_SYSTEM_PROGRESSBAR = 0x30137ROLE_SYSTEM_DIAL = 0x31138ROLE_SYSTEM_HOTKEYFIELD = 0x32139ROLE_SYSTEM_SLIDER = 0x33140ROLE_SYSTEM_SPINBUTTON = 0x34141ROLE_SYSTEM_DIAGRAM = 0x35142ROLE_SYSTEM_ANIMATION = 0x36143ROLE_SYSTEM_EQUATION = 0x37144ROLE_SYSTEM_BUTTONDROPDOWN = 0x38145ROLE_SYSTEM_BUTTONMENU = 0x39146ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a147ROLE_SYSTEM_WHITESPACE = 0x3b148ROLE_SYSTEM_PAGETABLIST = 0x3c149ROLE_SYSTEM_CLOCK = 0x3d150ROLE_SYSTEM_SPLITBUTTON = 0x3e151ROLE_SYSTEM_IPADDRESS = 0x3f152ROLE_SYSTEM_OUTLINEBUTTON = 0x40153)
154
155var (156IID_IAccPropServer = IID{0x76c0dbbb, 0x15e0, 0x4e7b, [8]byte{0xb6, 0x1b, 0x20, 0xee, 0xea, 0x20, 0x01, 0xe0}}157IID_IAccPropServices = IID{0x6e26e776, 0x04f0, 0x495d, [8]byte{0x80, 0xe4, 0x33, 0x30, 0x35, 0x2e, 0x31, 0x69}}158CLSID_AccPropServices = CLSID{0xb5f8350b, 0x0548, 0x48b1, [8]byte{0xa6, 0xee, 0x88, 0xbd, 0x00, 0xb4, 0xa5, 0xe7}}159)
160
161type IAccPropServerVtbl struct {162QueryInterface uintptr163AddRef uintptr164Release uintptr165GetPropValue uintptr166}
167
168type IAccPropServer struct {169LpVtbl *IAccPropServerVtbl170}
171
172type IAccPropServicesVtbl struct {173QueryInterface uintptr174AddRef uintptr175Release uintptr176SetPropValue uintptr177SetPropServer uintptr178ClearProps uintptr179SetHwndProp uintptr180SetHwndPropStr uintptr181SetHwndPropServer uintptr182ClearHwndProps uintptr183ComposeHwndIdentityString uintptr184DecomposeHwndIdentityString uintptr185SetHmenuProp uintptr186SetHmenuPropStr uintptr187SetHmenuPropServer uintptr188ClearHmenuProps uintptr189ComposeHmenuIdentityString uintptr190DecomposeHmenuIdentityString uintptr191}
192
193type IAccPropServices struct {194LpVtbl *IAccPropServicesVtbl195}
196
197func (obj *IAccPropServices) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT {198ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3,199uintptr(unsafe.Pointer(obj)),200uintptr(unsafe.Pointer(riid)),201uintptr(unsafe.Pointer(ppvObject)))202return HRESULT(ret)203}
204
205func (obj *IAccPropServices) AddRef() uint32 {206ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1,207uintptr(unsafe.Pointer(obj)),2080,2090)210return uint32(ret)211}
212
213func (obj *IAccPropServices) Release() uint32 {214ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1,215uintptr(unsafe.Pointer(obj)),2160,2170)218return uint32(ret)219}
220
221// SetPropServer specifies a callback object to be used to annotate an array of properties for the accessible element. You can also specify whether the annotation is to be applied to this accessible element or to the element and its children. This method is used for server annotation.
222// If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer.
223func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT {224var idStringPtr unsafe.Pointer225idStringLen := len(idString)226if idStringLen != 0 {227idStringPtr = unsafe.Pointer(&idString[0])228}229var idPropsPtr unsafe.Pointer230idPropsLen := len(idProps)231if idPropsLen != 0 {232idPropsPtr = unsafe.Pointer(&idProps[0])233}234ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropServer, 7,235uintptr(unsafe.Pointer(obj)),236uintptr(idStringPtr),237uintptr(idStringLen),238uintptr(idPropsPtr),239uintptr(idPropsLen),240uintptr(unsafe.Pointer(server)),241uintptr(annoScope),2420,2430)244return HRESULT(ret)245}
246
247// ClearProps restores default values to properties of accessible elements that they had previously annotated.
248// If servers know the HWND of the object they want to clear, they can use ClearHwndProps.
249func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) HRESULT {250var idStringPtr unsafe.Pointer251idStringLen := len(idString)252if idStringLen != 0 {253idStringPtr = unsafe.Pointer(&idString[0])254}255var idPropsPtr unsafe.Pointer256idPropsLen := len(idProps)257if idPropsLen != 0 {258idPropsPtr = unsafe.Pointer(&idProps[0])259}260ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearProps, 5,261uintptr(unsafe.Pointer(obj)),262uintptr(idStringPtr),263uintptr(idStringLen),264uintptr(idPropsPtr),265uintptr(idPropsLen),2660)267return HRESULT(ret)268}
269
270// SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements.
271func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT {272var idPropsPtr unsafe.Pointer273idPropsLen := len(idProps)274if idPropsLen != 0 {275idPropsPtr = unsafe.Pointer(&idProps[0])276}277ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropServer, 8,278uintptr(unsafe.Pointer(obj)),279uintptr(hwnd),280uintptr(idObject),281uintptr(idChild),282uintptr(idPropsPtr),283uintptr(idPropsLen),284uintptr(unsafe.Pointer(server)),285uintptr(annoScope),2860)287return HRESULT(ret)288}
289
290// ClearHwndProps wraps SetPropValue, SetPropServer, and ClearProps, and provides a convenient entry point for callers who are annotating HWND-based accessible elements.
291func (obj *IAccPropServices) ClearHwndProps(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID) HRESULT {292var idPropsPtr unsafe.Pointer293idPropsLen := len(idProps)294if idPropsLen != 0 {295idPropsPtr = unsafe.Pointer(&idProps[0])296}297ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHwndProps, 6,298uintptr(unsafe.Pointer(obj)),299uintptr(hwnd),300uintptr(idObject),301uintptr(idChild),302uintptr(idPropsPtr),303uintptr(idPropsLen))304return HRESULT(ret)305}
306
307// ComposeHwndIdentityString retrievs an identity string.
308func (obj *IAccPropServices) ComposeHwndIdentityString(hwnd HWND, idObject int32, idChild uint32) (hr HRESULT, idString []byte) {309var data *[1<<31 - 1]byte310var len uint32311ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHwndIdentityString, 6,312uintptr(unsafe.Pointer(obj)),313uintptr(hwnd),314uintptr(idObject),315uintptr(idChild),316uintptr(unsafe.Pointer(&data)),317uintptr(unsafe.Pointer(&len)))318hr = HRESULT(ret)319if FAILED(hr) {320return321}322defer CoTaskMemFree(uintptr(unsafe.Pointer(data)))323idString = make([]byte, len)324copy(idString, data[:len])325return326}
327
328// DecomposeHwndIdentityString determines the HWND, object ID, and child ID for the accessible element identified by the identity string.
329func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HRESULT, hwnd HWND, idObject int32, idChild uint32) {330var idStringPtr unsafe.Pointer331idStringLen := len(idString)332if idStringLen != 0 {333idStringPtr = unsafe.Pointer(&idString[0])334}335ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHwndIdentityString, 6,336uintptr(unsafe.Pointer(obj)),337uintptr(idStringPtr),338uintptr(idStringLen),339uintptr(unsafe.Pointer(&hwnd)),340uintptr(unsafe.Pointer(&idObject)),341uintptr(unsafe.Pointer(&idChild)))342hr = HRESULT(ret)343return344}
345
346// SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements.
347func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT {348var idPropsPtr unsafe.Pointer349idPropsLen := len(idProps)350if idPropsLen != 0 {351idPropsPtr = unsafe.Pointer(&idProps[0])352}353ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropServer, 7,354uintptr(unsafe.Pointer(obj)),355uintptr(hmenu),356uintptr(idChild),357uintptr(idPropsPtr),358uintptr(idPropsLen),359uintptr(unsafe.Pointer(server)),360uintptr(annoScope),3610,3620)363return HRESULT(ret)364}
365
366// ClearHmenuProps wraps ClearProps, and provides a convenient entry point for callers who are annotating HMENU-based accessible elements.
367func (obj *IAccPropServices) ClearHmenuProps(hmenu HMENU, idChild uint32, idProps []MSAAPROPID) HRESULT {368var idPropsPtr unsafe.Pointer369idPropsLen := len(idProps)370if idPropsLen != 0 {371idPropsPtr = unsafe.Pointer(&idProps[0])372}373ret, _, _ := syscall.Syscall6(obj.LpVtbl.ClearHmenuProps, 5,374uintptr(unsafe.Pointer(obj)),375uintptr(hmenu),376uintptr(idChild),377uintptr(idPropsPtr),378uintptr(idPropsLen),3790)380return HRESULT(ret)381}
382
383// ComposeHmenuIdentityString retrieves an identity string for an HMENU-based accessible element.
384func (obj *IAccPropServices) ComposeHmenuIdentityString(hmenu HMENU, idChild uint32) (hr HRESULT, idString []byte) {385var data *[1<<31 - 1]byte386var len uint32387ret, _, _ := syscall.Syscall6(obj.LpVtbl.ComposeHmenuIdentityString, 5,388uintptr(unsafe.Pointer(obj)),389uintptr(hmenu),390uintptr(idChild),391uintptr(unsafe.Pointer(&data)),392uintptr(unsafe.Pointer(&len)),3930)394hr = HRESULT(ret)395if FAILED(hr) {396return397}398defer CoTaskMemFree(uintptr(unsafe.Pointer(data)))399idString = make([]byte, len)400copy(idString, data[:len])401return402}
403
404// DecomposeHmenuIdentityString determines the HMENU, object ID, and child ID for the accessible element identified by the identity string.
405func (obj *IAccPropServices) DecomposeHmenuIdentityString(idString []byte) (hr HRESULT, hmenu HMENU, idChild uint32) {406var idStringPtr unsafe.Pointer407idStringLen := len(idString)408if idStringLen != 0 {409idStringPtr = unsafe.Pointer(&idString[0])410}411ret, _, _ := syscall.Syscall6(obj.LpVtbl.DecomposeHmenuIdentityString, 5,412uintptr(unsafe.Pointer(obj)),413uintptr(idStringPtr),414uintptr(idStringLen),415uintptr(unsafe.Pointer(&hmenu)),416uintptr(unsafe.Pointer(&idChild)),4170)418hr = HRESULT(ret)419return420}
421