Win32 API SendMessage not working properly
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Win32 API SendMessage not working properly

  1. #1
    Join Date
    Mar 2003
    Location
    Crofton, MD
    Posts
    76

    Question Win32 API SendMessage not working properly

    I can not figure out why my send messages will only work when debugging. When I launch from the .exe file it appears that they are not firing. The code is just suppose to click a button on en external application.

    Code:
    private void TransferBuild (object sender, EventArgs e)  //Button Click Event
    {
    
    string sync = @"C:\USCG_IMS\SyncMgr.exe"; if (File.Exists(sync)) {
    this.Hide(); ActiveSync.FileName = sync; ActiveSync.CreateNoWindow = false; ActiveSync.UseShellExecute = false; SyncRun.StartInfo = ActiveSync; SyncRun.EnableRaisingEvents = true; SyncRun.Exited += new EventHandler (SyncRun_Exited); SyncRun.Start(); // Initiate the off-load process by auto-clicking the 'OK' button Process[] processes = Process.GetProcessByName ("SYNCMGR"); foreach (Process p in processes) {
    IntPtr hWnd = FindWind(p.MainWindowHandle, null); IntPtr hWndChild = FindWindowEx (hWnd, IntPtr.Zero, null, "Sync Mgr"); IntPtr ButtonHandle = FindWindEx (hWndChild, IntPtr.Zero, "Button", null); SendMessage (ButtonHandle, BN_CLICK, WM_LBUTTONDOWN, IntPtr.Zero); SendNessage (ButtonHandle, BN_CLICK, WM_LBUTTONUP, IntPtr.Zero);
    }
    }
    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,480

    Re: Win32 API SendMessage not working properly

    Instead of using SendMessage, use UIAutomation to automate an external app.

  3. #3
    Join Date
    Mar 2003
    Location
    Crofton, MD
    Posts
    76

    Re: Win32 API SendMessage not working properly

    I have never used UIAutomation. Can you give me some pointers or example of how to accomplish the task I posted?

    Thank you,

    mekinnik

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,480

    Re: Win32 API SendMessage not working properly


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center