[PATCH] WindowMatcher.Find() - hwnd too large

Found a bug in EventGhost? Report it here.

[PATCH] WindowMatcher.Find() - hwnd too large

Postby magao » Thu Jun 23, 2011 8:57 pm

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>
Attachments
__init__.py
(1.88 KiB) Downloaded 95 times
WindowMatcher.py
(6.42 KiB) Downloaded 94 times
Last edited by magao on Sun Jun 26, 2011 1:34 am, edited 2 times in total.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby Pako » Fri Jun 24, 2011 5:06 pm

I never got this exception.
Do you have any idea how to achieve it?
What is your operating system?

Pako
User avatar
Pako
Plugin Developer
 
Posts: 1283
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby magao » Fri Jun 24, 2011 9:49 pm

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.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby magao » Fri Jun 24, 2011 10:04 pm

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.
Last edited by magao on Sun Jun 26, 2011 1:35 am, edited 1 time in total.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby Pako » Sat Jun 25, 2011 10:29 am

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
User avatar
Pako
Plugin Developer
 
Posts: 1283
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby magao » Sat Jun 25, 2011 9:56 pm

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 ...
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby magao » Sun Jun 26, 2011 1:36 am

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.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: [PATCH] WindowMatcher.Find() - hwnd too large

Postby Pako » Mon Jun 27, 2011 3:23 pm

Included since version r1534.

Pako
User avatar
Pako
Plugin Developer
 
Posts: 1283
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 2 guests