[Python-au] win32com threading
Mark Hammond
mhammond at skippinet.com.au
Thu Apr 10 22:44:31 UTC 2008
Please try resending your email to the python-win32 at python.org mailing list
see mail.python.org for details. When you do resend, I suggest you try
and reduce your code to the smallest possible example that demonstrates your
problem, with all XMLRPC servers or commented-out old code removed, and
explain clearly what you do see, and what you expect to see.
Cheers,
Mark
---------------------------------------------------------------------
From: python-au-bounces at starship.python.net
[mailto:python-au-bounces at starship.python.net] On Behalf Of nigro
Sent: Friday, 11 April 2008 4:54 AM
To: python-au at starship.python.net
Subject: [Python-au] win32com threading
Hi:
My problem is:
Who I get many Internet Explorer instances in threading environment, this is
my code with all my trials, but in all cases I have many copies af same
instance
import xmlrpclib
import math
import time
import pythoncom
import win32api
import win32com.client
import sys
from threading import Thread
#from mechanize import Browser
from win32com.client import DispatchEx
class TestCarle(Thread):
def __init__ (self, site, num):
Thread.__init__(self)
#self.br = Browser()
self.site = site
self.tiempoFiesta = 0
self.nombre = ""
self.i = 0
self.num = num
def run(self):
server = xmlrpclib.Server('http://localhost:9001')
self.nombre = server.get_name()
self.tiempoFiesta = server.get_time()
tiempo = self.tiempoFiesta - time.time()
#print tiempo
tiempo = tiempo / 1000
#print tiempo
print self.nombre
time.sleep(tiempo)
sys.coinit_flags = 0
#pythoncom.CoInitialize()
#pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
#ie = pythoncom.CoCreateInstance("InternetExplorer.Application",
None,\
# pythoncom.CLSCTX_SERVER,
# pythoncom.IID_IDispatch)
#self.ie = Dispatch(ie)
#a = win32api.ShellExecute(0,None,"iexplore.exe",self.site,None,1)
#internetExplorerClassIdentity='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'
#hwnds = Dispatch(internetExplorerClassIdentity)
#self.ie = self.hwnds[self.num]
#self.ie.Navigate("http://www.google.com/search?hl=en&lr=&q=python";)
#self.ie = Dispatch("InternetExplorer.Application")
self.ie = DispatchEx("InternetExplorer.Application")
self.ie.Visible = 1
self.ie.Navigate(self.site)
while self.ie.Busy:
time.sleep(6)
#self.ie.document.getElementById("login").value = "37324"
self.ie.Document.getElementById("login").value = self.nombre
self.ie.Document.getElementById("B1").click()
while self.ie.Busy:
time.sleep(4)
#print self.ie.document.frames.length
#print dir(self.ie.Document.frames)
self.ie.Document.frames[0].Document.getElementById("Submit").click()
letras = ['A','B','C','D']
for self.i in range(50):
print "%s, %s" % (self.nombre, self.i)
while self.ie.Busy:
print "Esperando"
time.sleep(4)
self.ie.Document.frames[0].Document.getElementById("radiobutton").value=letr
as[self.i%4]
self.ie.Document.frames[0].Document.getElementById("radiobutton").Checked =
True
self.ie.Document.frames[0].Document.getElementById("Submit").click()
pythoncom.CoUninitialize()
Greats in advance
--
Eric Galicia Rosas
CETEE
ITAM
msn: eric_galicia at hotmail.com
tel: 56284000 ext 6612
cel: 0445532228865
More information about the python-au
mailing list