hi guys, im just starting out in asm and im trying to get the windows text that the mouse is over into an edit box. i have the code in a timer (WM_TIMER) invoke GetCursorPos, addr pt invoke WindowFromPoint, addr pt.x, addr pt.y mov WindowID, eax invoke GetWindowText, WindowID, addr buffer, 255 invoke SendMessage, TextBoxID, WM_SETTEXT, 0, addr buffer for some reason it wont get any windows caption at all, does anyone know what the problem could be?
Per MSDN, "GetWindowText cannot retrieve the text of a control in another application." Oops :-)
oh =(, do you know how i could fix the code to make it work good? =]
Learn how to navigate Microsoft's online documentation at http://msdn.microsoft.com/library/default.asp The docs for GetWindowText say to SendMessage WM_GETTEXT. There's even a link to the WM_GETTEXT message.
This message was edited by tank, on 1/29/2001 1:56:29 AM This message was edited by tank, on 2/1/2001 11:18:09 PM
SendMessage( (HWND) hWnd, // handle to destination window WM_GETTEXT, // message to send (WPARAM) wParam, // number of characters to copy (LPARAM) lParam // text buffer );
sorry to keep bothering you guys like this but i really cant seem to figure this out :(. i tried WM_GETTEXT this time and for some reason it still wont work. I checked to see if it was finding the window for it to grab the text from and its not picking it up at all - heres what i put: pt: POINT WindowID dword 0 invoke GetCursorPos, addr pt invoke WindowFromPoint, addr pt.x, addr pt.y mov WindowID, eax .if (WindowID != NULL) invoke SendMessage, WindowID, WM_GETTEXT, 255, addr buffer invoke SendMessage, TextBoxID, WM_SETTEXT, 0, addr buffer .endif
The call to WindowFromPoint is wrong. The arguments needed are the x-y coordinates, not the addresses to them. Change to invoke WindowFromPoint, pt.x, pt.y This message was edited by tank, on 1/29/2001 6:33:37 PM
thanks so much tank! =). Im sort of confused now though - i use to think you had to use addr or offset on those kind of things. how do you know when to use "addr, offset or neither of them?".
You have to look at the docs. If the argument is not a pointer, you definitely don't use ADDR. If the argument is a pointer, it needs an address. Whether or not you use ADDR depends on whether or not the source "variable" is also a pointer. ***** If we assume pV to be the name of a pointer variable that points to a data item/buffer V, then you have the following options. Pointer argument (it wants address of V) invoke APIfunc, pV invoke APIfunc, addr V Nonpointer argument (it wants data stored in V) invoke APIfunc, V ; to get the value of V indirectly from pV, we put ; the contents of pV (= addr V) into a register to ; make V addressable. mov edx,pV invoke APIfunc, dword ptr