Archive for the 'Technology' Category

Outlook to Skype SMS

Thursday, March 11th, 2010

I wanted to know when a process on a customer’s server had failed. In fact I wanted it to wake me up in the middle of the night so that I could fix it.

About the only usable outbound communication supported by the server is email, but my phone is not email capable (well it is, but not for work emails!).

So a colleague mentioned using MSN chat or Skype chat to send comments, and that set me wondering…

Skype has a COM library which can be used to interface with the Skype application. (A reinstall of Skype with the Extras Manager option ticked was needed to get the library installed.) The Skype4COM library allows you to send SMS. Outlook of course allows you to apply rules to incoming mail messages, and one of these allows you to run some code in a VBA module (the run a script option).

So put it all together and we have:

  1. A script on the customer’s server will monitor another script’s progress. If it detects a particular condition it will generate an email sent to my work email account.
  2. Outlook has a rule to look for specific text in the email subject (for example “ERROR”).  If it detects a suitable email, it will run a piece of VBA.
  3. The VBA will call skype and send the SMS message

Installation of outlook VBA code

  1. Add the code below to an outlook module
  2. Add a reference to the Skype4COM object in the module.
  3. Create a button in outlook that is linked to the macro SendTestSMS
  4. Create a rule in outlook that searches your incoming mail and will ‘run a script’ if it finds something. the script to run is the SendSMSRule VBA macro.

Running the solution

  1. Have outlook running and make sure that macros are enabled.
  2. Click the button you created in step 4 above and enter your phone number. The VBA app will remember your phone number, but you will want to send a test SMS, because you will probably have to ‘allow’ outlook to access Skype the first time after starting outlook.  Skype will ask you for confirmation.
  3. If Skype is not running, it will be started for you by the VBA code.
  4. Have some credit in Skype for sending sms!
  5. Wait for email’s to arrive.

The VBA Code

Public Sub SendTestSMS()
    Dim strMsg As String
    Dim strContact As String
    Dim strPhoneNumber As String

    strPhoneNumber = GetSetting("SendSkypeSMS", "PhoneNumber", "Data", "")

    strContact = InputBox("Make sure you allow Outlook to use Skype when prompted in Skype." & vbCrLf & _
                            "You will probably have to do this for every session" & vbCrLf & _
                            "Enter your mobile number (+44123456789)", "Enter Phone Number", strPhoneNumber)

    SaveSetting "SendSkypeSMS", "PhoneNumber", "Data", strContact

    If Len(strContact) = 0 Then
        Exit Sub
    End If

    strMsg = "A test message from Outlook"
    subSendSMS strContact, strMsg

    strPhoneNumber = GetSetting("SendSkypeSMS", "PhoneNumber", "Data", "")
    MsgBox "Sent a text to: " & strPhoneNumber
    SaveSetting "SendSkypeSMS", "PhoneNumber", "Data", strPhoneNumber

End Sub

Public Sub SendSMSRule(Item As Outlook.MailItem) 'Outlook will give us the mail item that matched the rule
    Dim strPhoneNumber As String

    strPhoneNumber = GetSetting("SendSkypeSMS", "PhoneNumber", "Data")

    If strPhoneNumber = "" Then
        MsgBox "You have to send a test SMS message so that I know what your phone number is!", vbCritical
        Exit Sub
    End If

    subSendSMS strPhoneNumber, Item.Subject

End Sub

Private Sub subSendSMS(strRecipients As String, strMessage As String)
    Dim objSkype        As SKYPE4COMLib.Skype
    Dim objSMS          As SKYPE4COMLib.SmsMessage

    Set objSkype = New SKYPE4COMLib.Skype

    If Not objSkype.Client.IsRunning Then
        objSkype.Client.Start
    End If

    objSkype.Attach , True

    Set objSMS = objSkype.CreateSms(smsMessageTypeOutgoing, strRecipients)

    With objSMS
        .Body = strMessage
        .Send
    End With

    objSkype.Convert.SmsMessageStatusToText (objaStatus)

KillObjects:
    Set objSMS = Nothing
    Set objSkype = Nothing
End Sub

Stop motion animation

Saturday, January 30th, 2010

This animation is a test using a DV camera and a little script I wrote to control it.

Basically I wanted to be able to use my DV camera to take single frames, which could then be rolled into a finished video.

A little shell script follows, which does just what I need, using dvgrab and ffplay.

#!/bin/bash
# script to take a shot with DV camera

count=1
calldir=`pwd`
wrapdir='wraps'

function help_me
{
echo -e "HELP!"
echo -e "h - shows this help!"
echo -e "s - takes a shot"
echo -e "p - shows a preview of all the shots so far"
echo -e "w - writes the shots to a wrap file in ./$wrapdir"
echo -e "q - quits\n"
}

help_me

if [ ! -d $calldir/$wrapdir ] ; then
mkdir $calldir/$wrapdir || exit
fi

while [ "$ans" != "q" ]
do

echo -e "I'm waiting for instructions:(h|s|p|w|q)"
read -sn1 ans

if [ "$ans" = "h" ] ; then

help_me

elif [ "$ans" = "s" ] ; then

echo -e "grabbing a frame"
dvgrab --every 25 --duration 1 2>/dev/null
echo -e "grabbed $count\n\a"

count=$(($count+1))

elif [ "$ans" = "p" ] ; then

echo -e "Preview"
cat $calldir/*.dv | ffplay -
echo -e "Preview ended"

elif [ "$ans" = "w" ] ; then

echo -e "Wrapping up"
echo -e "Creating in in $calldir/$wrapdir"
echo -e "Enter filename for wrap:"

read filename

cd $calldir/$wrapdir || exit

cat $calldir/*.dv | dvgrab -stdin --format dv2 $filename 2>/dev/null

clear

# reset count after wrapping file
count=1

echo -e "Tidying up last wrap: deleting $calldir/*.dv"
rm $calldir/*.dv

echo -e "Preview wrap"
ffplay $calldir/$wrapdir/$filename*
echo -e "Preview wrap ended"

cd $calldir || exit

elif [ "$ans" = "q" ] ; then

echo -e "Quitting...\n"
exit

fi

done

Playing with Audio

Wednesday, November 18th, 2009

I have spent quite some time recently playing with audio on my ubuntu desktop.

Last time I tried Audio on linux I found it to be a sorely disappointing affair. That was some 6 to 12 months ago.

On my old Windows box I had an E-mu 1820, but when I bought it I didn’t know that Creative didn’t like to help out by open sourcing their drivers. (How many people have bought M-Audio cards now, knowing that they can get Open Source drivers for it!) On my old Windows box I thought that card was going to stay, until week before last…

I had had some recent successes with getting jack and pulseaudio playing nicely. I had had a play with Ardour and loved it. So I bit the bullet and gave it a go.

I now have glorious multi channel playback and recording via my E-mu audiodock, so I have taken the opportunity to throw together a few recordings of my poetry. The first couple were straight recordings with a bit of reverberation added for ambience.

Virility

The Tree I Wish I’d Been

The most recent is a full on four and a half minutes of sequenced sound and samples :)

A Rude Awakening

If you are viewing this on the site you’ll see the above links as little embedded mp3 players, courtesy of the very smart wpaudio plugin.