Hey! I am working on an applescript, that is supposed to ask Skype over and over again, how many contacts are online etc...
The problem I stumbled upon is the following: in case the script was triggered several times, while Skype was not running and later when Skype is executed, then Skype asks very often (up to 100 times) whether or one wants to all this application to use Skype via the API.
Even if I click each time "allow", the next time Skype is executed the same thing is happening again...
Here is the script I am using:
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
In case you have an idea, whats wrong, I would appreciate your help very much!
Cheers Julian