【问题标题】:Skype Mac API - Use AppleScript or 5 year old API?Skype Mac API - 使用 AppleScript 或 5 年前的 API?
【发布时间】:2010-06-06 05:37:10
【问题描述】:

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

我的问题是,基本上,我应该怎么做呢?我真的只需要获取和设置 USERSTATUS AWAY/ONLINE 字符串。

使用 AppleScript,每次都会弹出一个“Skype 是否允许这样做”对话框。这是非常低效和彻头彻尾的恼人。

建议?

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

【问题讨论】:

    标签: objective-c cocoa xcode x86-64 skype


    【解决方案1】:

    我使用 Notification Watcher 了解到 Skype 的 API 仅适用于 NSDistributedNotifications。重复这些通知就像 64 位应用程序的魅力一样。

    【讨论】:

      【解决方案2】:

      【讨论】:

      • 好吧,经过一两天的处理,它与 AppleScript 存在完全相同的问题 - 无法保存“我已获得使用 Skype 的权限”对话框。还有其他选择吗?
      【解决方案3】:

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

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

      【讨论】:

        【解决方案4】:

        我发现如果你通过查看捆绑内容打开“Skype.app” -> 框架你会发现一个 64 位和 32 位的 skype.framework

        【讨论】:

          【解决方案5】:

          这是对 twitter 请求的回复。我在问这个问题后使用了这段代码。我不需要查看 Skype API,因为它工作得很好,但我想自从我上次尝试使用它以来它已经更新了。总之……

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

          SKSkypeAPI通知

          SKSkypeAttachResponse

          SKSkype 变为可用

          SKAvailabilityUpdate

          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 = @"";
                          }
              
                      }
                  
                  }
              }
          

          【讨论】:

          • 使用这种方法我只能得到SKSkypeBecameAvailable 通知。
          猜你喜欢
          • 2021-03-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-05-13
          • 1970-01-01
          相关资源
          最近更新 更多