Skip to content

Multiple Screen Screenshot #603

Answered by ilopX
tbsmanish asked this question in Q&A
Discussion options

You must be logged in to vote
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart';

void main() {
  for (final display in Displays.all()) {
    if (display.isTurnOn) {
      display.saveScreenshot("${display.name}.bmp");
    }
  }
}

class Displays {
  static Iterable<Display> all() sync* {
    final device = calloc<DISPLAY_DEVICE>()..ref.cb = sizeOf<DISPLAY_DEVICE>();
    var deviceIndex = 0;

    while (EnumDisplayDevices(nullptr, deviceIndex, device.cast(), 0) != 0) {
      final isTurnOn = device.ref.StateFlags != 0;
      yield Display(device.ref.DeviceName, isTurnOn);
      deviceIndex++;
    }
  }
}

class Display {
  final String rawName;
  final bool isTurnOn;

  Display(this.…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by halildurmus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #600 on November 24, 2022 23:31.