Importing win32api

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Nettingman
Newbie
Posts: 1
Joined: Sun Jun 25, 2017 11:43 am
Contact:

Importing win32api

#1 Post by Nettingman »

Hi,
I'm trying to make a game, where one of the characters can break the 4th wall, by turning on and off the Caps Lock.

I'm trying to do this by using the win32api module, to make virtual keypresses. The problem is, I can't import the module.
I downloaded it to python 2.7, and copied the files from

C:\Python27\Lib\site-packages
to
the_question\game\python-packages

Sadly it's not working (even though, other modules do).
ImportError: No module named win32api

It's a possible issue, that this is a library, and also win32api has a .pyd extension not .py.
I tried with copying only win32api.pyd, but I got the same error.

Any idea how to solve it?
Attachments
traceback.txt
(1.22 KiB) Downloaded 18 times

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Importing win32api

#2 Post by PyTom »

This seems like a terrible terrible idea.

But if you really want to do it, the files need to be dropped off somewhere in lib/windows-i686.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
storykween
Regular
Posts: 154
Joined: Mon Sep 30, 2013 1:17 pm
Completed: Serafina's Saga, Quantum Conscience, Echoes of the Fey, miraclr - Divine Dating Sim
Organization: Woodsy Studio
Location: St Louis
Contact:

Re: Importing win32api

#3 Post by storykween »

I am also trying to import win32api, AKA pywin32. In this case I'm doing it to enable desktop notifications.

I copied all the files from C:\Python27\Lib\site-packages to:

game\python-packages
AND:
lib/windows-i686

In my project's init code, I use the following code to import it:

Code: Select all

init python:
      if renpy.windows:
            from win32api import *
            from win32gui import *
            from win32gui import IsIconic
            import win32con
            import sys, os
            import struct
            import win32gui
On my OWN computer, this all works fine. However, as soon as I try to build out the game and play it on a different Windows computer, I get this error:

Code: Select all

While running game code: 
     File "game/functions.rpy", line 20, in <module>   #this is the first line of import code, containing from win32api import *
ImportError: DLL Load failed: The specified module could not be found. 
Again, this only happens once I BUILD the game. Any ideas why the game isn't building with the included libraries?
Image
My website: woodsy-studio.com

User avatar
storykween
Regular
Posts: 154
Joined: Mon Sep 30, 2013 1:17 pm
Completed: Serafina's Saga, Quantum Conscience, Echoes of the Fey, miraclr - Divine Dating Sim
Organization: Woodsy Studio
Location: St Louis
Contact:

Re: Importing win32api

#4 Post by storykween »

I'm still struggling with this on a game I'm releasing soon. If anyone has any ideas, I would really appreciate the help!
Image
My website: woodsy-studio.com

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Importing win32api

#5 Post by PyTom »

Sorry, but i don't support 3rd-party compiled python modules directly. You can take a look at your two windows-i686 directories to see which DLLs are missing there.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users