• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Programmatically toggle display to white on black
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatically toggle display to white on black


  • Subject: Re: Programmatically toggle display to white on black
  • From: Philip Dow <email@hidden>
  • Date: Mon, 26 Jun 2006 19:08:20 +0200

This will be under the control of the user. It is for use in full screen text editing mode under low light conditions.

The trick is as follows:

CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, true); // command
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)58, true); // option
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)59, true); // ctrl


CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)28, true); // number 8 CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)28, false); CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)59, false); CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)58, false); CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, false);

Apple documentation specifically warns against using this method and instead recommends CGCreateKeyboardEvent. That method crashes every time as I call it so I'm not bothering with it. Applescript was also an option:

tell application "System Events"
	tell application process "MyHappyProcess"
		key code 28 using {command down, option down, control down}
	end tell
end tell

-Phil

On Jun 26, 2006, at 4:01 PM, Scott Thompson wrote:


On Jun 24, 2006, at 12:53 PM, Philip Dow wrote:

Is anyone aware of a way to switch the display into white on black mode then eventually back? This is a feature available via Universal Access that I would like to use programatically.

I've searched through the CGDisplay docs, Quartz stuff, NSScreen, - Display and -ColorSpace but haven't found anything. Cocoadev doesn't seem to have anything on the topic and the Apple lists only produced an unanswered request from 2003.

I'd be fine with sending a command-alt-ctrl-8 keyboard shortcut event to the system, but I don't know how to do this either.

As a general rule, this is something that should be under the control of the user, and the operating system. You might explain a bit more why you want to do this from your application. Are you creating some kind of assistive device?


Scott



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Programmatically toggle display to white on black
      • From: John Stiles <email@hidden>
References: 
 >Programmatically toggle display to white on black (From: Philip Dow <email@hidden>)
 >Re: Programmatically toggle display to white on black (From: Scott Thompson <email@hidden>)

  • Prev by Date: Problem with application menu
  • Next by Date: Re: Simplest Dongle Method? Making a file uncopyable on CD?
  • Previous by thread: Re: Programmatically toggle display to white on black
  • Next by thread: Re: Programmatically toggle display to white on black
  • Index(es):
    • Date
    • Thread