home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_2886 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  3.3 KB  |  103 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import string
  5. import sys
  6. import os
  7. import win32com.client.dynamic as win32com
  8. from win32com.client import Dispatch
  9. import win32api
  10. import win32gui
  11. import win32con
  12. import glob
  13. import pythoncom
  14. import time
  15. from util import CheckClean
  16. bVisibleEventFired = 0
  17.  
  18. class ExplorerEvents:
  19.     
  20.     def OnVisible(self, visible):
  21.         global bVisibleEventFired
  22.         bVisibleEventFired = 1
  23.  
  24.  
  25.  
  26. def TestExplorerEvents():
  27.     global bVisibleEventFired
  28.     iexplore = win32com.client.DispatchWithEvents('InternetExplorer.Application', ExplorerEvents)
  29.     iexplore.Visible = 1
  30.     if not bVisibleEventFired:
  31.         raise RuntimeError, 'The IE event did not appear to fire!'
  32.     bVisibleEventFired
  33.     iexplore.Quit()
  34.     iexplore = None
  35.     bVisibleEventFired = 0
  36.     ie = win32com.client.Dispatch('InternetExplorer.Application')
  37.     ie_events = win32com.client.DispatchWithEvents(ie, ExplorerEvents)
  38.     ie.Visible = 1
  39.     if not bVisibleEventFired:
  40.         raise RuntimeError, 'The IE event did not appear to fire!'
  41.     bVisibleEventFired
  42.     ie.Quit()
  43.     ie = None
  44.     print 'IE Event tests worked.'
  45.  
  46.  
  47. def TestObjectFromWindow():
  48.     hwnd = win32gui.FindWindow('IEFrame', None)
  49.     for child_class in [
  50.         'TabWindowClass',
  51.         'Shell DocObject View',
  52.         'Internet Explorer_Server']:
  53.         hwnd = win32gui.FindWindowEx(hwnd, 0, child_class, None)
  54.     
  55.     msg = win32gui.RegisterWindowMessage('WM_HTML_GETOBJECT')
  56.     (rc, result) = win32gui.SendMessageTimeout(hwnd, msg, 0, 0, win32con.SMTO_ABORTIFHUNG, 1000)
  57.     ob = pythoncom.ObjectFromLresult(result, pythoncom.IID_IDispatch, 0)
  58.     doc = Dispatch(ob)
  59.     for color in 'red green blue orange white'.split():
  60.         doc.bgColor = color
  61.         time.sleep(0.2)
  62.     
  63.  
  64.  
  65. def TestExplorer(iexplore):
  66.     if not iexplore.Visible:
  67.         iexplore.Visible = -1
  68.     
  69.     iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
  70.     win32api.Sleep(1000)
  71.     TestObjectFromWindow()
  72.     win32api.Sleep(3000)
  73.     
  74.     try:
  75.         iexplore.Quit()
  76.     except (AttributeError, pythoncom.com_error):
  77.         pass
  78.  
  79.  
  80.  
  81. def TestAll():
  82.     
  83.     try:
  84.         iexplore = win32com.client.dynamic.Dispatch('InternetExplorer.Application')
  85.         TestExplorer(iexplore)
  86.         win32api.Sleep(1000)
  87.         iexplore = None
  88.         TestExplorerEvents()
  89.         time.sleep(2)
  90.         gencache = gencache
  91.         import win32com.client
  92.         gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1)
  93.         iexplore = win32com.client.Dispatch('InternetExplorer.Application')
  94.         TestExplorer(iexplore)
  95.     finally:
  96.         iexplore = None
  97.  
  98.  
  99. if __name__ == '__main__':
  100.     TestAll()
  101.     CheckClean()
  102.  
  103.