2012-04-12 60 views
0

如何更改桌面背景位置(「填充屏幕」,「適合屏幕」,「拉伸填充屏幕」,「居中」或「平鋪」)和菜單之一酒吧半透明(打開或關閉)的代碼?更改背景位置和菜單欄半透明

基本上我想效仿類似「Desktop &屏幕保護程序」偏好窗格的功能。

回答

1

使用AppleScript,您可以更改菜單欄半透明:

tell application "System Events" 
    set translucent menu bar of first desktop to false 
end tell 

有針對桌面圖片的各種屬性 - change intervalpicturepicture rotationpictures folder,並random order - 但沒有對背景的位置。從代碼中配置它可能是不可能的。


更新與腳本橋接技術:

在終端,這樣做:

sdef /System/Library/CoreServices/System\ Events.app | sdp -fh --basename SystemEvents 

添加所產生的SystemEvents.h到項目中。將其導入到您的代碼中。將ScriptingBridge框架添加到您的目標。

然後,在你的代碼,你可以這樣做:

SystemEventsApplication* SystemEvents = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"]; 
SystemEvents.currentDesktop.translucentMenuBar = FALSE; 

您可以進一步閱讀有關腳本橋here

+0

我可以使用Objective-C來做同樣的事嗎? – rid 2012-04-13 10:25:42

+0

我已經使用Scripting Bridge技術更新了我的答案。 – 2012-04-13 10:54:01

+0

如果我要通過Mac App Store發佈應用程序,這是特定於我的系統,還是會在任何地方運行? – rid 2012-04-13 10:55:55