Skype Mac API - 使用 AppleScript 还是 5 年前的 API?

发布于 2024-09-04 01:32:31 字数 293 浏览 9 评论 0原文

我有一个 x86_64 应用程序,我希望可以选择读取 Skype 状态消息。然而,已有 5 年历史的 Skype mac 框架是 32 位的,如果有办法在 64 位应用程序中编译该框架,我还没有找到。

我的问题基本上是,我应该如何去做呢?我实际上只需要获取和设置 USERSTATUS AWAY/ONLINE 字符串。

使用 AppleScript,每次都会弹出“Skype 是否应该允许此操作”对话框。这是非常低效且令人恼火的。

建议?

我正在考虑编写一个 32 位 CLI 包装器,但这似乎有点矫枉过正。

I have a x86_64 app that I would like to have optionally read Skype status messages. However, the 5 year old skype mac framework is 32-bit, and if there is a way to have that compile within a 64-bit app, I haven't found it.

My question is, basically, how should I go about doing this? I really only need to get and set the USERSTATUS AWAY/ONLINE string.

Using AppleScript, a "Should Skype allow this" dialog pops up... every time. This is highly inefficient and downright irritating.

Advice?

I'm considering writing a 32-bit CLI wrapper, but that seems like overkill.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

二智少女猫性小仙女 2024-09-11 01:32:31

我使用通知观察器了解到 Skype 的 API 只能与 NSDistributedNotifications 配合使用。对于 64 位应用程序来说,重复这些通知就像一个魅力。

I used Notification Watcher to learn that Skype's API just works with NSDistributedNotifications. Repeating those notifications worked like a charm for a 64bit app.

弥繁 2024-09-11 01:32:31

如果我没记错的话,一旦您允许权限,权限对话框就不会出现。

我的 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

If I remember right, the permission dialog does not come up once you allow permission.

I my Skype Apple Scripts I have to GUI to click them. If they come up.

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
太阳男子 2024-09-11 01:32:31

我发现如果您通过查看捆绑内容打开“Skype.app”->您将找到 64 位和 32 位的框架 skype.framework

I've found out that if you open "Skype.app" by viewing bundle contents -> Frameworks you'll find a 64bit and 32bit skype.framework

作死小能手 2024-09-11 01:32:31

这是针对 Twitter 请求的回复。我很久以前问过这个问题后就使用了这段代码。我不需要研究 Skype API,因为它工作得很好,但我想自从我上次尝试使用它以来它已经更新了。无论如何...

这是我与 Skype 通信时使用的 NSDistributedNotifications 列表:

SKSkypeAPI通知

SKSkypeAttachResponse

SKSkype 可用

SKA可用性更新

SKSkype将退出

就像任何其他类型的 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 = @"";
                }
    
            }
        
        }
    }

This is an answer in reply to a request from twitter. I used this code after asking this question way back when. I have not needed to look into the Skype API since this works just fine, but I imagine that its been updated since I last tried to use it. Anyhow...

Here's a list of the NSDistributedNotifications that I use when communicating to skype:

SKSkypeAPINotification

SKSkypeAttachResponse

SKSkypeBecameAvailable

SKAvailabilityUpdate

SKSkypeWillQuit

Just like any other kind of NSDistributedNotification, you simply register and process the results:

[[NSDistributedNotificationCenter defaultCenter]
     addObserver:self selector:@selector(setStatusAfterQuit:) 
     name:@"SKSkypeWillQuit"
     object:nil 
     suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];

These are the iVars that I keep to sync with Skype:

NSString *applicationName;
NSString *mostRecentStatus;
NSString *mostRecentStatusMessage;
NSString *mostRecentUsername;
int APIClientID;
BOOL isConnected;
BOOL needToSetMessage;

NSString *nextMessage;
NSString *nextStatus;

Here's an example of how to connect to 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];
    }
}

Here's an example of getting the status message (after you've registered with 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 = @"";
                }
    
            }
        
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文