CTypes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SoutoJohn@gmail.com

    #1

    CTypes

    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\Desk top\pywinauto-0.3.6>C:\Python 24\Python setup.py install
    Traceback (most recent call last):
    File "setup.py", line 29, in ?
    import pywinauto
    File "C:\WINDOWS\Des ktop\pywinauto-0.3.6\pywinauto \__init__.py",
    line 28, in ?

    import findwindows
    File "C:\WINDOWS\Des ktop\pywinauto-0.3.6\pywinauto \findwindows.py ",
    line 31, i
    n ?
    import win32functions
    File "C:\WINDOWS\Des ktop\pywinauto-0.3.6\pywinauto
    \win32functions .py", line 14
    9, in ?
    GetModuleFileNa meEx =
    ctypes.windll.p sapi.GetModuleF ileNameExW

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

    self._handle = _dlopen(self._n ame, 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_MO DE, handle=None):
    self._name = name
    if handle is None:
    self._handle = _dlopen(self._n ame, 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?

  • SoutoJohn@gmail.com

    #2
    Re: CTypes

    I forgot to mention I am running Windows 98SE.

    Comment

    • Mark

      #3
      Re: CTypes

      Hi,

      On Feb 3, 6:22 pm, "SoutoJ...@gmai l.com" <SoutoJ...@gmai l.comwrote:
      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 GetModuleFileNa meExW to GetModuleFileNa meExA - 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

      Comment

      • SoutoJohn@gmail.com

        #4
        Re: CTypes

        On Feb 4, 7:26 am, "Mark" <mark.m.mcma... @gmail.comwrote :

        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.kern el32,
        which I understands loads the kernel but I don't see how I could apply
        that to load AutoIt3X. Thanks in advanced.

        Comment

        • Chris Mellon

          #5
          Re: CTypes

          On 2/4/07, Dennis Lee Bieber <wlfraed@ix.net com.comwrote:
          On 4 Feb 2007 05:16:27 -0800, "SoutoJohn@gmai l.com"
          <SoutoJohn@gmai l.comdeclaimed the following in comp.lang.pytho n:
          >
          >
          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.kern el32,
          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.A utoIt3X
          >
          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.L oadLibrary(r"C: \AutoIT#x.dll")

          Comment

          • Gabriel Genellina

            #6
            Re: CTypes

            En Sat, 03 Feb 2007 13:01:56 -0300, SoutoJohn@gmail .com
            <SoutoJohn@gmai l.comescribió:
            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:
            >
            GetModuleFileNa meEx =
            ctypes.windll.p sapi.GetModuleF ileNameExW
            >
            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.

            --
            Gabriel Genellina

            Comment

            Working...