Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. (((((((How do I send a message!))))))

(((((((How do I send a message!))))))

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++jsontutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    peshkunta
    wrote on last edited by
    #1

    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.

    V 1 Reply Last reply
    0
    • P peshkunta

      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.

      V Offline
      V Offline
      vishalmore
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • V vishalmore

        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

        P Offline
        P Offline
        peshkunta
        wrote on last edited by
        #3

        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!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups