#version Smart_Script 1.20
#timeout 1200
#linewait 0
#error_continue

// Netscape Communicator 4.7 Mail Downloading.ssc (MCHK Version) for Smart Script
// Copyright 2000 Sony Corp.
// VASVersion=1.1.01.03280
function  main( $argc , @argv )
{
    $check = 0;
    if ( $argc == 1 ) {
        if ( @argv[ 0 ] eq "c" ) {
            exit 4;
        }
    }
    if ( $argc > 0 ) {
        $check = @argv[ 0 ];
    }
    if ( $argc == 2 ) {
        :$limit = @argv[ 1 ];
    } else {
        :$limit = 15;
    }
    Initialize(  );
    $_result = IsWindowExisting( :$WndNameMain , :$ClassNameMain );
    if ( ! $_result ) {
        $_result = IsFileExisting( :$path );
        if ( $_result ) {
            $_result = ExecuteFile( :$CommandLine );
        } else {
            $_result = TimerMessage( :$errmsgFileNotFound , 3 );
            exit 1;
        }
    }
    %netscape = WaitWindowOpen( :$WndNameMain , :$ClassNameMain , 60 );
    $_result = IsWindowValid( %netscape );
    if ( $_result ) {
        $_result = RestoreWindow( %netscape );
        $_result = SelectMenu( %netscape , :$IDReceive , "i" );
        %state = WaitWindowOpen( :$WndNameState , "" , 10 );
        $_result = IsWindowValid( %state );
        if ( ! $_result ) {
            %msg = GetWindowHandle( :$WndNameReceive , :$ClassNameDlg );
            $_result = IsWindowValid( %msg );
            if ( $_result ) {
                $_result = DialogPushButton( %msg , :$BtnNameYes , "s" );
            }
            %state = WaitWindowOpen( :$WndNameState , "" , 10 );
        }
        $_result = IsWindowValid( %state );
        if ( $_result ) {
            $_result = WaitWindowClose( %state , :$limit * 60 );
            if ( $_result ) {
                exit 0;
            } else {
                $_result = IsWindowValid( %state );
                if ( $_result ) {
                    $_result = PressKey( %netscape , "ESCAPE" , "" );
                }
                $_result = TimerMessage( :$errmsgEnd , 3 );
                exit 1;
            }
        } else {
            $_result = TimerMessage( :$errmsgStatusDlgNotFound , 3 );
            exit 1;
        }
    } else {
        $_result = TimerMessage( :$errmsgCantOpen , 3 );
        exit 1;
    }
}
//
function  Initialize(  )
{
    :$path = LoadRegistry( "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscape.exe" , "" );
    :$CommandLine = "\"" & :$path & "\" -mail";
    //:$StartMenu = LoadRegistry( "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" , "Programs" );
    //:$StartMenu &= "\\Netscape Communicator\\Netscape Messenger.lnk";
    //Window 
    :$WndNameMain = "* - Netscape Folder";
    :$ClassNameMain = "Afx:400000:b:*";
    :$WndNameState = "Getting New Messages";
    :$WndNameReceive = "Get Messages";
    :$ClassNameDlg = "#32770";
    :$BtnNameYes = "Yes";
    //Menu ID
    :$IDReceive = 34006;
    //Error Messages
    :$errmsgFileNotFound = "netscape.exe not found.";
    :$errmsgEnd = "Terminated by timeout or by pressing cancel button.";
    :$errmsgStatusDlgNotFound = "Cannot find the Download dialog.";
    :$errmsgCantOpen = "Cannot find Netscape Messenger.";
}
