Hello Karthik, I'm running Windows XP and Windows 2000. I installed "ctypes-0.6.2a.win32-py2.3.exe" but I guess there is a new version. See the following link. http://sourceforge.net/project/showfiles.php?group_id=71702&package_id=71318 &release_id=210134.
I found the instructions for this module at the following link. http://starship.python.net/crew/theller/ctypes/ And I went through the tutorial at the above link. I copied some code that I wrote based on the instructions so that I could access a DLL called "nidaq32.dll". If you have any questions you free to ask. Todd [Begin pydaq.py] from Numeric import * from ctypes import * from string import * from struct import * # Create instance of traditional nidaq dll ni=windll.nidaq32 class pydaq: def __init__(self): """variable declaration""" self.deviceNumber=c_int(1) self.chan=c_int(0) self.voltage=c_double(1.0) self.pvoltage=pointer(self.voltage) self.gain=c_int(-1) self.num=100 #Number of data points self.sampleRate=c_double(1000) self.max=10.0 self.min=-10.0 self.bits=12 def AI_Configure (self, deviceNumber=c_int(1), chan=c_int(0), inputMode=c_int(0), inputRange=c_int(10), polarity=c_int(0), driveAIS=c_int(0)): """configure analong input task""" self.AI_ConfigureStatus = ni.AI_Configure (deviceNumber, chan, inputMode, inputRange, polarity, driveAIS) #print "AI_Configure status =", self.AI_ConfigureStatus return self.AI_ConfigureStatus def AO_Configure (self, deviceNumber=c_int(1), chan=c_int(0), outputPolarity=c_int(0), intOrExtRef=c_int(0), refVoltage=c_double(10.0), updateMode=c_int(0)): """configure analog output task""" #print "Entering AO_Configure" self.AO_ConfigureStatus = ni.AO_Configure (deviceNumber, chan, outputPolarity, intOrExtRef, refVoltage, updateMode) #print "AO_Configure status =", AO_ConfigureStatus #print "Leaving AO_Configure" return self.AO_ConfigureStatus def AO_VWrite (self, deviceNumber=c_int(1), chan=c_int(0), voltage=c_double(1.0)): """analog write one point""" #print "Entering AO_VWrite" self.AO_VWriteStatus = ni.AO_VWrite (deviceNumber, chan, voltage) #print "AO_VWrite status =", AO_VWriteStatus #print "Leaving AO_VWrite" return self.AO_VWriteStatus def AI_VRead (self, deviceNumber=c_int(1), chan=c_int(0), gain=c_int(-1), pvoltage=pointer(c_double(1.0))): self.AO_VReadStatus = ni.AI_VRead (deviceNumber, chan, gain, pvoltage) #print "AI_VRead status =", self.AO_VWriteStatus, "voltage =", pvoltage.contents return self.AO_VReadStatus, pvoltage[0] def DAQ_VOp (self, deviceNumber=c_int(1), chan=c_int(0), gain=c_int(-1), num=2, sampleRate=c_double(1000)): """ acquire array of data """ #print "Entering DAQ_VOp" count=c_ulong(num) buffer=c_buffer(num * 2) self.DAQ_OpStatus = ni.DAQ_Op (deviceNumber, chan, gain, buffer, count, sampleRate) #print " buffer =", buffer #convert buffer to scaled array br = buffer.raw #print " buffer.raw =", br #rbr = repr(buffer.raw) #print " repr(buffer.raw)=", rbr fmt = 'h' * num #print " fmt =", fmt sizefmt = calcsize(fmt) unpacked = unpack(fmt, br) #print " unpacked =", unpacked unpackedarray = array(unpacked) #print "unpackedarray =", unpackedarray ScaledArray = unpackedarray * ((self.max - self.min)/(2 ** self.bits)) #print " DAQ_Op status =", self.DAQ_OpStatus #print " ScaledArray =", ScaledArray #print "Leaving DAQ_VOp" return self.DAQ_OpStatus, ScaledArray def DAQ_Clear (self, deviceNumber): self.DAQ_Clear_status = DAQ_Clear (self.deviceNumber) return self.DAQ_ClearStatus def AI_Clear (self, deviceNumber=c_int(1)): """clear the data acquisition task""" self.AI_ClearStatus = ni.AI_Clear (self.deviceNumber) #print "AI_Clear status =", self.AI_ClearStatus return self.AI_ClearStatus def EasyDAQ_VOp (self): self.AI_Configure (self.deviceNumber, self.chan) self.DAQ_OpStatus, ScaledArray = self.DAQ_VOp (self.deviceNumber, self.chan, self.gain, self.num, self.sampleRate) self.AI_Clear (self.deviceNumber) #status = DAQ_Clear (deviceNumber) return self.DAQ_OpStatus, ScaledArray def Test(self): print "AI_ConfigureStatus =", pd.AI_Configure () print "AO_VWriteStatus () =", pd.AO_Configure () print "AO_VWriteStatus =", pd.AO_VWrite(chan=c_int(1), voltage=c_double(3.0)) print "self.AO_VReadStatus, pvoltage[0] =", pd.AI_VRead () print "self.DAQ_OpStatus, ScaledArray =", pd.DAQ_VOp (chan=c_int(0), num=2, sampleRate=c_double(1000)) print "self.AI_ClearStatus =", pd.AI_Clear (c_int(1)) print print "EasyDAQ_VOpStatus =", pd.EasyDAQ_VOp() pd=pydaq() pd.Test() [End pydaq.py] -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of karthik karthik Sent: Wednesday, January 21, 2004 12:33 AM To: [EMAIL PROTECTED] Subject: [pygtk] using external dlls in python hi! i need to use textract.dll in python .py file to capture the text information within the given coordinates. can anyone tell me how to use external dlls in python? ===== thanks and regards, Karthik. __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
