Clearing a field with sendmessage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gerdescm
    New Member
    • Jan 2008
    • 2

    Clearing a field with sendmessage

    I am working on automating a program whose source I don't have. I have everything working except I am struggling with sending a message to two fields. I am able to send the characters using a cmdlet created by Dr. McCaffrey, which uses sendmessage.
    The problem is that this appends the characters to the end of the field. I want to make another cmdlet that clears the field first so that I may then append the characters to it but I canot figure out how to do that with sendmesage and I was unable to find anything about that in the user32 library.

    Thanks for the help all.
  • answers4forums
    New Member
    • Dec 2007
    • 2

    #2
    Hi Gerdescm,

    I dont know which platform ur using.

    in linux and other RTOS :- we can use message-ques for sending and receiving the messages.

    ur problem: see have a buffer( file for storing the messages), before writing into buffer make sure u ask the question whether :
    1. to append to the existing file,
    2. to clear the earlier contents.

    !!Sorry!! if i have not given the solution.

    Regards,
    Answers.

    Comment

    • gerdescm
      New Member
      • Jan 2008
      • 2

      #3
      Hey, thanks for the response. I am running on windows XP, so that does not supply the answer sadly. to give a bit more detail on how it is working, the cmdlet is using the user32.dll library which has a sendmessage function contained within. The sendmessage function can do many things when interfacing with a window control (it can click buttons append to fields etc) but I cannot find documentation on how to select what it is to do or what capabilities it has. I believe (judging by the code) that the WM_CHAR = 0x0102 is what specifies that it should be appending characters to the field. Unfortunately I have not been able to find information on what I would need to specify to have it either clear the field or simply replace the contents of the field with what I specify. I have included the code of the cmdlet that appends characters below. Thanks again for your help!


      Code:
      [Cmdlet(VerbsCommunications.Send, "Chars")]
          public class SendCharsCommand : Cmdlet
          {
              private IntPtr handleControl;
              private string s;
      
              [Parameter(Position = 0)]
              public IntPtr HandleControl {
                  get { return handleControl; }
                  set { handleControl = value; }
              }
      
              [Parameter(Position = 1)]
              public string S {
                  get { return s; }
                  set { s = value; }
              }
      
              [DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)]
              private static extern void SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
      
              protected override void ProcessRecord() {
                  uint WM_CHAR = 0x0102;
                  foreach (char c in s) {
                      SendMessage(handleControl, WM_CHAR, c, 0);
                  }
              }
          } // class SendCharsCommand
      Originally posted by answers4forums
      Hi Gerdescm,

      I dont know which platform ur using.

      in linux and other RTOS :- we can use message-ques for sending and receiving the messages.

      ur problem: see have a buffer( file for storing the messages), before writing into buffer make sure u ask the question whether :
      1. to append to the existing file,
      2. to clear the earlier contents.

      !!Sorry!! if i have not given the solution.

      Regards,
      Answers.

      Comment

      Working...