Hi:<br><br>My problem is:<br><br>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<br><br>import xmlrpclib<br>import math <br>
import time<br>import pythoncom<br>import win32api<br>import win32com.client<br>import sys<br><br>from threading import Thread<br>#from mechanize import Browser<br>from win32com.client import DispatchEx<br><br><br>class TestCarle(Thread):<br>
def __init__ (self, site, num):<br> Thread.__init__(self)<br> #<a href="http://self.br">self.br</a> = Browser()<br> self.site = site<br> self.tiempoFiesta = 0<br> self.nombre = ""<br>
self.i = 0<br> self.num = num<br><br> def run(self):<br> server = xmlrpclib.Server('<a href="http://localhost:9001">http://localhost:9001</a>')<br><br> self.nombre = server.get_name()<br>
self.tiempoFiesta = server.get_time()<br><br> tiempo = self.tiempoFiesta - time.time()<br> #print tiempo<br> tiempo = tiempo / 1000<br><br> #print tiempo<br> print self.nombre <br>
<br> time.sleep(tiempo)<br><br> sys.coinit_flags = 0<br> #pythoncom.CoInitialize()<br> #pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)<br> pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)<br>
<br> #ie = pythoncom.CoCreateInstance("InternetExplorer.Application", None,\<br> # pythoncom.CLSCTX_SERVER, <br> # pythoncom.IID_IDispatch)<br> #<a href="http://self.ie">self.ie</a> = Dispatch(ie)<br>
<br> #a = win32api.ShellExecute(0,None,"iexplore.exe",self.site,None,1)<br> #internetExplorerClassIdentity='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'<br> #hwnds = Dispatch(internetExplorerClassIdentity)<br>
#<a href="http://self.ie">self.ie</a> = self.hwnds[self.num]<br> #self.ie.Navigate("<a href="http://www.google.com/search?hl=en&lr=&q=python">http://www.google.com/search?hl=en&lr=&q=python</a>";)<br>
<br><br> #<a href="http://self.ie">self.ie</a> = Dispatch("InternetExplorer.Application")<br> <a href="http://self.ie">self.ie</a> = DispatchEx("InternetExplorer.Application")<br> self.ie.Visible = 1<br>
self.ie.Navigate(self.site)<br> <br> while self.ie.Busy:<br> time.sleep(6)<br><br> #self.ie.document.getElementById("login").value = "37324"<br> self.ie.Document.getElementById("login").value = self.nombre<br>
self.ie.Document.getElementById("B1").click()<br><br> while self.ie.Busy:<br> time.sleep(4)<br><br> #print self.ie.document.frames.length<br> #print dir(self.ie.Document.frames)<br>
self.ie.Document.frames[0].Document.getElementById("Submit").click() <br><br> letras = ['A','B','C','D']<br><br> for self.i in range(50):<br> print "%s, %s" % (self.nombre, self.i)<br>
while self.ie.Busy:<br> print "Esperando"<br> time.sleep(4)<br><br> self.ie.Document.frames[0].Document.getElementById("radiobutton").value=letras[self.i%4]<br>
self.ie.Document.frames[0].Document.getElementById("radiobutton").Checked = True<br> self.ie.Document.frames[0].Document.getElementById("Submit").click()<br> <br> pythoncom.CoUninitialize() <br>
<br clear="all"><br>Greats in advance<br>-- <br>Eric Galicia Rosas<br>CETEE<br>ITAM<br><br>msn: <a href="mailto:eric_galicia@hotmail.com">eric_galicia@hotmail.com</a><br>tel: 56284000 ext 6612<br>cel: 0445532228865