scripting-bridge

OS X: Move window from Python

时间秒杀一切 提交于 2020-06-13 04:32:14
问题 I'm trying to move around windows programatically from Python on OS X. I found a snippet of AppleScript here on Stackoverflow which does this, but I'd like to do it in Python or another "real" scripting language. This is my Python script, which does not work. I wrote the output of print commands below each of them. #!/usr/bin/python from Foundation import * from ScriptingBridge import * app = SBApplication.applicationWithBundleIdentifier_("com.apple.SystemEvents") finderProc = app.processes()

Finder Scripting Bridge to Shutdown

佐手、 提交于 2020-01-23 04:08:09
问题 I tried to use Application Scripting Bridge to send my Mac to sleep. The code look like the following: #import "Finder.h" FinderApplication *Finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.finder"]; [Finder sleep]; But it doesn't work. Any ideas why it doesn't work? No compiling errors or warnings, but it doesn't work… 回答1: As I posted in this answer, I've been using the following code for over 8 years without issues: MDRestartShutdownLogout.h: #import <CoreServices

Get iTunes Artwork for Current Song with ScriptingBridge

China☆狼群 提交于 2020-01-01 05:15:05
问题 I have been trying to figure out how to get the iTunes artwork for the currently playing song with scripting bridge. I have gotten to a point where it works for some songs, but for others, I get a SIGABRT. I'm not sure what the issue could be, so any help would be greatly appreciated. Here is what I have so far: iTunesApplication * iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; NSImage *songArtwork; iTunesTrack *current = [iTunes currentTrack]; iTunesArtwork

Get iTunes Artwork for Current Song with ScriptingBridge

拟墨画扇 提交于 2020-01-01 05:15:05
问题 I have been trying to figure out how to get the iTunes artwork for the currently playing song with scripting bridge. I have gotten to a point where it works for some songs, but for others, I get a SIGABRT. I'm not sure what the issue could be, so any help would be greatly appreciated. Here is what I have so far: iTunesApplication * iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; NSImage *songArtwork; iTunesTrack *current = [iTunes currentTrack]; iTunesArtwork

Scripting bridge and generate Microsoft Word header file

怎甘沉沦 提交于 2019-12-31 03:01:26
问题 I’m trying to get a Cocoa application to connect to Microsoft Word, and from my search it seems that the only way, is to use Scripting Bridge and generate a word header file. However, using the approach explained in Apples example project SBSendEmail: sdef "$INPUT_FILE_PATH" | sdp -fh -o "$DERIVED_FILES_DIR" --basename "$INPUT_FILE_BASE" --bundleid `defaults read "$INPUT_FILE_PATH/Contents/Info" CFBundleIdentifier` Does not generate a usable word header file, I get the following: sdp:

Scripting bridge and generate Microsoft Word header file

我是研究僧i 提交于 2019-12-31 03:01:08
问题 I’m trying to get a Cocoa application to connect to Microsoft Word, and from my search it seems that the only way, is to use Scripting Bridge and generate a word header file. However, using the approach explained in Apples example project SBSendEmail: sdef "$INPUT_FILE_PATH" | sdp -fh -o "$DERIVED_FILES_DIR" --basename "$INPUT_FILE_BASE" --bundleid `defaults read "$INPUT_FILE_PATH/Contents/Info" CFBundleIdentifier` Does not generate a usable word header file, I get the following: sdp:

Cocoa Scripting Bridge and <contents> element

烈酒焚心 提交于 2019-12-24 21:33:16
问题 So, the application I'm trying to script has a scripting definition file that includes a <contents> element, which is an "implicitly specified container." The question, how do I get at what's inside this element using Scripting Bridge? Or alternatively, how do I send the Apple Event necessary to retrieve it and then transform what I get back into an SBObject? I already tried: [document nameOfKey] document.nameofKey [document contents] document.contents 回答1: Not sure if this will help but I

Programmatically enter text into any application

試著忘記壹切 提交于 2019-12-24 02:35:09
问题 Is there a proof-of-concept Objective-C executable that enters some text into an application and then clicks the mouse, using Apple events and not AppleScript? e.g. the AppleScript equivalent of tell application "System Events" tell process "Safari" keystroke "Hello World" click end tell end tell It should work on Mac OS X 10.9, preferably be future oriented (backwards compatibility doesn't matter). The context is that I will be calling the Objective-C code from another language. I'm saying

Swift: Undefined Symbols: iTunesApplication

二次信任 提交于 2019-12-23 21:29:00
问题 I'm trying to create Swift OS X app now, and found difficulty using ScriptingBridge. I included proper iTunes.h file, and Xcode is not giving any error when I wrote "iTunesApplication" as type. However, when I compile(run) the app, it gives me error :( Does anybody know about this issue? Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_iTunesApplication", referenced from: __TFC12LoveYouChloe11AppDelegate10showWindowfS0_FPSs9AnyObject_T_ in AppDelegate.o ld: symbol(s) not found for

in scripting bridge how can i send shortcut with 2 modifiers?

坚强是说给别人听的谎言 提交于 2019-12-23 05:32:38
问题 I was trying to replicate "take a screenshot shortcut" (cmd+shift+3) via cocoa and scripting bridge SystemEventsApplication * sysEvent = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"]; [sysEvent keyCode:20 using:SystemEventsEMdsCommandDown]; but i can't send more than one SystemEventsEMds to the method. In applescript is as easy as key code 20 using {command down, shift down} 回答1: I kinda solved this. I was trying to get a cmd+shift+3 that serves, as all of you know