home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 November / PCO1197.ISO / FilesBBS / WIN95 / CM95-10.EXE / INTERNET.DLL / TEXT / WILEXCHANGE < prev    next >
Encoding:
Text File  |  1997-07-24  |  4.1 KB  |  160 lines

  1. AddExtender ("wwwsk32i.dll")
  2. IntControl (35, 500, 0, 0, 0)
  3. bOK = @TRUE
  4. sDial      = "<dialupname>"
  5. nMaxRedial = <numredials>
  6. nRedialDelay = 10
  7. sPgmPath   = "<pgmpath>"
  8. sPgmDir    = "<pgmdir>"
  9. bAllSvcs   = <allservices>
  10. sServices  = "<services>"
  11. sErrDesc   = ""
  12. sWinTitle  = "~ - Microsoft Exchange"
  13. nTimeout   = 30 ; How many secs of inactivity to wait
  14.  
  15.  
  16. ;**********************************************************************
  17. ;Dial our host (unless user is on a direct connect)...
  18. ;**********************************************************************
  19. hConn = 0
  20. nNumRedials = 0
  21. if (sDial <> "")
  22.     :DialIt
  23.     hConn = DUNConnect (sDial)
  24.     nErr = SGetLastErr ()
  25.     sErr = wxGetErrDesc (nErr)
  26.     if (nErr == 633 && WinVersion(@MAJOR)==4 && WinVersion(@MINOR)==0)
  27.         ; Error 633 under NT 4.0 >really< just means we're already connected...
  28.         nErr = @SAlready
  29.         hConn = 0
  30.     else
  31.         if (nErr!=@SAlready && !hConn)
  32.             switch nErr
  33.                 case @SErrBusy
  34.                 case @SErrNoAnswer
  35.                 case 680 ; no dialtone
  36.                     if (nNumRedials <= nMaxRedial)
  37.                         nNumRedials = nNumRedials + 1
  38.                         Delay (nRedialDelay)
  39.                         goto DialIt
  40.                     endif
  41.                     break
  42.     
  43.                 case @SErrNotFound
  44.                 case @SErrVoice
  45.                 case nErr ; <--default
  46.                     sErrDesc = "Couldn't connect to %sDial%: %sErr%"
  47.                     bOK = @FALSE
  48.                     goto LogIt
  49.             endswitch
  50.         else
  51.             if (nErr == @SAlready)
  52.                 ; We're already connected. Don't hang up when this event is thru...
  53.                 hConn = 0 
  54.             endif
  55.         endif
  56.     endif
  57. endif
  58.  
  59.  
  60. ; Run Exchange & make it do things...
  61. if (!WinExist(sWinTitle))
  62.     DirChange (sPgmDir)
  63.     Run (sPgmPath, "")
  64.     while (!WinExist(sWinTitle))
  65.         Delay (1)
  66.     endwhile
  67.     Delay (6)
  68. endif
  69.  
  70. WinActivate (sWinTitle)
  71. sWinTitle = WinGetActive () ; Get actual window name
  72.  
  73. ; Main processing...
  74. if (bAllSvcs)
  75.     SendKeysTo (sWinTitle, "!td~")
  76.     Delay (10)
  77. else
  78.     SendkeysTo (sWinTitle, "!td") ; Force 3rd level menu to be created...
  79.     Delay (1)
  80.     SendkeysTo (sWinTitle, "{esc 3}") ; Back out of menu selection
  81.     Delay (1)
  82.  
  83.     for nSvc = 1 to ItemCount(sServices,@TAB)
  84.         sService = ItemExtract (nSvc, sServices, @TAB)
  85.         gosub WinSelectMenuItem
  86.         Delay (10)
  87.  
  88.         ; Wait for timeout on modem...
  89.         nBytesMoved = wxGetInfo(3,hConn) + wxGetInfo(4,hConn)
  90.         if (nBytesMoved != -1)
  91.             nTimer = 0
  92.             while (nTimer < nTimeout && WinExist(sTitle))
  93.                 Delay (1)
  94.                 nBytesPrev = nBytesMoved
  95.                 nBytesMoved = wxGetInfo(3,hConn) + wxGetInfo(4,hConn)
  96.                 if (nBytesMoved != nBytesPrev)
  97.                     ; Still data being moved in this period. Reset timer...
  98.                     nTimer = 0
  99.                 endif
  100.                 nTimer = nTimer + 1
  101.             endwhile
  102.         endif
  103.     next nSvc
  104. endif
  105.  
  106.  
  107. ; If user hit Ctrl+Break, WIL will bring us here...
  108. :Cancel
  109.  
  110. ; Hang up if we're on a dial-up connection...
  111. :HangUp
  112. if (hConn)
  113.     nRet = DUNDisconnect (hConn)
  114. endif
  115.  
  116.  
  117. ; Log what we did...
  118. :LogIt
  119. if bOK == @TRUE
  120.     sLog = "Ran Exchange"
  121. else
  122.     sLog = strcat ("Error attempting to automate Exchange:", @CRLF, sErrDesc)
  123. endif
  124.  
  125. CMLogMessage (sLog)
  126. Display (8, "ClockMan95", sLog)
  127. exit
  128.  
  129.  
  130. ; Select the menu item corresponding to service "sService"...
  131. :WinSelectMenuItem
  132. WSMsSysDir = DirWindows (1)
  133. WSMhUser32 = DllLoad ("%WSMsSysDir%user32.dll")
  134. ;Debug(@ON)
  135. WSMhwnd = IntControl(21, sWinTitle, 0, 0, 0)
  136. WSMhMenu = DllCall(WSMhUser32, long:"GetMenu", long:WSMhwnd)
  137. WSMhMenu = DllCall(WSMhUser32, long:"GetSubMenu", long:WSMhMenu, long:3)
  138. WSMhMenu = DllCall(WSMhUser32, long:"GetSubMenu", long:WSMhMenu, long:0)
  139. if (!WSMhMenu)
  140.     CMLogMessage ("No Services menu found!")
  141. else
  142.     WSMhItem = BinaryAlloc(80)
  143.     BinaryEODSet(WSMhItem, 80)
  144.     WSMnSvcs = DllCall(WSMhUser32, long:"GetMenuItemCount", long:WSMhMenu)
  145.     for WSMn = 2 to WSMnSvcs-1 ; skipping over "All services" & horiz separator
  146.         DllCall(WSMhUser32, long:"GetMenuStringA", long:WSMhMenu, long:WSMn, lpbinary:WSMhItem, long:80, long:1024)
  147.         WSMsItem = BinaryPeekStr(WSMhItem, 0, 80)
  148.         if strindex (WSMsItem, sService, 0, @FWDSCAN) == 1
  149.             ; We found the menu item we're looking for...
  150.             WSMnItem = WSMn - 1
  151.             SendKeysTo (sWinTitle, "^%WSMnItem%") ; Ctrl+1, etc.
  152.         endif
  153.     next WSMn
  154.     BinaryFree (WSMhItem)
  155. endif
  156. DllFree (WSMhUser32)
  157.  
  158. return
  159. ~
  160.