views:

438

answers:

1

Dear All!

I am working on an Applescript, which does nothing fancy but asking Skype how many contacts are online... However, when the script was executed several times, while Skype was not running, and finally is running, then Skype opens uncountable dialog windows with a Skype API Security Request, asking whether or not to allow the Applescript to use Skype.

Unfortunately I can't find a solution for this problem. In case you have an idea, I would appreciate your help very much!

Thanks in advance! Julian

Here the mentioned script:

set onlineFriendsCount to 0
set resultArray to {}

-- define a string replace method
on ReplaceText(theString, findStr, replaceStr)

set current_Delimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to findStr set sList to every text item of theString set AppleScript's text item delimiters to replaceStr set newString to sList as string set AppleScript's text item delimiters to current_Delimiters return newString end ReplaceText

on countString(myText, myDelimiter)

set {oldDelimiters, AppleScript's text item delimiters} to {AppleScript's text item delimiters, myDelimiter} set myCounter to (count text items of myText) - 1 set AppleScript's text item delimiters to oldDelimiters

return myCounter
end countString

tell application "System Events"

set the active_flag to (name of processes) contains "Skype" end tell if active_flag then

tell application "Skype"

-- find out first the number of online "friends" (this is skype jargon) set groups to send command "SEARCH GROUPS HARDWIRED" script name "getType" set groupList to words of groups

set the groupCount to the number of items in groupList

repeat with i from 2 to the groupCount set group to item i of groupList

set groupType to send command "GET GROUP " & group & " TYPE" script name "getType" if groupType contains "ONLINE" then set onlineFriends to send command "GET GROUP " & group & " USERS" script name "getType" --set onlineFriends to words of 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

end if end repeat

-- get the mood message set moodMessage to send command "GET PROFILE MOOD_TEXT" script name "getType" set moodStrings to my ReplaceText(moodMessage, "PROFILE MOOD_TEXT ", "") set moodStrings to my ReplaceText(moodStrings, ",", "") set resultArray to resultArray & moodStrings -- get the online status set onlineStatus to send command ("GET USERSTATUS") script name "getType" set onlineStatus to my ReplaceText(onlineStatus, "USERSTATUS ", "") set resultArray to resultArray & onlineStatus -- get the number of active chats set activeChats to send command "SEARCH ACTIVECHATS" script name "getType" set activeChats to my countString(activeChats, "#") set resultArray to resultArray & activeChats -- check if there are ongoing calls set activeCalls to send command "SEARCH ACTIVECALLS" script name "getType" set callNum to count of words of activeCalls if callNum > 1 then set resultArray to resultArray & true else set resultArray to resultArray & false end if

return resultArray

end tell

else

set resultArray to {0, "", "OFFLINE", 0, false}

end if
+1  A: 

Hi,

The security request doesn't have anything to do with your script. It should pop-up when executing any scripts or Skype API clients. Please just select the first option "allow this application to use Skype" and you will not see this pop-up any more.

Janno

Janno Teelem