0

如何从代码更改桌面背景位置(“填充屏幕”、“适合屏幕”、“拉伸以填充屏幕”、“中心”或“平铺”之一)和菜单栏半透明(打开或关闭)?

基本上我想从“桌面和屏幕保护程序”首选项窗格中模拟类似的功能。

4

1 回答 1

1

使用 AppleScript,您可以更改菜单栏的半透明:

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

桌面图片有各种属性 - change intervalpicturepicture rotationpictures folderrandom 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;

您可以在此处进一步了解脚本桥。

于 2012-04-13T03:58:32.383 回答