-
January 29th, 2013, 02:16 PM
#1
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); } } }
-
January 30th, 2013, 04:36 PM
#2
Re: Win32 API SendMessage not working properly
Instead of using SendMessage, use UIAutomation to automate an external app.
-
January 31st, 2013, 02:11 PM
#3
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
-
January 31st, 2013, 06:11 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|