home *** CD-ROM | disk | FTP | other *** search
- AddExtender ("wwwsk32i.dll")
- IntControl (35, 500, 0, 0, 0)
- bOK = @TRUE
- sDial = "<dialupname>"
- nMaxRedial = <numredials>
- nRedialDelay = 10
- sPgmPath = "<pgmpath>"
- sPgmDir = "<pgmdir>"
- bAllSvcs = <allservices>
- sServices = "<services>"
- sErrDesc = ""
- sWinTitle = "~ - Microsoft Exchange"
- nTimeout = 30 ; How many secs of inactivity to wait
-
-
- ;**********************************************************************
- ;Dial our host (unless user is on a direct connect)...
- ;**********************************************************************
- hConn = 0
- nNumRedials = 0
- if (sDial <> "")
- :DialIt
- hConn = DUNConnect (sDial)
- nErr = SGetLastErr ()
- sErr = wxGetErrDesc (nErr)
- if (nErr == 633 && WinVersion(@MAJOR)==4 && WinVersion(@MINOR)==0)
- ; Error 633 under NT 4.0 >really< just means we're already connected...
- nErr = @SAlready
- hConn = 0
- else
- if (nErr!=@SAlready && !hConn)
- switch nErr
- case @SErrBusy
- case @SErrNoAnswer
- case 680 ; no dialtone
- if (nNumRedials <= nMaxRedial)
- nNumRedials = nNumRedials + 1
- Delay (nRedialDelay)
- goto DialIt
- endif
- break
-
- case @SErrNotFound
- case @SErrVoice
- case nErr ; <--default
- sErrDesc = "Couldn't connect to %sDial%: %sErr%"
- bOK = @FALSE
- goto LogIt
- endswitch
- else
- if (nErr == @SAlready)
- ; We're already connected. Don't hang up when this event is thru...
- hConn = 0
- endif
- endif
- endif
- endif
-
-
- ; Run Exchange & make it do things...
- if (!WinExist(sWinTitle))
- DirChange (sPgmDir)
- Run (sPgmPath, "")
- while (!WinExist(sWinTitle))
- Delay (1)
- endwhile
- Delay (6)
- endif
-
- WinActivate (sWinTitle)
- sWinTitle = WinGetActive () ; Get actual window name
-
- ; Main processing...
- if (bAllSvcs)
- SendKeysTo (sWinTitle, "!td~")
- Delay (10)
- else
- SendkeysTo (sWinTitle, "!td") ; Force 3rd level menu to be created...
- Delay (1)
- SendkeysTo (sWinTitle, "{esc 3}") ; Back out of menu selection
- Delay (1)
-
- for nSvc = 1 to ItemCount(sServices,@TAB)
- sService = ItemExtract (nSvc, sServices, @TAB)
- gosub WinSelectMenuItem
- Delay (10)
-
- ; Wait for timeout on modem...
- nBytesMoved = wxGetInfo(3,hConn) + wxGetInfo(4,hConn)
- if (nBytesMoved != -1)
- nTimer = 0
- while (nTimer < nTimeout && WinExist(sTitle))
- Delay (1)
- nBytesPrev = nBytesMoved
- nBytesMoved = wxGetInfo(3,hConn) + wxGetInfo(4,hConn)
- if (nBytesMoved != nBytesPrev)
- ; Still data being moved in this period. Reset timer...
- nTimer = 0
- endif
- nTimer = nTimer + 1
- endwhile
- endif
- next nSvc
- endif
-
-
- ; If user hit Ctrl+Break, WIL will bring us here...
- :Cancel
-
- ; Hang up if we're on a dial-up connection...
- :HangUp
- if (hConn)
- nRet = DUNDisconnect (hConn)
- endif
-
-
- ; Log what we did...
- :LogIt
- if bOK == @TRUE
- sLog = "Ran Exchange"
- else
- sLog = strcat ("Error attempting to automate Exchange:", @CRLF, sErrDesc)
- endif
-
- CMLogMessage (sLog)
- Display (8, "ClockMan95", sLog)
- exit
-
-
- ; Select the menu item corresponding to service "sService"...
- :WinSelectMenuItem
- WSMsSysDir = DirWindows (1)
- WSMhUser32 = DllLoad ("%WSMsSysDir%user32.dll")
- ;Debug(@ON)
- WSMhwnd = IntControl(21, sWinTitle, 0, 0, 0)
- WSMhMenu = DllCall(WSMhUser32, long:"GetMenu", long:WSMhwnd)
- WSMhMenu = DllCall(WSMhUser32, long:"GetSubMenu", long:WSMhMenu, long:3)
- WSMhMenu = DllCall(WSMhUser32, long:"GetSubMenu", long:WSMhMenu, long:0)
- if (!WSMhMenu)
- CMLogMessage ("No Services menu found!")
- else
- WSMhItem = BinaryAlloc(80)
- BinaryEODSet(WSMhItem, 80)
- WSMnSvcs = DllCall(WSMhUser32, long:"GetMenuItemCount", long:WSMhMenu)
- for WSMn = 2 to WSMnSvcs-1 ; skipping over "All services" & horiz separator
- DllCall(WSMhUser32, long:"GetMenuStringA", long:WSMhMenu, long:WSMn, lpbinary:WSMhItem, long:80, long:1024)
- WSMsItem = BinaryPeekStr(WSMhItem, 0, 80)
- if strindex (WSMsItem, sService, 0, @FWDSCAN) == 1
- ; We found the menu item we're looking for...
- WSMnItem = WSMn - 1
- SendKeysTo (sWinTitle, "^%WSMnItem%") ; Ctrl+1, etc.
- endif
- next WSMn
- BinaryFree (WSMhItem)
- endif
- DllFree (WSMhUser32)
-
- return
- ~
-