Ok I've seen a few threads over the last few months about using "EnumerateWindow" or "FindWindow" to get the handle to another window...

My question is this (using a recent thread)
Say I want to get the text from a window (AIM) I have open...
You can do this:
.data
iMClass db "AIM_IMessage",0
.code
invoke FindWindow, addr iMEditClass, 0

Now this would only get one window (you could enumerate all of these instances, but this is just a simple example)...

But where do you go from here?

How do you access the IM edit box (is there some standard way to do this...


I know if you have a hook you can basically change everything, but can it be done without having the user having to select everything?

Basically I was trying to see if I could write an simple application that would send a message to all active windows (saying "Goodbye" or whatever) and got stuck on this first part :(

Any help is appreciated

Sliver
Posted on 2002-03-20 04:40:04 by Sliver
Maybe sending WM_GETTEXT/SETTEXT would do it
Posted on 2002-03-20 07:56:16 by Quantum
use a window spy to get the Window Control ID and maybe the parent window

then use GetDlgItem to get the handle to that window.
or FindWindowEx first if it has a parent window

i attached the program Spy & Capture, the author's site seems to be down.
Posted on 2002-03-20 09:28:08 by savage
This is my code so far:



invoke FindWindow, addr iMClass, 0
mov hWndAim, 000008A8h
mov hWndAimButton, 00000b28h
invoke SendMessage,hWndAim,WM_GETTEXTLENGTH,0,0
invoke SendMessage,hWndAim,WM_SETTEXT,0,addr iMEditClass
Invoke SendMessage, hWndAimButton, WM_LBUTTONDOWN, 0, 0
Invoke SendMessage, hWndAimButton, WM_LBUTTONUP, 0, 0

FindWindow really doesn't do a whole lot in this example because I ended up just hardcoding the values ...

The problem is that the values can't be hardcoded in reallife :( Meaning the valu for the edit box and the send button change with each instance of the application

So the question is now?

Given a window with alot of buttons and edit boxes how do you pick the right one or is there a command to narrow this down?

Help would seriously be appreciated
Sliver
Posted on 2002-03-20 13:54:00 by Sliver
Use the Spy to get the ControlID values, not the handles, because the controlid's are (always) static.

then use invoke GetDlgItem, hWnd, ControlID to get the handle..



IDC_AIMBUTTON equ 1000
;assuming the controlid of the button is 1000 (just as an example)

invoke FindWindow, addr iMClass, 0
mov hWndAim, eax ;not sure if this is right, because i dont have aim
invoke GetDlgItem, hWndAim, IDC_AIMBUTTON
mov hWndAimButton, eax
Invoke SetWindowText, hWndAimButton, CTEXT("Test")
Posted on 2002-03-20 14:34:11 by savage