dart_winapi 0.3.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

Dart WinApi #

Dart implementation of the Win32 Api https://docs.microsoft.com/en-us/windows/win32/

Documentation of the functions are taken from the official documentation.

How to use #

You can import a single part of the library such as user32.dart or import all the api function importing dart_winapi.dart

Example #

Get cursor position, set it and send left click input and release.

  var point = Point.allocate();
  GetCursorPos(point: point);
  point.x += 10;
  SetCursorPosFromPoint(point);
  MouseEvent(dwFlags: MOUSEEVENTF_LEFTDOWN);
  MouseEvent(dwFlags: MOUSEEVENTF_LEFTUP);
  free(point.addressOf);

To request a new api function to be added please open a new issue.

0.0.1 #

  • Initial version, created by Stagehand

0.0.2 #

  • Added GetKeyState

0.1.0 #

  • Added CallNextHookEx
  • Added GetMessage
  • Added SetWindowsHookExA (still experimental)

0.2.0 Breaking changes #

  • Renamed some function to don't include the A prefix, and added the textFormat parameter to chose between either utf16 or ascii
  • Added RegisterHotKey
  • Disable SetWindowHook which cause the entire library to fail

0.3.0 Breaking changes #

  • Changed api to use optional named parameters
  • Added short hand to set the cursor position given a point struct

0.3.1 #

  • Added GetActiveWindow

0.3.2 #

  • Added ShowWindow

0.3.3 #

  • Added GetForegroundWindow

example/example.dart

import 'dart:ffi';

import 'package:dart_winapi/user32.dart';
import 'package:ffi/ffi.dart';

void main() {
  var point = Point.allocate();
  GetCursorPos(point: point);
  point.x += 10;
  SetCursorPosFromPoint(point: point);
  MouseEvent(dwFlags: MOUSEEVENTF_LEFTDOWN);
  MouseEvent(dwFlags: MOUSEEVENTF_LEFTUP);
  free(point.addressOf);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_winapi: ^0.3.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_winapi/dart_winapi.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Mar 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/user32/get_message.dart. (-0.50 points)

Analysis of lib/src/user32/get_message.dart reported 1 hint:

line 3 col 8: Unused import: 'package:ffi/ffi.dart'.

Fix lib/src/user32/send_input.dart. (-0.50 points)

Analysis of lib/src/user32/send_input.dart reported 1 hint:

line 9 col 8: Unused import: 'package:ffi/ffi.dart'.

Fix lib/src/user32/set_windows_hook_ex.dart. (-0.50 points)

Analysis of lib/src/user32/set_windows_hook_ex.dart reported 1 hint:

line 50 col 7: The declaration '_expReturn' isn't referenced.

Format lib/kernel.dart.

Run dartfmt to format lib/kernel.dart.

Format lib/src/user32/show_window.dart.

Run dartfmt to format lib/src/user32/show_window.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
ffi ^0.1.3 0.1.3
meta ^1.1.8 1.1.8