Version: 1.0

Posted: 2006-02-23

Build Requirements: Xcode 2.2, Universal Binary

Runtime Requirements: Mac OS X 10.4

View Source Code:

Download Sample (“iTunesController.zip”, 49.1K)
Download Sample (“iTunesController.dmg”, 107.5K)



Description

iTunesController makes use of the RegisterEventHotKey API which allows you to register to receive hotkey events while in the foreground or background. Registering for a hotkey such as <command>-P causes problems because, once registered for a hotkey, that event does NOT get propagated to the frontmost application, and in this case, would intercept it from printing. We overcome this problem, in the routine PostHotKeyKeyboardEvent, by first unregestering for hotkeys, posting the event to the frontmost application using CGPostKeyboardEvent, and then re-registering for hotkeys. This sample also demonstrates how to communicate with iTunes through an AppleScript in our timer routine, PeriodicTimerAction.

Builds as a Universal Binary

Document Revision History

Date Notes
2006-02-23iTunesController allows you to control iTunes without having to bring it to the foreground.

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.