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?
How to Install Pywin32?
-
- One Eyed Hopeful
- Posts: 34
- Joined: Tue Dec 22, 2015 12:52 pm
Re: How to Install Pywin32?
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.
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.
-
- One Eyed Hopeful
- Posts: 3
- Joined: Fri Mar 17, 2017 12:38 am
Re: How to Install Pywin32?
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.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 just figured out a way to do using ctypes, but it does not work on freePIE. The code runs fine on python however.
Code: Select all
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
Code: Select all
329066
(-31993, -32000, -31847, -31972)
<_FuncPtr object at 0x03DC1A80>
<_FuncPtr object at 0x03DC1AF8>
<ctypes.wintypes.RECT object at 0x03C52D50>
-
- One Eyed Hopeful
- Posts: 3
- Joined: Fri Mar 17, 2017 12:38 am
Re: How to Install Pywin32?
Nevermind, I found a way, here it is how:
Code: Select all
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))