我有一个 x86_64 应用程序,我希望可以选择读取 Skype 状态消息。但是,5 年前的 Skype mac 框架是 32 位的,如果有办法在 64 位应用程序中编译,我还没有找到。
我的问题是,基本上,我应该怎么做呢?我真的只需要获取和设置 USERSTATUS AWAY/ONLINE 字符串。
使用 AppleScript,每次都会弹出一个“Skype 是否允许这样做”对话框。这是非常低效且令人讨厌的。
建议?
我正在考虑编写一个 32 位 CLI 包装器,但这似乎有点矫枉过正。
我有一个 x86_64 应用程序,我希望可以选择读取 Skype 状态消息。但是,5 年前的 Skype mac 框架是 32 位的,如果有办法在 64 位应用程序中编译,我还没有找到。
我的问题是,基本上,我应该怎么做呢?我真的只需要获取和设置 USERSTATUS AWAY/ONLINE 字符串。
使用 AppleScript,每次都会弹出一个“Skype 是否允许这样做”对话框。这是非常低效且令人讨厌的。
建议?
我正在考虑编写一个 32 位 CLI 包装器,但这似乎有点矫枉过正。
我使用 Notification Watcher 了解到 Skype 的 API 只适用于 NSDistributedNotifications。重复这些通知就像 64 位应用程序的魅力一样。
查看 Scripting Bridge:Cocoa Scripting Bridge 编程指南简介
如果我没记错的话,一旦您允许权限,权限对话框就不会出现。
我是我的 Skype Apple 脚本,我必须使用 GUI 才能单击它们。如果他们上来。
tell application "Skype" to launch
delay 15
(* this part if the security API window comes up*)
tell application "System Events"
tell application process "Skype"
if exists (radio button "Allow this application to use Skype" of radio group 1 of window "Skype API Security") then
click
delay 0.5
click button "OK" of window "Skype API Security"
end if
end tell
end tell
delay 5
我发现如果您通过查看捆绑内容打开“Skype.app”-> 框架,您会发现 64 位和 32 位 skype.framework
这是对推特请求的回复。我在问这个问题后使用了这段代码。我不需要查看 Skype API,因为它工作得很好,但我想自从我上次尝试使用它以来它已经更新了。无论如何...
这是我与 Skype 通信时使用的 NSDistributedNotifications 列表:
SKSkypeAPI通知
SKSkype附加响应
SKSkype变得可用
SKA可用性更新
SKSkypeWillQuit
就像任何其他类型的 NSDistributedNotification 一样,您只需注册并处理结果:
[[NSDistributedNotificationCenter defaultCenter]
addObserver:self selector:@selector(setStatusAfterQuit:)
name:@"SKSkypeWillQuit"
object:nil
suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
这些是我与 Skype 保持同步的 iVar:
NSString *applicationName;
NSString *mostRecentStatus;
NSString *mostRecentStatusMessage;
NSString *mostRecentUsername;
int APIClientID;
BOOL isConnected;
BOOL needToSetMessage;
NSString *nextMessage;
NSString *nextStatus;
以下是如何连接到 Skype 的示例:
-(void) skypeConnect{
if (!isConnected){
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"SKSkypeAPIAvailabilityRequest"
object:nil
userInfo:nil
deliverImmediately:YES];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"SKSkypeAPIAttachRequest"
object:applicationName
userInfo:nil
deliverImmediately:YES];
}
}
这是获取状态消息的示例(在您注册 Skype 之后):
-(void) processNotification:(NSNotification *) note{
if ([[note name] isEqualToString:@"SKSkypeAttachResponse"]){
if([[[note userInfo] objectForKey:@"SKYPE_API_ATTACH_RESPONSE"] intValue] == 0){
NSLog(@"Failed to connect to Skype.");
isConnected = NO;
}else {
NSLog(@"Connected to Skype.");
APIClientID = [[[note userInfo] objectForKey:@"SKYPE_API_ATTACH_RESPONSE"] intValue];
isConnected = YES;
[self sendCommand:@"GET PROFILE MOOD_TEXT"];
if (needToSetMessage){
[self sendCommand:[NSString stringWithFormat:@"SET USERSTATUS %@",nextStatus]];
[self sendCommand:[NSString stringWithFormat:@"SET PROFILE MOOD_TEXT %@",nextMessage]];
needToSetMessage = NO;
nextMessage = @"";
nextStatus = @"";
}
}
}
}