Skip to content

Instantly share code, notes, and snippets.

@hechen
Created May 4, 2019 11:02
Show Gist options
  • Save hechen/991c624945828458e9b219164d4fac7d to your computer and use it in GitHub Desktop.
Save hechen/991c624945828458e9b219164d4fac7d to your computer and use it in GitHub Desktop.
toggle cocoa App dockless on or off
func toggleDock(show: Bool) -> Bool {
// ProcessApplicationTransformState
  let transformState = show ? 
  // show to foreground application 
  // or not show to background application
  ProcessApplicationTransformState(kProcessTransformToForegroundApplication) 
 : ProcessApplicationTransformState(kProcessTransformToUIElementApplication)
// transform current application type.
 var psn = ProcessSerialNumber(highLongOfPSN: 0, lowLongOfPSN: UInt32(kCurrentProcess))
 return TransformProcessType(&psn, transformState) == 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment