ホーム › UI.Accessibility › UiaAddEvent
UiaAddEvent
関数UIオートメーションノードにイベントリスナーを登録する。
シグネチャ
// UIAutomationCore.dll
#include <windows.h>
HRESULT UiaAddEvent(
HUIANODE hnode,
INT eventId,
UiaEventCallback* pCallback,
TreeScope scope,
INT* pProperties,
INT cProperties,
UiaCacheRequest* pRequest,
HUIAEVENT* phEvent
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hnode | HUIANODE | in |
| eventId | INT | in |
| pCallback | UiaEventCallback* | inout |
| scope | TreeScope | in |
| pProperties | INT* | inout |
| cProperties | INT | in |
| pRequest | UiaCacheRequest* | inout |
| phEvent | HUIAEVENT* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// UIAutomationCore.dll
#include <windows.h>
HRESULT UiaAddEvent(
HUIANODE hnode,
INT eventId,
UiaEventCallback* pCallback,
TreeScope scope,
INT* pProperties,
INT cProperties,
UiaCacheRequest* pRequest,
HUIAEVENT* phEvent
);[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int UiaAddEvent(
IntPtr hnode, // HUIANODE
int eventId, // INT
IntPtr pCallback, // UiaEventCallback* in/out
int scope, // TreeScope
ref int pProperties, // INT* in/out
int cProperties, // INT
IntPtr pRequest, // UiaCacheRequest* in/out
IntPtr phEvent // HUIAEVENT* in/out
);<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function UiaAddEvent(
hnode As IntPtr, ' HUIANODE
eventId As Integer, ' INT
pCallback As IntPtr, ' UiaEventCallback* in/out
scope As Integer, ' TreeScope
ByRef pProperties As Integer, ' INT* in/out
cProperties As Integer, ' INT
pRequest As IntPtr, ' UiaCacheRequest* in/out
phEvent As IntPtr ' HUIAEVENT* in/out
) As Integer
End Function' hnode : HUIANODE
' eventId : INT
' pCallback : UiaEventCallback* in/out
' scope : TreeScope
' pProperties : INT* in/out
' cProperties : INT
' pRequest : UiaCacheRequest* in/out
' phEvent : HUIAEVENT* in/out
Declare PtrSafe Function UiaAddEvent Lib "uiautomationcore" ( _
ByVal hnode As LongPtr, _
ByVal eventId As Long, _
ByVal pCallback As LongPtr, _
ByVal scope As Long, _
ByRef pProperties As Long, _
ByVal cProperties As Long, _
ByVal pRequest As LongPtr, _
ByVal phEvent As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UiaAddEvent = ctypes.windll.uiautomationcore.UiaAddEvent
UiaAddEvent.restype = ctypes.c_int
UiaAddEvent.argtypes = [
wintypes.HANDLE, # hnode : HUIANODE
ctypes.c_int, # eventId : INT
ctypes.c_void_p, # pCallback : UiaEventCallback* in/out
ctypes.c_int, # scope : TreeScope
ctypes.POINTER(ctypes.c_int), # pProperties : INT* in/out
ctypes.c_int, # cProperties : INT
ctypes.c_void_p, # pRequest : UiaCacheRequest* in/out
ctypes.c_void_p, # phEvent : HUIAEVENT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UIAutomationCore.dll')
UiaAddEvent = Fiddle::Function.new(
lib['UiaAddEvent'],
[
Fiddle::TYPE_VOIDP, # hnode : HUIANODE
Fiddle::TYPE_INT, # eventId : INT
Fiddle::TYPE_VOIDP, # pCallback : UiaEventCallback* in/out
Fiddle::TYPE_INT, # scope : TreeScope
Fiddle::TYPE_VOIDP, # pProperties : INT* in/out
Fiddle::TYPE_INT, # cProperties : INT
Fiddle::TYPE_VOIDP, # pRequest : UiaCacheRequest* in/out
Fiddle::TYPE_VOIDP, # phEvent : HUIAEVENT* in/out
],
Fiddle::TYPE_INT)#[link(name = "uiautomationcore")]
extern "system" {
fn UiaAddEvent(
hnode: *mut core::ffi::c_void, // HUIANODE
eventId: i32, // INT
pCallback: *mut *const core::ffi::c_void, // UiaEventCallback* in/out
scope: i32, // TreeScope
pProperties: *mut i32, // INT* in/out
cProperties: i32, // INT
pRequest: *mut UiaCacheRequest, // UiaCacheRequest* in/out
phEvent: *mut *mut core::ffi::c_void // HUIAEVENT* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int UiaAddEvent(IntPtr hnode, int eventId, IntPtr pCallback, int scope, ref int pProperties, int cProperties, IntPtr pRequest, IntPtr phEvent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_UiaAddEvent' -Namespace Win32 -PassThru
# $api::UiaAddEvent(hnode, eventId, pCallback, scope, pProperties, cProperties, pRequest, phEvent)#uselib "UIAutomationCore.dll"
#func global UiaAddEvent "UiaAddEvent" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; UiaAddEvent hnode, eventId, pCallback, scope, varptr(pProperties), cProperties, varptr(pRequest), phEvent ; 戻り値は stat
; hnode : HUIANODE -> "sptr"
; eventId : INT -> "sptr"
; pCallback : UiaEventCallback* in/out -> "sptr"
; scope : TreeScope -> "sptr"
; pProperties : INT* in/out -> "sptr"
; cProperties : INT -> "sptr"
; pRequest : UiaCacheRequest* in/out -> "sptr"
; phEvent : HUIAEVENT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UIAutomationCore.dll" #cfunc global UiaAddEvent "UiaAddEvent" sptr, int, sptr, int, var, int, var, sptr ; res = UiaAddEvent(hnode, eventId, pCallback, scope, pProperties, cProperties, pRequest, phEvent) ; hnode : HUIANODE -> "sptr" ; eventId : INT -> "int" ; pCallback : UiaEventCallback* in/out -> "sptr" ; scope : TreeScope -> "int" ; pProperties : INT* in/out -> "var" ; cProperties : INT -> "int" ; pRequest : UiaCacheRequest* in/out -> "var" ; phEvent : HUIAEVENT* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UIAutomationCore.dll" #cfunc global UiaAddEvent "UiaAddEvent" sptr, int, sptr, int, sptr, int, sptr, sptr ; res = UiaAddEvent(hnode, eventId, pCallback, scope, varptr(pProperties), cProperties, varptr(pRequest), phEvent) ; hnode : HUIANODE -> "sptr" ; eventId : INT -> "int" ; pCallback : UiaEventCallback* in/out -> "sptr" ; scope : TreeScope -> "int" ; pProperties : INT* in/out -> "sptr" ; cProperties : INT -> "int" ; pRequest : UiaCacheRequest* in/out -> "sptr" ; phEvent : HUIAEVENT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT UiaAddEvent(HUIANODE hnode, INT eventId, UiaEventCallback* pCallback, TreeScope scope, INT* pProperties, INT cProperties, UiaCacheRequest* pRequest, HUIAEVENT* phEvent) #uselib "UIAutomationCore.dll" #cfunc global UiaAddEvent "UiaAddEvent" intptr, int, intptr, int, var, int, var, intptr ; res = UiaAddEvent(hnode, eventId, pCallback, scope, pProperties, cProperties, pRequest, phEvent) ; hnode : HUIANODE -> "intptr" ; eventId : INT -> "int" ; pCallback : UiaEventCallback* in/out -> "intptr" ; scope : TreeScope -> "int" ; pProperties : INT* in/out -> "var" ; cProperties : INT -> "int" ; pRequest : UiaCacheRequest* in/out -> "var" ; phEvent : HUIAEVENT* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT UiaAddEvent(HUIANODE hnode, INT eventId, UiaEventCallback* pCallback, TreeScope scope, INT* pProperties, INT cProperties, UiaCacheRequest* pRequest, HUIAEVENT* phEvent) #uselib "UIAutomationCore.dll" #cfunc global UiaAddEvent "UiaAddEvent" intptr, int, intptr, int, intptr, int, intptr, intptr ; res = UiaAddEvent(hnode, eventId, pCallback, scope, varptr(pProperties), cProperties, varptr(pRequest), phEvent) ; hnode : HUIANODE -> "intptr" ; eventId : INT -> "int" ; pCallback : UiaEventCallback* in/out -> "intptr" ; scope : TreeScope -> "int" ; pProperties : INT* in/out -> "intptr" ; cProperties : INT -> "int" ; pRequest : UiaCacheRequest* in/out -> "intptr" ; phEvent : HUIAEVENT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
procUiaAddEvent = uiautomationcore.NewProc("UiaAddEvent")
)
// hnode (HUIANODE), eventId (INT), pCallback (UiaEventCallback* in/out), scope (TreeScope), pProperties (INT* in/out), cProperties (INT), pRequest (UiaCacheRequest* in/out), phEvent (HUIAEVENT* in/out)
r1, _, err := procUiaAddEvent.Call(
uintptr(hnode),
uintptr(eventId),
uintptr(pCallback),
uintptr(scope),
uintptr(pProperties),
uintptr(cProperties),
uintptr(pRequest),
uintptr(phEvent),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UiaAddEvent(
hnode: THandle; // HUIANODE
eventId: Integer; // INT
pCallback: Pointer; // UiaEventCallback* in/out
scope: Integer; // TreeScope
pProperties: Pointer; // INT* in/out
cProperties: Integer; // INT
pRequest: Pointer; // UiaCacheRequest* in/out
phEvent: Pointer // HUIAEVENT* in/out
): Integer; stdcall;
external 'UIAutomationCore.dll' name 'UiaAddEvent';result := DllCall("UIAutomationCore\UiaAddEvent"
, "Ptr", hnode ; HUIANODE
, "Int", eventId ; INT
, "Ptr", pCallback ; UiaEventCallback* in/out
, "Int", scope ; TreeScope
, "Ptr", pProperties ; INT* in/out
, "Int", cProperties ; INT
, "Ptr", pRequest ; UiaCacheRequest* in/out
, "Ptr", phEvent ; HUIAEVENT* in/out
, "Int") ; return: HRESULT●UiaAddEvent(hnode, eventId, pCallback, scope, pProperties, cProperties, pRequest, phEvent) = DLL("UIAutomationCore.dll", "int UiaAddEvent(void*, int, void*, int, void*, int, void*, void*)")
# 呼び出し: UiaAddEvent(hnode, eventId, pCallback, scope, pProperties, cProperties, pRequest, phEvent)
# hnode : HUIANODE -> "void*"
# eventId : INT -> "int"
# pCallback : UiaEventCallback* in/out -> "void*"
# scope : TreeScope -> "int"
# pProperties : INT* in/out -> "void*"
# cProperties : INT -> "int"
# pRequest : UiaCacheRequest* in/out -> "void*"
# phEvent : HUIAEVENT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。