I'm trying to trigger a shortcut keys such as
At first my code is like this:
let source = CGEventSourceCreate(.CombinedSessionState)
let keyDown = CGEventCreateKeyboardEvent(source, 49 as CGKeyCode, true)
let keyUp = CGEventCreateKeyboardEvent(source, 49 as CGKeyCode, false)
But it doesn't work because
.MaskControl has overwriting
.MaskCommand which means I need to use method
CGEventSetFlags only once and set both command key and control key.
So I google it and find that you can do like this in Swift1:
CGEventSetFlags(keyDown, .MaskCommand | .MaskControl). Does it right? Well, I'm use Swift2 and it's not work. And I tried
CGEventSetFlags(keyDown, [.MaskCommand, .MaskControl]), also not work.
So, please tell me the right way to use
CGEventSetFlags in Swift2. Thanks!