How to use SendMessage?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bennyn
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 1:00 pm
Contact:

How to use SendMessage?

Post by bennyn » Mon Mar 28, 2011 11:09 am

Hello, I need to get a text from a "RichEdit20W" textarea. The internal Macro Scheduler function "GetWindowTextEx" does not fulfill my needs because it only gets the text which can be seen on top but the textarea has got a scrollbar and I want to get all of the text (even from the bottom of the textarea).

In C++ I did this with the following statement:

Code: Select all

SendMessage(handle, WM_GETTEXT, 25000, (LPARAM) buffer);
In MacroScheduler I tried it with:

Code: Select all

LibFunc>User32,FindWindowExA,handle,hwnd,0,RichEdit20W,0
LibFunc>User32,SendMessageA,result,handle,13,25000,0
My problem is, that I do not know how to set the (LPARAM) buffer when using SendMessageA in MacroScheduler. Therefore I passed a "0" for it but this does not work. Can anyone tell me how to set (LPARAM) buffer in MacroScheduler? This would be nice.

Greetings

Benny

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 28, 2011 3:31 pm

Let>buffer_SIZE=1024
LibFunc>User32,SendMessageA,result,handle,13,25000,buffer
MessageModal>result_4
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

bennyn
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 1:00 pm
Contact:

Post by bennyn » Tue Mar 29, 2011 1:11 pm

mtettmar wrote:Let>buffer_SIZE=1024
LibFunc>User32,SendMessageA,result,handle,13,25000,buffer
MessageModal>result_4
Many thanks for the answer. I got it now with:
GetWindowHandle>My Window Title,hwnd
LibFunc>User32,FindWindowExA,handle,hwnd,0,RichEdit20W,0
Let>buffer_SIZE=2560
LibFunc>User32,SendMessageA,result,handle,13,25000,buffer
MessageModal>result_4
The only problem I have now is that a buffer size of 2560 bytes is too small. If I change it to 2810 (or even more) then the MacroScheduler freezes. The text I want to get has about 13662 bytes. Is there any chance to get it?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Mar 29, 2011 1:16 pm

You're setting your buffer size to a size smaller than the max number of characters you are asking it to extract. So this would cause a crash/hang. You probably want something like:

Let>buffer_SIZE=25000
LibFunc>User32,SendMessageA,result,handle,13,25000,buffer
MessageModal>result_4

You should be fine if the buffer size is equal to or larger than the value you're passing in lparam which for WM_GETTEXT is the max number of chars to copy.

And you should also extract the string from result_4 up to the null character so that you're not reading past the end of the returned data.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts