Skip to content

Commit

Permalink
feat(windows_ui): add Windows UI Automation APIs (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
halildurmus committed May 31, 2023
1 parent 1a5479f commit 89035f8
Show file tree
Hide file tree
Showing 35 changed files with 2,184 additions and 7 deletions.
26 changes: 26 additions & 0 deletions packages/windows_ui/lib/src/exports.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ export 'popups/messagedialogoptions.dart';
export 'popups/placement.dart';
export 'popups/uicommand.dart';
export 'popups/uicommandseparator.dart';
export 'uiautomation/automationconnection.dart';
export 'uiautomation/automationconnectionboundobject.dart';
export 'uiautomation/automationelement.dart';
export 'uiautomation/automationtextrange.dart';
export 'uiautomation/core/automationannotationtyperegistration.dart';
export 'uiautomation/core/automationremoteoperationoperandid.dart';
export 'uiautomation/core/automationremoteoperationresult.dart';
export 'uiautomation/core/automationremoteoperationstatus.dart';
export 'uiautomation/core/coreautomationregistrar.dart';
export 'uiautomation/core/coreautomationremoteoperation.dart';
export 'uiautomation/core/coreautomationremoteoperationcontext.dart';
export 'uiautomation/core/iautomationremoteoperationresult.dart';
export 'uiautomation/core/icoreautomationconnectionboundobjectprovider.dart';
export 'uiautomation/core/icoreautomationremoteoperation.dart';
export 'uiautomation/core/icoreautomationremoteoperation2.dart';
export 'uiautomation/core/icoreautomationremoteoperationcontext.dart';
export 'uiautomation/core/icoreautomationremoteoperationextensionprovider.dart';
export 'uiautomation/core/iremoteautomationclientsession.dart';
export 'uiautomation/core/iremoteautomationwindow.dart';
export 'uiautomation/core/remoteautomationclientsession.dart';
export 'uiautomation/core/remoteautomationserver.dart';
export 'uiautomation/core/remoteautomationwindow.dart';
export 'uiautomation/iautomationconnection.dart';
export 'uiautomation/iautomationconnectionboundobject.dart';
export 'uiautomation/iautomationelement.dart';
export 'uiautomation/iautomationtextrange.dart';
export 'viewmanagement/handpreference.dart';
export 'viewmanagement/iuisettings.dart';
export 'viewmanagement/iuisettings2.dart';
Expand Down
37 changes: 37 additions & 0 deletions packages/windows_ui/lib/src/uiautomation/automationconnection.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

import 'iautomationconnection.dart';

/// Provides access to the connection details of a UI Automation connection.
///
/// {@category class}
class AutomationConnection extends IInspectable
implements IAutomationConnection {
AutomationConnection.fromPtr(super.ptr);

late final _iAutomationConnection = IAutomationConnection.from(this);

@override
bool get isRemoteSystem => _iAutomationConnection.isRemoteSystem;

@override
String get appUserModelId => _iAutomationConnection.appUserModelId;

@override
String get executableFileName => _iAutomationConnection.executableFileName;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

import 'automationconnection.dart';
import 'iautomationconnectionboundobject.dart';

/// Represents an object associated with a specific UI Automation provider
/// connection.
///
/// {@category class}
class AutomationConnectionBoundObject extends IInspectable
implements IAutomationConnectionBoundObject {
AutomationConnectionBoundObject.fromPtr(super.ptr);

late final _iAutomationConnectionBoundObject =
IAutomationConnectionBoundObject.from(this);

@override
AutomationConnection? get connection =>
_iAutomationConnectionBoundObject.connection;
}
37 changes: 37 additions & 0 deletions packages/windows_ui/lib/src/uiautomation/automationelement.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

import 'iautomationelement.dart';

/// Provides access to a UI object that supports the IUIAutomationElement
/// interface.
///
/// {@category class}
class AutomationElement extends IInspectable implements IAutomationElement {
AutomationElement.fromPtr(super.ptr);

late final _iAutomationElement = IAutomationElement.from(this);

@override
bool get isRemoteSystem => _iAutomationElement.isRemoteSystem;

@override
String get appUserModelId => _iAutomationElement.appUserModelId;

@override
String get executableFileName => _iAutomationElement.executableFileName;
}
26 changes: 26 additions & 0 deletions packages/windows_ui/lib/src/uiautomation/automationtextrange.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

import 'iautomationtextrange.dart';

/// Provides access to a span of continuous text in a container that
/// supports the IUIAutomationTextPattern interface.
///
/// {@category class}
class AutomationTextRange extends IInspectable implements IAutomationTextRange {
AutomationTextRange.fromPtr(super.ptr);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

/// Represents an annotation registration.
///
/// {@category struct}
final class AutomationAnnotationTypeRegistration implements WinRTStruct {
AutomationAnnotationTypeRegistration(this.localId);

final int localId;

@override
Pointer<NativeAutomationAnnotationTypeRegistration> toNative(
{Allocator allocator = malloc}) {
final ptr = allocator<NativeAutomationAnnotationTypeRegistration>();
ptr.ref.localId = localId;
return ptr;
}

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AutomationAnnotationTypeRegistration &&
localId == other.localId;
}

@override
int get hashCode => localId.hashCode;
}

extension PointerNativeAutomationAnnotationTypeRegistrationConversion
on Pointer<NativeAutomationAnnotationTypeRegistration> {
/// Converts this [NativeAutomationAnnotationTypeRegistration] to a Dart
/// [AutomationAnnotationTypeRegistration].
AutomationAnnotationTypeRegistration toDart() =>
AutomationAnnotationTypeRegistration(ref.localId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

/// Represents an identifier that refers to an operand register of a
/// CoreAutomationRemoteOperation.
///
/// {@category struct}
final class AutomationRemoteOperationOperandId implements WinRTStruct {
AutomationRemoteOperationOperandId(this.value);

final int value;

@override
Pointer<NativeAutomationRemoteOperationOperandId> toNative(
{Allocator allocator = malloc}) {
final ptr = allocator<NativeAutomationRemoteOperationOperandId>();
ptr.ref.value = value;
return ptr;
}

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AutomationRemoteOperationOperandId && value == other.value;
}

@override
int get hashCode => value.hashCode;
}

extension PointerNativeAutomationRemoteOperationOperandIdConversion
on Pointer<NativeAutomationRemoteOperationOperandId> {
/// Converts this [NativeAutomationRemoteOperationOperandId] to a Dart
/// [AutomationRemoteOperationOperandId].
AutomationRemoteOperationOperandId toDart() =>
AutomationRemoteOperationOperandId(ref.value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

import 'automationremoteoperationoperandid.dart';
import 'automationremoteoperationstatus.dart';
import 'iautomationremoteoperationresult.dart';

/// Provides access to the execution results (status and remote objects) of
/// a CoreAutomationRemoteOperation.
///
/// {@category class}
class AutomationRemoteOperationResult extends IInspectable
implements IAutomationRemoteOperationResult {
AutomationRemoteOperationResult.fromPtr(super.ptr);

late final _iAutomationRemoteOperationResult =
IAutomationRemoteOperationResult.from(this);

@override
AutomationRemoteOperationStatus get status =>
_iAutomationRemoteOperationResult.status;

@override
int get extendedError => _iAutomationRemoteOperationResult.extendedError;

@override
int get errorLocation => _iAutomationRemoteOperationResult.errorLocation;

@override
bool hasOperand(AutomationRemoteOperationOperandId operandId) =>
_iAutomationRemoteOperationResult.hasOperand(operandId);

@override
Object? getOperand(AutomationRemoteOperationOperandId operandId) =>
_iAutomationRemoteOperationResult.getOperand(operandId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: deprecated_member_use_from_same_package

import 'package:windows_foundation/windows_foundation.dart';

/// Specifies the possible execution states of a
/// CoreAutomationRemoteOperation.
///
/// {@category enum}
enum AutomationRemoteOperationStatus implements WinRTEnum {
success(0),
malformedBytecode(1),
instructionLimitExceeded(2),
unhandledException(3),
executionFailure(4);

@override
final int value;

const AutomationRemoteOperationStatus(this.value);

factory AutomationRemoteOperationStatus.from(int value) =>
AutomationRemoteOperationStatus.values.firstWhere((e) => e.value == value,
orElse: () => throw ArgumentError.value(
value, 'value', 'No enum value with that value'));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';

import 'automationannotationtyperegistration.dart';
import 'icoreautomationregistrarstatics.dart';

/// Exposes methods for registering new control patterns, properties,
/// events, and annotations.
///
/// {@category class}
class CoreAutomationRegistrar extends IInspectable {
CoreAutomationRegistrar.fromPtr(super.ptr);

static const _className =
'Windows.UI.UIAutomation.Core.CoreAutomationRegistrar';

static AutomationAnnotationTypeRegistration registerAnnotationType(
Guid guid) =>
createActivationFactory(ICoreAutomationRegistrarStatics.fromPtr,
_className, IID_ICoreAutomationRegistrarStatics)
.registerAnnotationType(guid);

static void unregisterAnnotationType(
AutomationAnnotationTypeRegistration registration) =>
createActivationFactory(ICoreAutomationRegistrarStatics.fromPtr,
_className, IID_ICoreAutomationRegistrarStatics)
.unregisterAnnotationType(registration);
}

0 comments on commit 89035f8

Please sign in to comment.