(((((((How do I send a message!))))))
-
I would like to use Win API's SendMessage( wnd, WM_GETTEXTLENGTH, 0, 0 );, or PostMessage function to be able to get the text from the textbox of another program. Let's say, I would like to be able to get the text from Instant Messenger and show it in my App. Does anyone know how to do this! I'm doing it in C#, but I'm posting here because those functions are not C# native and you are more familiar with them than C# programmers.
-
I would like to use Win API's SendMessage( wnd, WM_GETTEXTLENGTH, 0, 0 );, or PostMessage function to be able to get the text from the textbox of another program. Let's say, I would like to be able to get the text from Instant Messenger and show it in my App. Does anyone know how to do this! I'm doing it in C#, but I'm posting here because those functions are not C# native and you are more familiar with them than C# programmers.
Hi peshkunta, You want to retrieve the text from the text box of some Instant messenger? What all you require are 1. HWND of -- IM 2. Class name for text box (most of cases it's "Edit") The API's you would require are... 1. EnumWindows: -Pass IM HWND as 1 param, and give your (own) callback function name as second param to this API. -Loop through the text boxes inside IM (if more text boxes exists). -When ever you get the text box from where you want to retrive the text return TRUE from callback to terminate the enumeration. (one possible approach to compare the text boxes is compare class name) -EnumWindows must return you the HWND to (desired) text box. 2. PostMessage -Use PostMessage to get the text from the text box. Pseudo code is done... now get in action to retrive the text ! all the very best ! Cheers, Vishal
-
Hi peshkunta, You want to retrieve the text from the text box of some Instant messenger? What all you require are 1. HWND of -- IM 2. Class name for text box (most of cases it's "Edit") The API's you would require are... 1. EnumWindows: -Pass IM HWND as 1 param, and give your (own) callback function name as second param to this API. -Loop through the text boxes inside IM (if more text boxes exists). -When ever you get the text box from where you want to retrive the text return TRUE from callback to terminate the enumeration. (one possible approach to compare the text boxes is compare class name) -EnumWindows must return you the HWND to (desired) text box. 2. PostMessage -Use PostMessage to get the text from the text box. Pseudo code is done... now get in action to retrive the text ! all the very best ! Cheers, Vishal
Thanks so much for the response! I'm not very familiar with C++ functions. I know that SendMessage or PostMessage have many versions (all accept different parameters), but I have no experience in using them. I know how to get the handle of a window/dialog (HWND), and pass the message constant WM_CLOSE, etc., but I'm not sure how to get the class of a text box, hence don't know how to loop through them. Is EnumWindows a function? And how do I use it? That below is what I think I'm most iffy about: ****************************************************************** -Loop through the text boxes inside IM (if more text boxes exists). -When ever you get the text box from where you want to retrive the text return TRUE from callback to terminate the enumeration. (one possible approach to compare the text boxes is compare class name) -EnumWindows must return you the HWND to (desired) text box. ****************************************************************** Could you please write me an example on how I would do that? THANKS!!