Skype4COM ファイル転送自動受信

Windows API の力を借りる
かなりベタな方法で、まだまだ実用段階ではありませんが、一応成功したので。

まず、既に存在するファイルを上書き保存するキー操作を想定しています。
スカイプのログインは済んでいるという前提で、スクリプトは cscript.exe で実行し、
実行後メッセージボックスが表示されたら、スカイプに手動でフォーカスを移しておきます
ここで、API_CALLBACK.exe は、以下の VB.NET で作成したものです。
フォームは使わずに、目的の処理が済むと即終了します

要するに、ApplicationEvents.vb を使っています。
実装方法は こちらを参照して下さい
001.Imports System.Runtime.InteropServices
002.Imports System.Text
003. 
004.Namespace My
005. 
006.    Partial Friend Class MyApplication
007. 
008.        ' ******************************************************
009.        ' Callback 関数の定義( 通常 )
010.        ' ******************************************************
011.        Public Delegate Function EnumWindowsCallbackNormal( _
012.        ByVal hWnd As Integer, _
013.        ByVal lParam As Integer) As Boolean
014.        ' ******************************************************
015.        ' Callback 呼び出し 関数の定義
016.        ' ******************************************************
017.        <dllimport("user32.dll", charset:="CharSet.Auto)"> _
018.         Public Shared Function EnumWindows( _
019.         ByVal callback As EnumWindowsCallbackNormal, _
020.         ByVal lParam As Integer) As Integer
021.        End Function
022. 
023.        ' ******************************************************
024.        ' 情報取得用 API
025.        ' ******************************************************
026.        <dllimport("user32.dll", charset:="CharSet.Auto)"> _
027.        Public Shared Function ShowWindow(ByVal hWnd As Integer, _
028.         ByVal nCmdShow As Integer _
029.         ) As Integer
030.        End Function
031. 
032.        <dllimport("user32.dll", charset:="CharSet.Auto)"> _
033.        Public Shared Function GetWindowText(ByVal hWnd As Integer, _
034.         ByVal lpString As StringBuilder, _
035.         ByVal nMaxCount As Integer) As Integer
036.        End Function
037. 
038.        <dllimport("user32.dll", charset:="CharSet.Auto)"> _
039.        Public Shared Function GetClassName(ByVal hwnd As Integer, _
040.         ByVal lpClassName As StringBuilder, _
041.         ByVal cch As Integer) As Integer
042.        End Function
043. 
044.        Const STRING_BUFFER_LENGTH As Integer = 255
045. 
046.        ' ******************************************************
047.        ' 開始( 処理後終了 )
048.        ' ******************************************************
049.        Private Sub MyApplication_Startup(ByVal sender As Object, _
050.         ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
051. 
052.            ' Callback 関数のアドレスの渡し方
053.            Dim func As EnumWindowsCallbackNormal = _
054.             AddressOf ActiveProcessListNormal
055. 
056.            EnumWindows( _
057.             CType( _
058.              AddressOf ActiveProcessListNormal, _
059.              EnumWindowsCallbackNormal _
060.              ), 0)
061. 
062.            e.Cancel = True
063. 
064.        End Sub
065. 
066.        ' ******************************************************
067.        ' Callback 関数( 通常 )
068.        ' ******************************************************
069.        Private Function ActiveProcessListNormal(ByVal hWnd As Integer, _
070.          ByVal lParam As Integer) As Boolean
071. 
072.            Dim windowText As New StringBuilder(STRING_BUFFER_LENGTH)
073.            Dim className As New StringBuilder(STRING_BUFFER_LENGTH)
074. 
075.            GetWindowText(hWnd, windowText, STRING_BUFFER_LENGTH)
076.            GetClassName(hWnd, className, STRING_BUFFER_LENGTH)
077. 
078.            Dim target As String = windowText.ToString() + ""
079. 
080.            If target.Length >= 5 Then
081.                If target.Substring(0, 5) = "Skype" Then
082. 
083.                    If target.IndexOf("ファイルを受信しています") >= 0 Then
084. 
085.                        Console.WriteLine( _
086.                          String.Format("{0}|{1}|{2}", _
087.                           windowText.ToString(), _
088.                           className.ToString(), _
089.                           hWnd.ToString()) _
090.                          )
091. 
092.                        ShowWindow(hWnd, 9)
093. 
094.                    End If
095.                End If
096.            End If
097. 
098.            Return True
099. 
100.        End Function
101. 
102.    End Class
103. 
104.End Namespace
105.</dllimport("user32.dll",></dllimport("user32.dll",></dllimport("user32.dll",></dllimport("user32.dll",>