View unanswered posts | View active topics It is currently May 21st, '13, 15:28




Reply to topic  [ 2 posts ] 
 win.Find 
Author Message

Joined: Jan 26th, '12, 11:32
Posts: 1
Post win.Find
I'm having a strange issue with win.Find.

If I use task manager, I can see the window listed as "Eden Eternal" but I can never get win.Find to actually return a HWND for this window.

Using the included Windows List.mms, I get:
Code:
[357] H: 00170AF8, T: "Eden Eternal                     ", C: "Eden Eternal
                ".


If plug that HWND into the Window Info.mms, I get:
Code:
 « MacroMonkey v: 2.1 Copyright(c) 2009-2011 by Sirmabus www.macromonkey.com »
HWND: 0x170AF8
T: ""
C: "Eden Eternal                     "
Pos: (0, 0)
Dim: 1920, 1080
CDim: 1920, 1080
pid: 0xE60
id: 0x0
parent: 0x0
hinstance: 0x400000
winproc: 0x0
style: 0xFFFFFFFF96000000
exstyle: 0x0

- Press a key exit -


I'm at a loss as to why win.Find won't find the window and why the two samples provide different titles for the window


Jan 26th, '12, 11:38
Profile
Site Moderator
User avatar

Joined: Aug 18th, '09, 03:32
Posts: 1201
Post Re: win.Find
Could it be that there is just multiple windows that have the "Eden Eternal" class (or title)?
If this is the case then maybe win.Find() is just returning the first occurrence.
It's not that uncommon for an application (particularly games) to have more then one window.
And one or more of them might be hidden/inactive that you probably don't want too.

Something like this should work:
Code:
local hwndTarget = nil

-- Enumerate all windows
local Windows = win.List()
for _,w in ipairs(Windows) do
    -- The one we are looking for?
    if (string.find(w.class, "Eden Eternal", 1,true) and string.find(w.title, "Eden Eternal", 1,true)) then
        hwndTarget = w.hwnd
        break
    end
end

assert(hwndTarget, "Game window not found!")


To see if there are multiple windows you can use the "Windows List.mms", or use a tool like "InqSoft Window Scanner" to list them.
And if in fact there are multiple windows you can narrow them down doing more tests for it's pattern using the window's style, ID, etc.

If this is not the case let me know so I can track down a bug(s) in MM and fix it.
Also please either post or PM me your win.Find() line(s) so I can study it.


Jan 28th, '12, 12:44
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Based on design by STSoftware, modded by Sirmabus Copyright© 2009-2011