Can someone make me this function for ASM? Thanks in advance
Posted on 2003-06-29 18:42:53 by ESP
Looks like EnumWindows to me...

Just enumerate them all - discard all the hidden and child windows' - add the hWnd into an array and grab any data of those windows which you need.
Posted on 2003-06-29 20:32:19 by JimmyClif
I'm just looking for a way to find a Dialog Window that has a caption that's the time window poped up. IE: "Message - June 28th 2:49 AM"

For now I been using
invoke FindWindow, addr classname, addr caption

though that will only get the handle of the window with that exact caption...
Posted on 2003-06-29 20:49:12 by ESP
Just have a look under \masm32\examples1\winenum\

Here we grab the hWnd and the ClassName of all windows and show them in an ListView or ListBox. It's quite easy to just replace the call which gets the ClassName of the windows with a GetWindowText call....

Now, that you made that just have a look at the first dword to see if it is "sseM" for Mess(age) if it is - do whatever you want with it.
Posted on 2003-06-29 21:50:45 by JimmyClif
I managed to freeze my PC lol. Anyway, I need a way to somehow check the caption for a string too; since the window class is #32770. Maybe I could find window by the handle? Would multiple windows of it open change the handle?
Posted on 2003-06-30 17:26:17 by ESP
As JimmyClif said use GetWindowText to examine the caption of the window. EnumWindows will pass every window to a callback routine, so you could do something like this:
invoke EnumWindows,OFFSET EnumWindowsProc,NULL


EnumWindowsProc PROC hWnd:DWORD,lParam:DWORD
LOCAL WindowText[256] :BYTE
invoke GetWindowText,hWnd,ADDR WindowText,256
; Do something with the text here
; for example compare the caption with a TargetCaption
; TargetCaption db "My Window",0
;
invoke lstrcmp,ADDR WindowText,OFFSET TargetCaption
;
; Return TRUE to continue or FALSE to stop
; lstrcmp will return FALSE and stop the enumeration
; when it finds the TargetCaption
ret
EnumWindowsProc ENDP
Posted on 2003-06-30 21:38:49 by donkey
That's just like I had, but I was actually checking the class with strcmp. That's probably what went wrong... Thank you very much :) Both of you
Posted on 2003-06-30 21:47:29 by ESP
I just Read your middle post. You can insert the following, it will clip off the date and time and check for "Message - " :
invoke EnumWindows,OFFSET EnumWindowsProc,NULL


EnumWindowsProc PROC hWnd:DWORD,lParam:DWORD
LOCAL WindowText[256] :BYTE
invoke GetWindowText,hWnd,ADDR WindowText,256
; Do something with the text here
; for example compare the caption with a TargetCaption
; TargetCaption db "Message - ",0
;
[b]lea eax,WindowText
mov [eax+10],BYTE PTR 0[/b]
invoke lstrcmp,ADDR WindowText,OFFSET TargetCaption
;
; Return TRUE to continue or FALSE to stop
; lstrcmp will return FALSE and stop the enumeration
; when it finds the TargetCaption
ret
EnumWindowsProc ENDP
Posted on 2003-06-30 21:49:25 by donkey
Thanks I was working that out too, you saved me alot of time lol

How can I move the caption out of the proc if it's the right one? I can't figure it out...
Posted on 2003-06-30 22:26:05 by ESP
Return the handle to the Window then you can get it again when you need it. The actual buffer that the caption is held in in my example is fudged by the insertion of a zero. You could just copy it to a global string as well.
Posted on 2003-06-30 22:40:53 by donkey
THANKS YOU GUYS works great. I just had addr WindowText and not offset WindowText
Posted on 2003-07-01 00:22:04 by ESP