ページの先頭行へ戻る
Interstage Interaction Manager V9.1.1 Interstage Portalworksシナリオ作成支援ガイド

4.6.6 スクリプト(two.js)

スクリプトファイルには、以下を記述します。

// WSH Shellオブジェクトの作成
WshShell = new ActiveXObject("WScript.Shell");

// 起動済の場合はウィンドウをアクティブ化
if(WshShell.AppActivate("メール") == true){
         PwShell.Quit(0);
}

// レジストリからインストールディレクトリを検索
path = WshShell.RegRead("HKLM\\Software\\Fujitsu\\Install\\TeamWARE Office\\Directory");

// 起動パス
path = "\"" + path + "\\twmail32.exe" + "\"";

// TeamWAREメールを起動
try{
         WshShell.Run(path);
}catch(e){
         WshShell.Popup("起動エラー(" + e.number + ")");
         PwShell.Quit(e.number);
}

// 認証画面が表示されるのを待つ(20秒)
bActive = false;
for(i = 0; i < 20; i++){
         PwShell.Sleep(1000); // 1秒

        if(WshShell.AppActivate("メール") == true){
                  PwShell.Quit(0);
        }

         if(WshShell.AppActivate("TeamWARE Office") == true){
                  bActive = true;
                  break;
         }
}
if(!bActive){
         WshShell.Popup("起動に失敗しました");
         PwShell.Quit(1);
}

// ユーザIDの入力フィールドへカーソルを移動
WshShell.SendKeys("%L");
PwShell.Sleep(100);

// ユーザIDの入力
userid = PwShell.GetAppParam("TeamWARE", "userid");
WshShell.SendKeys(userid);
PwShell.Sleep(100);

// TABでパスワード入力フィールドへ移動
WshShell.SendKeys("{TAB}");
PwShell.Sleep(100);

// カーソルがパスワード入力フィールドにあるか確認
if(PwShell.IsPassword()){
         // パスワードの入力
         pw = PwShell.GetAppParam("TeamWARE", "pw");
         WshShell.SendKeys(pw);
}

// Enterキーを押す
WshShell.SendKeys("{ENTER}");

// TeamWAREメールが起動されるのを待つ(10秒)
bActive = false;
for(i = 0; i < 10; i++){
         PwShell.Sleep(1000); // 1秒

         if(WshShell.AppActivate("メール") == true){
                  bActive = true;
                  break;
         }
}
if(!bActive){
         WshShell.Popup("起動に失敗しました");
         PwShell.Quit(1);
}

// 正常
PwShell.Quit(0);