更改背景位置和菜单栏半透明度 [英] Changing background position and menu bar translucence
问题描述
如何更改桌面背景位置(填充屏幕,适合屏幕,伸展到填充屏幕,中心或平铺)和菜单栏半透明从代码?
基本上,我想仿效桌面和屏幕保护程序首选项窗格中类似的功能。
告诉应用程序系统事件
将第一个桌面的半透明菜单栏设置为false
end tell
$ b b
桌面图片有多种属性 - 更改间隔
,图片
,图片旋转
,图片文件夹
和随机顺序
- 但没有关于背景位置。
使用脚本桥技术更新:
在Terminal中,执行:
sdef / System / Library / CoreServices / System\ Events。 app | sdp -fh --basename SystemEvents
将生成的SystemEvents.h添加到项目中。将它导入到代码中。
然后,在您的代码中,您可以执行以下操作:
SystemEventsApplication * SystemEvents = [SBApplication applicationWithBundleIdentifier:@com.apple.systemevents];
SystemEvents.currentDesktop.translucentMenuBar = FALSE;
您可以进一步阅读脚本桥此处。
How can I change the desktop background position (one of "Fill Screen", "Fit to Screen", "Stretch to Fill Screen", "Center" or "Tile") and the menu bar translucence (on or off) from code?
Basically I'd like to emulate the similar functionality form the "Desktop & Screen Saver" preference pane.
Using AppleScript, you can change the menu bar translucence:
tell application "System Events"
set translucent menu bar of first desktop to false
end tell
There are various properties for the desktop picture – change interval
, picture
, picture rotation
, pictures folder
, and random order
– but nothing about the background position. It may not be possible to configure that from code.
Update with Scripting Bridge technique:
In Terminal, do:
sdef /System/Library/CoreServices/System\ Events.app | sdp -fh --basename SystemEvents
Add the resulting SystemEvents.h into your project. Import it into your code. Add the ScriptingBridge framework to your target.
Then, in your code, you can do something like:
SystemEventsApplication* SystemEvents = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"];
SystemEvents.currentDesktop.translucentMenuBar = FALSE;
You can read further about the Scripting Bridge here.
这篇关于更改背景位置和菜单栏半透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!