[check] WinUtil.cc: suggestions for enhancements and fixes

Bug #1292336 reported by Luke Dunstan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
In Progress
Medium
RaiMan

Bug Description

focusWinByAppName in WinUtil.cc attempts to use GetWindowModuleFileName() to search for applications by executable name but there are multiple bugs in that function:

1. GetWindowModuleFileName() only works for windows owned by the calling process (i.e. Sikuli itself): http://support.microsoft.com/?id=228469

2. GetWindowModuleFileName() returns a fully-qualified path, and I think looking for a substring in this path is not a good idea. Instead it should look at executable filename only, i.e. the last component of the path.

3. focusWinByAppName does not initialise the "filename" variable and it does not check to see whether GetWindowModuleFileName() succeeded or failed, so when it fails the "filename" variable is uninitialised.

One consequence of this is that if I run Sikuli from a path containing the word "Foo" and then I try to call App.focus('Foo') with the intention of focusing an application with that word in the title bar, Sikuli may set the focus to the wrong window, depending on the order of windows returned by EnumWindows().

I am using Sikuli IDE 1.0.1 on Windows Server 2008 R2 (64-bit).

Revision history for this message
RaiMan (raimund-hocke) wrote :

Thanks for finding and the suggestion

Changed in sikuli:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.0
RaiMan (raimund-hocke)
Changed in sikuli:
status: Fix Committed → In Progress
milestone: 1.1.0 → 2.0.0
summary: - Sikuli focuses the wrong application
+ [1.1.0.] WinUtil.cc: suggestions for enhancements and fixes
RaiMan (raimund-hocke)
Changed in sikuli:
milestone: 2.0.0 → 2.1.0
importance: High → Medium
summary: - [1.1.0.] WinUtil.cc: suggestions for enhancements and fixes
+ [check] WinUtil.cc: suggestions for enhancements and fixes
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.