通过Applescript调用Skype API会触发多达100个安全授权请求

通过Applescript调用Skype API会触发多达100个安全授权请求,api,macos,applescript,skype,Api,Macos,Applescript,Skype,我正在编写一个Applescript,它除了询问Skype有多少联系人在线外,没有什么特别的功能。。。但是,当脚本在Skype未运行且最终正在运行的情况下多次执行时,Skype会打开带有Skype API安全请求的无数对话框窗口,询问是否允许Applescript使用Skype 不幸的是,我找不到解决这个问题的办法。 如果你有什么想法,我将非常感谢你的帮助 提前谢谢! 朱利安 下面是提到的脚本: set onlineFriendsCount to 0 set resultArray to {}

我正在编写一个Applescript,它除了询问Skype有多少联系人在线外,没有什么特别的功能。。。但是,当脚本在Skype未运行且最终正在运行的情况下多次执行时,Skype会打开带有Skype API安全请求的无数对话框窗口,询问是否允许Applescript使用Skype

不幸的是,我找不到解决这个问题的办法。 如果你有什么想法,我将非常感谢你的帮助

提前谢谢! 朱利安

下面是提到的脚本:

set onlineFriendsCount to 0
set resultArray to {}

-- define a string replace method
on ReplaceText(theString, findStr, replaceStr)
将当前_分隔符设置为AppleScript的文本项分隔符 将AppleScript的文本项分隔符设置为findStr 将sList设置为字符串的每个文本项 将AppleScript的文本项分隔符设置为replaceStr 将newString设置为sList as string 将AppleScript的文本项分隔符设置为当前分隔符 返回新闻字符串 结束替换文本

on countString(myText, myDelimiter)
将{oldDelimiters,AppleScript的文本项分隔符}设置为{AppleScript的文本项分隔符,myDelimiter} 将myCounter设置为(计算myText的文本项)-1 将AppleScript的文本项分隔符设置为oldDelimiters

return myCounter
end countString

tell application "System Events"
将active_标志设置为(进程名称)包含“Skype” 结束语 如果激活了_标志,则

告诉应用程序“Skype”

--首先找出在线“朋友”的数量(这是skype术语) 将组设置为发送命令“搜索组硬连线”脚本名称“getType” 将groupList设置为组中的单词

将groupCount设置为groupList中的项目数

重复从2到groupCount的i 将组设置为groupList的项目i

将groupType设置为发送命令“GET GROUP”&GROUP&“TYPE”脚本名“getType” 如果groupType包含“ONLINE”,则 将onlineFriends设置为发送命令“GET GROUP”&组和“USERS”脚本名“getType” --将onlineFriends设置为onlineFriends的单词

-- setting the new string delimiter for chunking the resulting list
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set onlineFriendsList to every text item of onlineFriends
set AppleScript's text item delimiters to oldDelimiters

set AppleScript's text item delimiters to ","
set onlineFriendsCount to (number of items in onlineFriendsList)
-- this is a little workaround to get the correct number of online contacts:
if onlineFriendsCount = 1 then
 set resultArray to resultArray & 0
else
 set resultArray to resultArray & onlineFriendsCount
end if
exit repeat
如果结束 结束重复

--获得情绪信息 将moodMessage设置为发送命令“GET PROFILE MOOD_TEXT”脚本名“getType” 将moodStrings设置为my ReplaceText(moodMessage,“配置文件MOOD_TEXT”和“”) 将MoodString设置为my ReplaceText(MoodString、、) 将resultArray设置为resultArray和MoodString --获取联机状态 将onlineStatus设置为发送命令(“GET USERSTATUS”)脚本名“getType” 将onlineStatus设置为my ReplaceText(onlineStatus,“USERSTATUS”,“”) 将resultArray设置为resultArray&Online状态 --获取活动聊天的数量 设置activeChats以发送命令“搜索activeChats”脚本名“getType” 将activeChats设置为my countString(activeChats,“#”) 将resultArray设置为resultArray&activeChats --检查是否有正在进行的呼叫 设置activeCalls以发送命令“搜索activeCalls”脚本名“getType” 将callNum设置为activeCalls的字数 如果callNum>1,则 将resultArray设置为resultArray&true 其他的 将resultArray设置为resultArray(&false) 如果结束

返回结果数组

结束语

else
将resultArray设置为{0,,“脱机”,0,false}

end if

安全请求与您的脚本无关。它应该在执行任何脚本或Skype API客户端时弹出。请只选择第一个选项“允许此应用程序使用Skype”,您将不再看到此弹出窗口


詹诺

不幸的是,这对我不起作用。如果运行applescript,然后重新打开skype,apple脚本(通过geektool使用)运行几秒钟,然后消失。即使我按下“允许此应用程序使用skype”,apple脚本仍然无法工作。