It is currently Sun Oct 22, 2017 4:42 pm



Reply to topic  [ 4 posts ] 
 How to Install Pywin32? 
Author Message
One Eyed Hopeful

Joined: Fri Mar 17, 2017 12:38 am
Posts: 3
Reply with quote
I'm having trying to install pywin32 on FreePIE, I sucessfully installed it on my python 2.7 folder and copied the contents from site-packages to FreePIE's correspondent folder.
But when use import win32gui i got the error : No module named win32gui.

Does anyone know how to install this module?


Sun Mar 19, 2017 7:36 am
Profile
One Eyed Hopeful

Joined: Tue Dec 22, 2015 12:52 pm
Posts: 33
Reply with quote
Most information I could find about pywin32 compatibility with IronPython dates back from 2009. Part of the library is written in pure python, so it should be compatible. As far as I understood, there are some parts built/compiled specifically for cpython, which'll obviously not work in IronPython.

Anyway, perhaps a more important question is: what are you trying to achieve with pywin32? Maybe we can help you out with newer, alternative methods, or figure out whether the part that you need is compatible with IronPython.


Sun Mar 19, 2017 1:52 pm
Profile
One Eyed Hopeful

Joined: Fri Mar 17, 2017 12:38 am
Posts: 3
Reply with quote
MarijnS95 wrote:
Most information I could find about pywin32 compatibility with IronPython dates back from 2009. Part of the library is written in pure python, so it should be compatible. As far as I understood, there are some parts built/compiled specifically for cpython, which'll obviously not work in IronPython.

Anyway, perhaps a more important question is: what are you trying to achieve with pywin32? Maybe we can help you out with newer, alternative methods, or figure out whether the part that you need is compatible with IronPython.


I am trying to find a way to get the size of a specific window and its handler. Since it seems very easy to do with pywin that was my first option.

I just figured out a way to do using ctypes, but it does not work on freePIE. The code runs fine on python however.

Code:
import ctypes.wintypes
from ctypes import wintypes, windll, sizeof, byref

FindWindow = ctypes.windll.user32.FindWindowA

hwnd = FindWindow(None, 'Untitled - Notepad')

foundwindow = ctypes.windll.dwmapi.DwmGetWindowAttribute

if foundwindow:
    rect = ctypes.wintypes.RECT()
    DWMWA_EXTENDED_FRAME_BOUNDS = 9
    foundwindow(
        ctypes.wintypes.HWND(hwnd),
        ctypes.wintypes.DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),
        ctypes.byref(rect), ctypes.sizeof(rect))
    window_size = (rect.left, rect.top, rect.right, rect.bottom)

print hwnd
print window_size
print FindWindow
print foundwindow
print rect


It returns this on python shell, but null on FreePIE

Code:
329066
(-31993, -32000, -31847, -31972)
<_FuncPtr object at 0x03DC1A80>
<_FuncPtr object at 0x03DC1AF8>
<ctypes.wintypes.RECT object at 0x03C52D50>


Replacing "ctypes.windll.user32.FindWindowA" with the actual handler makes FreePIE return the same value as python.


Sun Mar 19, 2017 9:32 pm
Profile
One Eyed Hopeful

Joined: Fri Mar 17, 2017 12:38 am
Posts: 3
Reply with quote
Nevermind, I found a way, here it is how:

Code:
import ctypes.wintypes
from ctypes import wintypes, windll, sizeof, byref

FindWindow = ctypes.windll.user32.FindWindowExW
FindWindow.argtypes = [
    wintypes.HWND,
    wintypes.HWND,
    wintypes.LPCWSTR,
    wintypes.LPCWSTR,
]

hwnd = FindWindow(None,None,None, 'Untitled - Notepad')

foundwindow = ctypes.windll.dwmapi.DwmGetWindowAttribute

if foundwindow:
    rect = ctypes.wintypes.RECT()
    DWMWA_EXTENDED_FRAME_BOUNDS = 9
    foundwindow(
        ctypes.wintypes.HWND(hwnd),
        ctypes.wintypes.DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),
        ctypes.byref(rect), ctypes.sizeof(rect))
    window_size = (rect.left, rect.top, rect.right, rect.bottom)

window_width = rect.left + rect.right
window_height = rect.top + rect.bottom

#set cursor in the middle of the screen, so clicking wont change windows focus
#cemu_active = window.active you need window.active plugin to check if window is active
#if (cemu_active == "Cemu") and (enabled):
set_cursor = ctypes.windll.user32.SetCursorPos((window_width / 2),(window_height / 2))


Mon Mar 20, 2017 12:34 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.