Metropoli BBS
VIEWER: wileudora MODE: TEXT (ASCII)
AddExtender ("wwwsk32i.dll")
IntControl (35, 500, 0, 0, 0)
bOK = @TRUE
sDial     = "<dialupname>"
nMaxRedial = <numredials>
nRedialDelay = 10
sPgmPath  = "<pgmpath>"
sPgmDir   = "<pgmdir>"
bGetMail   = <getmail>
bSendMail  = <sendmail>
bEmpty     = <empty>
bCompact   = <compact>
sErrDesc  = ""


;Dial our host (unless user is on a direct connect)...
hConn = 0
nNumRedials = 0
if ((bGetMail || bSendMail) && sDial <> "")
	:DialIt
	hConn = DUNConnect (sDial)
	nErr = SGetLastErr ()
	if (!hConn)
		switch nErr
		case @SErrNotFound
			sErrDesc = "Couldn't connect to %sDial%: no such dial-up"
			break
		case @SErrBusy
			if (nNumRedials <= nMaxRedial)
				nNumRedials = nNumRedials + 1
				Delay (nRedialDelay)
				goto DialIt
			else
				sErrDesc = "Couldn't connect to %sDial%: Line busy"
			endif
			break
		case @SErrNoAnswer
			if (nNumRedials <= nMaxRedial)
				nNumRedials = nNumRedials + 1
				Delay (nRedialDelay)
				goto DialIt
			else
				sErrDesc = "Couldn't connect to %sDial%: No answer"
			endif
			break
		case @SErrVoice
			sErrDesc = "Couldn't connect to %sDial%: A human answered"
			break
		case nErr ; <--default
			sErrDesc = "Couldn't connect to %sDial% - error %nErr%"
		endswitch
		bOK = @FALSE
		goto LogIt
	else
		if (nErr == @SAlready)
			; We're already connected. Don't hang up when this event is thru...
			hConn = 0 
		endif
	endif
endif


;Activate or Run Eudora...
If WinExist("Eudora")
	WinActivate("Eudora")
else
	DirChange (sPgmDir)
	Run(sPgmPath, "")
endif


; Do stuff online...
:GetMail
if bGetMail
	SendKeysTo("Eudora", "!FM")
	while !WinExist("No New Mail") && !WinExist("New Mail!")
		Delay(5)
		MouseMove (100+random(10), 100, "", "")
	endwhile
	Delay(1)
	SendKeysTo("Eudora", "~")
endif


:SendMail
if bSendMail
	SendKeysTo("Eudora", "!FQ")
	while WinExist("Progress")
		Delay(5)
		MouseMove (100+random(10), 100, "", "")
	endwhile
	Delay(1)
endif


; Do stuff offline...
:Compact
if bCompact
	SendKeysTo("Eudora", "!ST")
	while WinExist("Progress")
		Delay(5)
		MouseMove (100+random(10), 100, "", "")
	endwhile
	Delay(1)
endif


:Empty
if bEmpty
	SendKeysTo("Eudora", "!SE")
	while WinExist("Progress")
		Delay(5)
		MouseMove (100+random(10), 100, "", "")
	endwhile
	Delay(1)
endif


; If user hit Ctrl+Break, WIL will bring us here...
:Cancel

; Hang up...
:HangUp
if (hConn)
	nRet = DUNDisconnect (hConn)
endif


; Log what we did...
:LogIt
if bOK == @TRUE
	sLog = "Ran Eudora"
else
	sLog = strcat ("Error automating Eudora:", @CRLF, sErrDesc)
endif

CMLogMessage (sLog)
Display (8, "ClockMan95", sLog)
exit

~
[ RETURN TO DIRECTORY ]