# -*- coding: utf-8 -*- GlobalPVersion="0.97" from win32com.client import Dispatch import sys,time,os,_winreg try: px=Dispatch('ponx.Mci') pxd=Dispatch('ponxd.Mci') except: px=pxd=None import pxie try: name, ponxdir, typ = _winreg.EnumValue(_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Classes\CLSID\{EC501258-201C-449C-BE20-837A316EA382}\PythonCOMPath'), 0) print "ponxdir",ponxdir if not sys.path.__contains__(ponxdir): sys.path.append(ponxdir) except: ponxdir=os.getcwd() """ try: repertoirePonx=pxd.ponxdir() except: repertoirePonx="C:/ponx" """ repertoirePonx=ponxdir.replace("\\","/") print repertoirePonx,ponxdir class console(object): global BUFFER_out def __init__(self): self.navig=pxie.IEpilot(r'file:///'+repertoirePonx+'/consol.htm') self.navig.waitBusy() #self.navig.top(20) #self.navig.left(300) #self.navig.width(860) #self.navig.height(540) self.navig.title("PeJBshell") self.navig.toolsbar(False) self.navig.addressbar(False) self.navig.menubar(False) self.navig.statusbar(False) self.navig.loadLists() self.e0=self.navig.connectid('E0') self.prompt=self.navig.connectid('PROMPT') self.saisie=self.navig.connectfield('FORMBIDON.SAISIE') self.actionid=self.navig.connectid('ACTIONID') self.actioncible=self.navig.connectid('ACTIONCIBLE') self.actionvaleur=self.navig.connectid('ACTIONVALEUR') self.actionkbuffer=self.navig.connectid('ACTIONKBUFFER') self.actionkbskey=self.navig.connectid('ACTIONKBSKEY') self.consoleprompt='' self.BUFFER_out=sys.stdout sys.stdout=self def preparch(self, chaine): ch=chaine.replace('>','>') ch=ch.replace('<','<') ch=ch.replace('\r\n','
') ch=ch.replace('\n','
') ch=ch.replace('\r','
') ch=ch.replace(' ',' ') return ch """ def c255(c): if ord(c)>255: return '&#'+str(ord(c))+';' else: return c c=''.join([c255(i) for i in ch]) return c """ def attendkb(self): while 1: kbdata=self.actionkbuffer.innerText if kbdata!='': kbskey=self.actionkbskey.innerText self.actionkbuffer.innerText='' self.actionkbskey.innerText='' return (kbdata,kbskey) time.sleep(0.05) def echoline(self,chaine): ch=self.preparch(chaine) #self.navig.calljscript("addligne('"+ch+"')") self.e0.insertAdjacentHTML('BeforeEnd','
'+ch) #self.navig.FieldSetFocus('FORMBIDON.SAISIE') self.saisie.focus() def echonoline(self,chaine): ch=self.preparch(chaine) #self.navig.calljscript("addnoligne('"+ch+"')") self.e0.insertAdjacentHTML('BeforeEnd',ch) #self.navig.FieldSetFocus('FORMBIDON.SAISIE') self.saisie.focus() def cprompt(self,chaine): ch=self.preparch(chaine) i=ch.find('>') ch1=''+ch[:i+4]+''+ch[i+4:] self.prompt.innerHTML=ch1 self.saisie.focus() def writebrut(self,chaine): ch=chaine.replace(' ',' ') self.e0.insertAdjacentHTML('BeforeEnd',ch) self.saisie.focus() def open(self): sys.stdout=self def write(self, data): a="" for c in data: a+=str(ord(c))+" " if data.endswith('\r\n'): data=data[:-2] if data.startswith('\r\n'): data=data[2:] self.echonoline(data) def s_input(self,chaine): vret='' while vret=='': vret=getField('SAISIE') sleep(3) return vret def close(self): sys.stdout=self.BUFFER_out self.navig.close() del self.navig