Home Download Screenshots Wiki Plugins Translations Developers Donate Forums/Help Contact Us |
StrokeIt
Command to identify Childwindows alien script ?Posted by Leo
Hello,
I want to write a alien script to identify childwindows. from here I have this one http://www.activevb.de/rubriken/apikatalog/deklarationen/childwindowfrompoint.html require [[Alien\alien]] local eev = alien.User32.ChildWindowFromPoint eev:types{ ret = 'long', abi = 'stdcall',"long","pointer"} eev(gesture.point(0)) ---from example.lua start_x, start_y from gesture plugin.call("Utilities", "MessageBox", tostring(eev),"i") This is not working :). Can someone get it to work ? Thanks Leo Edited 1 time(s). Last edit at 12/14/2009 07:17AM by Leo.
Yep, it does not and it should not work in the form you posted. Let's clarify why.
ChildWindowFromPoint is a function that returns a childwindow handle based on a parent window handle and a point: HWND ChildWindowFromPoint( HWND hWndParent, POINT Point ); That means, if you want to get the child, you have to provide the parent. So you have to get it first. WindowFromPoint is another function that returns window handle based on a point: HWND WindowFromPoint( POINT Point ); You call them as WindowFromPoint(gesturestartpoint) and ChildWindowFromPoint(parenthandle, gesturestartpoint). Since there is (or at least I haven't found) a point type in lua, you are going to call those functions with two longs instead of a point as parameter. The code fragment down below should do what you want (well, more or less :): EDIT: after re-reading it, it will be a little 'less'. ChildWindowFromPoint requires the point to be relative to the parent, so you might have to adjust the result you get from gesture.point(). But I leave that up to you :P require [[Alien\alien]] local wfp = alien.User32.WindowFromPoint wfp:types{ ret = 'long', abi = 'stdcall', 'long', 'long' } -- two longs for the point local cwfp = alien.User32.ChildWindowFromPoint cwfp:types{ ret = 'long', abi = 'stdcall', 'long', 'long', 'long' } -- one long for the parenthandle and two for the point local wh = wfp(gesture.point(0)) local params = string.format([["%s" "%s"]], tostring(wh), 'Window handle') plugin.call("Utilities", "MessageBox", params) local cwh = cwfp(wh, gesture.point(0)) local params = string.format([["%s" "%s"]], tostring(cwh), 'Child Window handle') plugin.call("Utilities", "MessageBox", params) Edited 1 time(s). Last edit at 12/14/2009 09:07AM by gemisigo.
Just to clarify, you can use 'hwnd' inside a script to get the current hwnd at the point the window started, so there's no need to call WindowFromPoint
You would need to call MapWindowPoints to translate the points from screen coordinate to window coordinates. However, I've added a new 'hwnd_child' command to the scripting language so you can get the child window handle that way. One you have it, you'll probably want to call [url=http://msdn.microsoft.com/en-us/library/ms633582%28VS.85%29.aspx]GetClassName[/url] to get the 'name' of it and using that you can get do per-child window gestures. -- Jeff
Thank you very much gemisigo and Jeff,
Finally StrokeIt came close to my dream windows manipulator. Child window gestures would be awesome ! Jeff can you that way make gestures over buttons and different buttons makes different actions with the same gestures ? That way you finally reached girder. Thanks Leo
> However, I've added a new 'hwnd_child' command to
> the scripting language so you can get the child > window handle that way. One you have it, you'll > probably want to call GetClassName to get the > 'name' of it and using that you can get do > per-child window gestures. That's awesome, Jeff :) Now I've all I need. Thank you very much!
> Jeff can you that way make gestures over buttons and different buttons makes
> different actions with the same gestures ? Yes. You'll have to get the child class (example below), then check that against whatever child window class you're looking for and then run the appropriate commands. -- Jeff require[[alien]] local GetClassName = alien.User32.GetClassNameA GetClassName:types{ ret = 'long', abi = 'stdcall', 'long', 'pointer', 'int' } local buf = alien.buffer(512) GetClassName(gesture.hwnd_child(), buf, 511) local child_class = tostring(buf); local messagebox = alien.User32.MessageBoxA messagebox:types{ ret = 'long', abi = 'stdcall', 'long', 'string', 'string', 'long' } messagebox(0, "App Window: " .. string.format("0x%X", gesture.hwnd()) .. "\n\n" .. "Child Window: " .. string.format("0x%X", gesture.hwnd_child()) .. "\n" .. "Child Class: " .. child_class, "Get Child Class", 0)
Thanks again Jeff awesome feature ! so gemisigo what made I wrong again ?
require[[alien]] local GetWindowText= alien.User32.GetWindowTextA GetWindowText:types(ret ='long', abi = 'stdcall', 'long', 'pointer', 'int'} local buf2 = alien.buffer(512) GetWindowText(gesture.hwnd_child(), buf2, 511) local window_text = tostring(buf2);
You are being a bit careless :P The problem lies in the brackets you are using, namely the firs one in the code line below:
The winner (or loser) is: GetWindowText:types(ret ='long', abi = 'stdcall', 'long', 'pointer', 'int'} It should be: GetWindowText:types{ret ='long', abi = 'stdcall', 'long', 'pointer', 'int'}
|