'Simulating hold Command key to Multi-select dont work on macOS

Trying to simulate holding command key to multi-select on macOS, but it doesnt work, did I miss something?Key Codes

    CGEventSourceRef eventSrc = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
    CGEventRef event = CGEventCreateKeyboardEvent(eventSrc, 0x37, true);
    CGEventSetType(event, kCGEventFlagsChanged);
    CGEventSetFlags(event, flags);
    CGEventPost(kCGHIDEventTap, event);
    CFRelease(eventSrc);
    CFRelease(event);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source