Page 1 of 1
[PATCH] WindowMatcher.Find() - hwnd too large
Posted: Thu Jun 23, 2011 8:57 pm
by magao
Since at least r1486 (probably earlier - I expect the change to python 2.6 was the cause) hwnds are always returned in EventGhost as a positive integer, resulting in a "hwnd too large" exception from WindowMatcher.Find().
<EDIT>Changes needed to both eg.WinApi.__init__.py and eg.Classes.WindowMatcher.py</EDIT>
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Fri Jun 24, 2011 5:06 pm
by Pako
I never got this exception.
Do you have any idea how to achieve it?
What is your operating system?
Pako
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Fri Jun 24, 2011 9:49 pm
by magao
Win7 64-bit, though I don't know if it's specifically the 64-bit part. I left raising an exception in the patch to see if it ever raised after the fix, and it never has.
I used to get it quite frequently before I patched it. I almost never reboot my machine, so it's got time for very large numbers of windows to be created (and destroyed) - I suspect this is the cause.
I'll revert the patch and see if I can get it to recur.
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Fri Jun 24, 2011 10:04 pm
by magao
OK - not exactly the same - looks like another place that needs patching:
Code: Select all
Traceback (most recent call last) (1529):
File "C:\Program Files (x86)\EventGhost\plugins\Window\FindWindow.py", line 512, in OnSelectionChanged
GetClassName(hwnd) == targetWinClass and
OverflowError: long int too large to convert to int
To replicate: create a new FindWindow action, uncheck all criteria (including program name) and check search invisible items (so it will look at every window in the system). Not guaranteed, but a good chance of finding one.
Given that, I've now changed WinApi.__init__.py to return a "fixed" list of hwnds from GetTopLevelWindowList(). Ideally this would be fixed in cFunctions.GetTopLevelWindowList(), but for now the attached WinApi.__init__.py will work. WindowMatcher.py was getting GetTopLevelWindowList() directly from eg.cFunctions - I've changed it to use eg.WinApi.
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Sat Jun 25, 2011 10:29 am
by Pako
magao wrote:Win7 64-bit
I thought so. Apparently this problem occurs only in Win7 64-bit. In this case, I do not have the opportunity to try it.
However, I think that your patch can be used.
I thank you.
You're probably a better programmer than I am. I'm just an amateur and autodidact.
I would welcome it if you become more involved in the development of EG.
Pako
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Sat Jun 25, 2011 9:56 pm
by magao
I've contributed a few things to EG over the years (PS3 remote SNIFF mode, some stuff to the Broadcaster plugin). In general I just scratch my itches, but I might contribute more if I could find the bug tracker ...
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Sun Jun 26, 2011 1:36 am
by magao
Bah - just found that WindowMatcher.py didn't import from eg.WinApi but directly from eg.cFunctions. I've added both fixed files to the first post.
Re: [PATCH] WindowMatcher.Find() - hwnd too large
Posted: Mon Jun 27, 2011 3:23 pm
by Pako
Included since version r1534.
Pako