views:

157

answers:

0

When I try to transform my script in an executable, I get this error after it's done:

Traceback (most recent call last):
  File "shd-WinResize.py", line 4, in <module>
  File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32api.pyd

I'm using this script to convert:

from distutils.core import setup
import py2exe
import sys

sys.argv.append('py2exe')

setup(
    options = {'py2exe': dict(bundle_files=1, optimize=2)},
    windows = ["shd-WinResize.py"],
    zipfile = None,
    )

and here is the source of my program:

import pyHook
import pythoncom

import win32api
import win32console
import win32gui

hideConsole = win32console.GetConsoleWindow()
win32gui.ShowWindow(hideConsole, 0)


def OnKeyboardEvent(event):
    if event.Ascii == 49:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1440, 900, True)
    elif event.Ascii == 50:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1366, 768, True)
    elif event.Ascii == 51:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1280, 1024, True)
    elif event.Ascii == 52:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1280, 960, True)
    elif event.Ascii == 53:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1280, 800, True)
    elif event.Ascii == 54:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1280, 768, True)
    elif event.Ascii == 55:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1152, 864, True)
    elif event.Ascii == 56:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 1024, 768, True)
    elif event.Ascii == 57:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 800, 600, True)
    elif event.Ascii == 48:
        windowFocused = win32gui.GetForegroundWindow()
        win32gui.MoveWindow(windowFocused, 0, 0, 640, 480, True)


hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()

what is wrong with it?

I want compressed and I want bundle... What should I do?