Hack96.Convert Your Friends List to Fast-Dial Shortcuts


Hack 96. Convert Your Friends List to Fast-Dial Shortcuts

Convert contacts from your friends list into fast-dial shortcuts so that they're just a click away.

Works with: Windows version of Skype.

In "Add Fast-Dial Shortcuts to Your Menu or Desktop" [Hack #49], you saw how to create a shortcut that enabled you to call a contact with just a click or two of your mouse, or with a hotkey sequence. In this hack, we'll automate the process of converting everyone in your Skype friends list (also known as your buddies list) into shortcuts.

The following VBScript, shortcuts.vbs, constructs a list of friends and creates a shortcut icon for each one. If you have 15 or more friends, first you are prompted to confirm that you do indeed want one icon per friend. This is to prevent your desktop or menu from becoming cluttered with shortcut icons.

 ' File: shortcuts.vbs ' Global variables Dim g_objShell        ' Scripting shell object Dim g_objFSO          ' File system object Dim g_strSkypePath    ' Path of Skype executable Dim g_strShortcutPath ' Path to store shortcuts Dim g_objSkypeAPI     ' SkypeAPI interface object Dim g_strPrefix       ' Prefix to add to shortcuts  Dim g_bOnDesktop      ' True=icons on desktop, False=in menu ' Return True if friends list is below 15 entries or if user approves  Function CheckFriendListSize     Dim iFriends     iFriends = g_objSkypeAPI.GetFriendList.Count     If iFriends = 0 Then         CheckFriendListSize = False     Else         strTitle = "Create " & iFriends         if iFriends <> 1 Then strTitle = strTitle + "s"         strTitle = strTitle + " Shortcuts"         i = g_objShell.Popup( _             "Click ""Yes"" to create shortcuts on Desktop, "+vbCr+ _              "Click ""No"" to create shortcuts in Start Menu, "+vbCr+ _             "Click ""Cancel"" to abort", 0, strTitle, 35)         If i = 6 Then             CheckFriendListSize= True             g_bOnDesktop = True         ElseIf i = 7 Then             CheckFriendListSize= True             g_bOnDesktop = False         Else              CheckFriendListSize= False         End If      End If  End Function ' Create a shortcut for the Skype User object  Sub CreateSkypeShortcut(User)     Dim strFileName     ' Build a file name to display     If Len(User.DisplayName) > 0 Then         strFileName = User.DisplayName + ".lnk"     ElseIf Len(User.FullName) > 0 Then         strFileName = User.FullName + ".lnk"     Else         strFileName = User.Handle + ".lnk"     End If     ' Remove any bad characters     strFileName = Replace(strFileName, "|", "")     strFileName = Replace(strFileName, "\", "")     strFileName = Replace(strFileName, ":", "")     ' Create the shortcut     strFileName = g_strPrefix + strFileName     set objShellLink = _         g_objShell.CreateShortcut( g_objFSO.BuildPath( _                                    g_strShortcutPath, strFileName))      objShellLink.TargetPath = "callto://" + User.Handle      objShellLink.IconLocation = g_strSkypePath + ", 5"      objShellLink.WindowStyle = 1      objShellLink.Description = "Start Skype"      strSpeedDial = User.SpeedDial      If (strSpeedDial >= "0") And (strSpeedDial <= "9") Then         objShellLink.HotKey = "Ctrl+Shift+" + strSpeedDial     End If     objShellLink.Save End Sub ' Main script begins here Set g_objShell = WScript.CreateObject("WScript.Shell") Set g_objFSO = WScript.CreateObject("Scripting.FileSystemObject") Set g_objSkypeAPI = WScript.CreateObject("SkypeAPI.Access") g_objSkypeAPI.ConnectAndWait 15000 If CheckFriendListSize Then     ' Get the location of Skype for icons     g_strSkypePath = g_objShell.RegRead( _                      "HKLM\Software\Skype\Phone\SkypePath")     If g_bOnDesktop Then          g_strShortcutPath = g_objShell.SpecialFolders("Desktop")          g_strPrefix = "Skype - "     Else         g_strShortcutPath = g_objFSO.BuildPath( _                             g_objShell.SpecialFolders("StartMenu"), _                              "Skype Shortcuts")         g_strPrefix = ""     End If     ' Delete any existing shortcuts if folder exists     If g_objFSO.FolderExists(g_strShortcutPath) Then         For Each objFile in _             g_objFSO.GetFolder(g_strShortcutPath).Files              If (StrComp(g_objFSO.GetExtensionName( _                         objFile.Name), "lnk", 1) = 0) And _                (Left(objFile.Name, len(g_strPrefix)) = _                 g_strPrefix) Then                    objFile.Delete            End If        Next    ' Or create the folder    Else     g_objFSO.CreateFolder g_strShortcutPath    End If    ' Iterate through users and create shortcuts    For Each objUser in g_objSkypeAPI.GetFriendList    CreateSkypeShortcut objUser    g_iCtr = g_iCtr + 1 Next ' Show an "all done" message  g_objShell.Popup g_objSkypeAPI.GetFriendList.Count & _     " Shortcuts Created", 0, "Process Complete", 64  End If 




Skype Hacks
Skype Hacks: Tips & Tools for Cheap, Fun, Innovative Phone Service
ISBN: 0596101899
EAN: 2147483647
Year: 2005
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net