ホーム › UI.Accessibility › TextRange_Move
TextRange_Move
関数テキスト範囲を指定単位ぶん指定回数移動する。
シグネチャ
// UIAutomationCore.dll
#include <windows.h>
HRESULT TextRange_Move(
HUIATEXTRANGE hobj,
TextUnit unit,
INT count,
INT* pRetVal
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hobj | HUIATEXTRANGE | in | 移動対象のテキスト範囲ハンドル。 |
| unit | TextUnit | in | 移動の単位(文字・単語・行など)を示すTextUnit値。 |
| count | INT | in | 移動する単位数。負値で後方へ移動する。 |
| pRetVal | INT* | inout | 実際に移動できた単位数を受け取る出力先。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// UIAutomationCore.dll
#include <windows.h>
HRESULT TextRange_Move(
HUIATEXTRANGE hobj,
TextUnit unit,
INT count,
INT* pRetVal
);[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int TextRange_Move(
IntPtr hobj, // HUIATEXTRANGE
int unit, // TextUnit
int count, // INT
ref int pRetVal // INT* in/out
);<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function TextRange_Move(
hobj As IntPtr, ' HUIATEXTRANGE
unit As Integer, ' TextUnit
count As Integer, ' INT
ByRef pRetVal As Integer ' INT* in/out
) As Integer
End Function' hobj : HUIATEXTRANGE
' unit : TextUnit
' count : INT
' pRetVal : INT* in/out
Declare PtrSafe Function TextRange_Move Lib "uiautomationcore" ( _
ByVal hobj As LongPtr, _
ByVal unit As Long, _
ByVal count As Long, _
ByRef pRetVal As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TextRange_Move = ctypes.windll.uiautomationcore.TextRange_Move
TextRange_Move.restype = ctypes.c_int
TextRange_Move.argtypes = [
wintypes.HANDLE, # hobj : HUIATEXTRANGE
ctypes.c_int, # unit : TextUnit
ctypes.c_int, # count : INT
ctypes.POINTER(ctypes.c_int), # pRetVal : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UIAutomationCore.dll')
TextRange_Move = Fiddle::Function.new(
lib['TextRange_Move'],
[
Fiddle::TYPE_VOIDP, # hobj : HUIATEXTRANGE
Fiddle::TYPE_INT, # unit : TextUnit
Fiddle::TYPE_INT, # count : INT
Fiddle::TYPE_VOIDP, # pRetVal : INT* in/out
],
Fiddle::TYPE_INT)#[link(name = "uiautomationcore")]
extern "system" {
fn TextRange_Move(
hobj: *mut core::ffi::c_void, // HUIATEXTRANGE
unit: i32, // TextUnit
count: i32, // INT
pRetVal: *mut i32 // INT* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int TextRange_Move(IntPtr hobj, int unit, int count, ref int pRetVal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_TextRange_Move' -Namespace Win32 -PassThru
# $api::TextRange_Move(hobj, unit, count, pRetVal)#uselib "UIAutomationCore.dll"
#func global TextRange_Move "TextRange_Move" sptr, sptr, sptr, sptr
; TextRange_Move hobj, unit, count, varptr(pRetVal) ; 戻り値は stat
; hobj : HUIATEXTRANGE -> "sptr"
; unit : TextUnit -> "sptr"
; count : INT -> "sptr"
; pRetVal : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UIAutomationCore.dll" #cfunc global TextRange_Move "TextRange_Move" sptr, int, int, var ; res = TextRange_Move(hobj, unit, count, pRetVal) ; hobj : HUIATEXTRANGE -> "sptr" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UIAutomationCore.dll" #cfunc global TextRange_Move "TextRange_Move" sptr, int, int, sptr ; res = TextRange_Move(hobj, unit, count, varptr(pRetVal)) ; hobj : HUIATEXTRANGE -> "sptr" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT TextRange_Move(HUIATEXTRANGE hobj, TextUnit unit, INT count, INT* pRetVal) #uselib "UIAutomationCore.dll" #cfunc global TextRange_Move "TextRange_Move" intptr, int, int, var ; res = TextRange_Move(hobj, unit, count, pRetVal) ; hobj : HUIATEXTRANGE -> "intptr" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT TextRange_Move(HUIATEXTRANGE hobj, TextUnit unit, INT count, INT* pRetVal) #uselib "UIAutomationCore.dll" #cfunc global TextRange_Move "TextRange_Move" intptr, int, int, intptr ; res = TextRange_Move(hobj, unit, count, varptr(pRetVal)) ; hobj : HUIATEXTRANGE -> "intptr" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
procTextRange_Move = uiautomationcore.NewProc("TextRange_Move")
)
// hobj (HUIATEXTRANGE), unit (TextUnit), count (INT), pRetVal (INT* in/out)
r1, _, err := procTextRange_Move.Call(
uintptr(hobj),
uintptr(unit),
uintptr(count),
uintptr(pRetVal),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction TextRange_Move(
hobj: THandle; // HUIATEXTRANGE
unit: Integer; // TextUnit
count: Integer; // INT
pRetVal: Pointer // INT* in/out
): Integer; stdcall;
external 'UIAutomationCore.dll' name 'TextRange_Move';result := DllCall("UIAutomationCore\TextRange_Move"
, "Ptr", hobj ; HUIATEXTRANGE
, "Int", unit ; TextUnit
, "Int", count ; INT
, "Ptr", pRetVal ; INT* in/out
, "Int") ; return: HRESULT●TextRange_Move(hobj, unit, count, pRetVal) = DLL("UIAutomationCore.dll", "int TextRange_Move(void*, int, int, void*)")
# 呼び出し: TextRange_Move(hobj, unit, count, pRetVal)
# hobj : HUIATEXTRANGE -> "void*"
# unit : TextUnit -> "int"
# count : INT -> "int"
# pRetVal : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uiautomationcore" fn TextRange_Move(
hobj: ?*anyopaque, // HUIATEXTRANGE
unit: i32, // TextUnit
count: i32, // INT
pRetVal: [*c]i32 // INT* in/out
) callconv(std.os.windows.WINAPI) i32;proc TextRange_Move(
hobj: pointer, # HUIATEXTRANGE
unit: int32, # TextUnit
count: int32, # INT
pRetVal: ptr int32 # INT* in/out
): int32 {.importc: "TextRange_Move", stdcall, dynlib: "UIAutomationCore.dll".}pragma(lib, "uiautomationcore");
extern(Windows)
int TextRange_Move(
void* hobj, // HUIATEXTRANGE
int unit, // TextUnit
int count, // INT
int* pRetVal // INT* in/out
);ccall((:TextRange_Move, "UIAutomationCore.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Int32, Ptr{Int32}),
hobj, unit, count, pRetVal)
# hobj : HUIATEXTRANGE -> Ptr{Cvoid}
# unit : TextUnit -> Int32
# count : INT -> Int32
# pRetVal : INT* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t TextRange_Move(
void* hobj,
int32_t unit,
int32_t count,
int32_t* pRetVal);
]]
local uiautomationcore = ffi.load("uiautomationcore")
-- uiautomationcore.TextRange_Move(hobj, unit, count, pRetVal)
-- hobj : HUIATEXTRANGE
-- unit : TextUnit
-- count : INT
-- pRetVal : INT* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UIAutomationCore.dll');
const TextRange_Move = lib.func('__stdcall', 'TextRange_Move', 'int32_t', ['void *', 'int32_t', 'int32_t', 'int32_t *']);
// TextRange_Move(hobj, unit, count, pRetVal)
// hobj : HUIATEXTRANGE -> 'void *'
// unit : TextUnit -> 'int32_t'
// count : INT -> 'int32_t'
// pRetVal : INT* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UIAutomationCore.dll", {
TextRange_Move: { parameters: ["pointer", "i32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.TextRange_Move(hobj, unit, count, pRetVal)
// hobj : HUIATEXTRANGE -> "pointer"
// unit : TextUnit -> "i32"
// count : INT -> "i32"
// pRetVal : INT* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t TextRange_Move(
void* hobj,
int32_t unit,
int32_t count,
int32_t* pRetVal);
C, "UIAutomationCore.dll");
// $ffi->TextRange_Move(hobj, unit, count, pRetVal);
// hobj : HUIATEXTRANGE
// unit : TextUnit
// count : INT
// pRetVal : INT* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Uiautomationcore extends StdCallLibrary {
Uiautomationcore INSTANCE = Native.load("uiautomationcore", Uiautomationcore.class);
int TextRange_Move(
Pointer hobj, // HUIATEXTRANGE
int unit, // TextUnit
int count, // INT
IntByReference pRetVal // INT* in/out
);
}@[Link("uiautomationcore")]
lib LibUIAutomationCore
fun TextRange_Move = TextRange_Move(
hobj : Void*, # HUIATEXTRANGE
unit : Int32, # TextUnit
count : Int32, # INT
pRetVal : Int32* # INT* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TextRange_MoveNative = Int32 Function(Pointer<Void>, Int32, Int32, Pointer<Int32>);
typedef TextRange_MoveDart = int Function(Pointer<Void>, int, int, Pointer<Int32>);
final TextRange_Move = DynamicLibrary.open('UIAutomationCore.dll')
.lookupFunction<TextRange_MoveNative, TextRange_MoveDart>('TextRange_Move');
// hobj : HUIATEXTRANGE -> Pointer<Void>
// unit : TextUnit -> Int32
// count : INT -> Int32
// pRetVal : INT* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function TextRange_Move(
hobj: THandle; // HUIATEXTRANGE
unit: Integer; // TextUnit
count: Integer; // INT
pRetVal: Pointer // INT* in/out
): Integer; stdcall;
external 'UIAutomationCore.dll' name 'TextRange_Move';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TextRange_Move"
c_TextRange_Move :: Ptr () -> Int32 -> Int32 -> Ptr Int32 -> IO Int32
-- hobj : HUIATEXTRANGE -> Ptr ()
-- unit : TextUnit -> Int32
-- count : INT -> Int32
-- pRetVal : INT* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let textrange_move =
foreign "TextRange_Move"
((ptr void) @-> int32_t @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* hobj : HUIATEXTRANGE -> (ptr void) *)
(* unit : TextUnit -> int32_t *)
(* count : INT -> int32_t *)
(* pRetVal : INT* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uiautomationcore (t "UIAutomationCore.dll"))
(cffi:use-foreign-library uiautomationcore)
(cffi:defcfun ("TextRange_Move" text-range-move :convention :stdcall) :int32
(hobj :pointer) ; HUIATEXTRANGE
(unit :int32) ; TextUnit
(count :int32) ; INT
(p-ret-val :pointer)) ; INT* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TextRange_Move = Win32::API::More->new('UIAutomationCore',
'int TextRange_Move(HANDLE hobj, int unit, int count, LPVOID pRetVal)');
# my $ret = $TextRange_Move->Call($hobj, $unit, $count, $pRetVal);
# hobj : HUIATEXTRANGE -> HANDLE
# unit : TextUnit -> int
# count : INT -> int
# pRetVal : INT* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型