Win32 API 日本語リファレンス
ホームUI.Accessibility › UiaSetFocus

UiaSetFocus

関数
UIオートメーションノードにフォーカスを設定する。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// UIAutomationCore.dll
#include <windows.h>

HRESULT UiaSetFocus(
    HUIANODE hnode
);

パラメーター

名前方向
hnodeHUIANODEin

戻り値の型: HRESULT

各言語での呼び出し定義

// UIAutomationCore.dll
#include <windows.h>

HRESULT UiaSetFocus(
    HUIANODE hnode
);
[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int UiaSetFocus(
    IntPtr hnode   // HUIANODE
);
<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function UiaSetFocus(
    hnode As IntPtr   ' HUIANODE
) As Integer
End Function
' hnode : HUIANODE
Declare PtrSafe Function UiaSetFocus Lib "uiautomationcore" ( _
    ByVal hnode As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UiaSetFocus = ctypes.windll.uiautomationcore.UiaSetFocus
UiaSetFocus.restype = ctypes.c_int
UiaSetFocus.argtypes = [
    wintypes.HANDLE,  # hnode : HUIANODE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UIAutomationCore.dll')
UiaSetFocus = Fiddle::Function.new(
  lib['UiaSetFocus'],
  [
    Fiddle::TYPE_VOIDP,  # hnode : HUIANODE
  ],
  Fiddle::TYPE_INT)
#[link(name = "uiautomationcore")]
extern "system" {
    fn UiaSetFocus(
        hnode: *mut core::ffi::c_void  // HUIANODE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int UiaSetFocus(IntPtr hnode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_UiaSetFocus' -Namespace Win32 -PassThru
# $api::UiaSetFocus(hnode)
#uselib "UIAutomationCore.dll"
#func global UiaSetFocus "UiaSetFocus" sptr
; UiaSetFocus hnode   ; 戻り値は stat
; hnode : HUIANODE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "UIAutomationCore.dll"
#cfunc global UiaSetFocus "UiaSetFocus" sptr
; res = UiaSetFocus(hnode)
; hnode : HUIANODE -> "sptr"
; HRESULT UiaSetFocus(HUIANODE hnode)
#uselib "UIAutomationCore.dll"
#cfunc global UiaSetFocus "UiaSetFocus" intptr
; res = UiaSetFocus(hnode)
; hnode : HUIANODE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procUiaSetFocus = uiautomationcore.NewProc("UiaSetFocus")
)

// hnode (HUIANODE)
r1, _, err := procUiaSetFocus.Call(
	uintptr(hnode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function UiaSetFocus(
  hnode: THandle   // HUIANODE
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'UiaSetFocus';
result := DllCall("UIAutomationCore\UiaSetFocus"
    , "Ptr", hnode   ; HUIANODE
    , "Int")   ; return: HRESULT
●UiaSetFocus(hnode) = DLL("UIAutomationCore.dll", "int UiaSetFocus(void*)")
# 呼び出し: UiaSetFocus(hnode)
# hnode : HUIANODE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。