CTypes

S

SoutoJohn

I'm trying to install PyWinAuto for Python 2.4. It said that one of
the required libraries that I need to install would be CTypes. So I
head over to CTypes's SourceForge page and I installed CTypes for
Python 2.4. I go to run the PyWinAuto installation file and it throws
up this error:

C:\WINDOWS\Desktop\pywinauto-0.3.6>C:\Python24\Python setup.py install
Traceback (most recent call last):
File "setup.py", line 29, in ?
import pywinauto
File "C:\WINDOWS\Desktop\pywinauto-0.3.6\pywinauto\__init__.py",
line 28, in ?

import findwindows
File "C:\WINDOWS\Desktop\pywinauto-0.3.6\pywinauto\findwindows.py",
line 31, i
n ?
import win32functions
File "C:\WINDOWS\Desktop\pywinauto-0.3.6\pywinauto
\win32functions.py", line 14
9, in ?
GetModuleFileNameEx =
ctypes.windll.psapi.GetModuleFileNameExW

File "C:\PYTHON24\lib\site-packages\ctypes\__init__.py", line 387,
in __getatt
r__
dll = self._dlltype(name)
File "C:\PYTHON24\lib\site-packages\ctypes\__init__.py", line 312,
in __init__

self._handle = _dlopen(self._name, mode)
WindowsError: [Errno 1157] One of the library files needed to run this
applicati
on cannot be found

I have found out that anything that calls CTypes is producing this
error. I looked into the CTypes source and I found:

def __init__(self, name, mode=DEFAULT_MODE, handle=None):
self._name = name
if handle is None:
self._handle = _dlopen(self._name, mode) <errored line
else:
self._handle = handle

So my best guess is that I'm either missing a Python library or I'm
missing a DLL. Too bad I don't know which, does anyone know what I'm
missing?
 
M

Mark

Hi,

I forgot to mention I am running Windows 98SE.

Hmm - pywinauto is not supported on Windows 98 - it relies competely
on Unicode.

You could try renaming all the functions ending in W to ending in A
e.g. change GetModuleFileNameExW to GetModuleFileNameExA - but I am
fairly sure that this would NOT solve all the problems you would have
trying to run on W98.

As far as I know (not 100% sure) but ctypes should have no problem on
W98 - it is a pywinauto requirement for Unicode.

Another thing to look into might be Unicows.dll (which gives some
Unicode functions to W98)

Mark
 
S

SoutoJohn

Hey, I really appreciate you responding to my post. I've been on this
problem for some days now and it was getting to me. Sad that pywinauto
doesn't run on Win98SE, are there any other Python libraries for
'automating' Windows COM? If not I looked into AutoIt, which is a
Windows automation tool. It has a DLL which I believe contains all the
methods it does in the scripting language it has. I read over the
(yeah, 'the'. I keep finding the exact same tutorial) ctypes tutorial,
and I don't get it. I don't get how to load a DLL. So if I had a
script file 'test.py' and a DLL 'AutoIt3X.DLL' in the same folder, how
could I load it? The tutorial did something like dll=windll.kernel32,
which I understands loads the kernel but I don't see how I could apply
that to load AutoIt3X. Thanks in advanced.
 
D

Dennis Lee Bieber

script file 'test.py' and a DLL 'AutoIt3X.DLL' in the same folder, how
could I load it? The tutorial did something like dll=windll.kernel32,
which I understands loads the kernel but I don't see how I could apply
that to load AutoIt3X. Thanks in advanced.

I've not used ctypes, but from all the examples I've seen....

What happens if you specify:

dll = ctypes.windll.AutoIt3X

I think ctypes uses a getattr() trap to extract the dll name from
the invocation, then passes that to the Windows library loading code.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
C

Chris Mellon

I've not used ctypes, but from all the examples I've seen....

What happens if you specify:

dll = ctypes.windll.AutoIt3X

I think ctypes uses a getattr() trap to extract the dll name from
the invocation, then passes that to the Windows library loading code.
--

This is indeed what ctypes does. There's also a LoadLibrary static
method of windll.cdll etc that you can use to get it explicitly (like
if you need to load a DLL not on your path).

dll = ctypes.windll.LoadLibrary(r"C:\AutoIT#x.dll")
 
G

Gabriel Genellina

En Sat, 03 Feb 2007 13:01:56 -0300, (e-mail address removed)
I'm trying to install PyWinAuto for Python 2.4. It said that one of
the required libraries that I need to install would be CTypes. So I
head over to CTypes's SourceForge page and I installed CTypes for
Python 2.4. I go to run the PyWinAuto installation file and it throws
up this error:

GetModuleFileNameEx =
ctypes.windll.psapi.GetModuleFileNameExW

So my best guess is that I'm either missing a Python library or I'm
missing a DLL. Too bad I don't know which, does anyone know what I'm
missing?

From the line above, should be "psapi.dll"
I don't know it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top