getActiveAppIdentifier method

String? getActiveAppIdentifier()

Get the bundle identifier of the active application.

On macOS: returns bundle ID like "com.apple.Safari" On Windows: returns process name like "notepad.exe" Returns null if not found.

Implementation

String? getActiveAppIdentifier() {
  const bufferSize = 256;
  final buffer = calloc<Char>(bufferSize);

  try {
    final length = _bindings.GetActiveAppIdentifier(buffer, bufferSize);
    if (length == 0) return null;
    return buffer.cast<Utf8>().toDartString(length: length);
  } finally {
    calloc.free(buffer);
  }
}