Click here to Skip to main content
15,888,461 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: COm Callable Assembly Missing From Reference Lists Pin
Brady Kelly30-Jan-08 8:26
Brady Kelly30-Jan-08 8:26 
GeneralFTP WEB Request error (550) File unavailable Pin
Sean_B29-Jan-08 5:21
Sean_B29-Jan-08 5:21 
GeneralRe: FTP WEB Request error (550) File unavailable Pin
Mike Dimmick29-Jan-08 6:59
Mike Dimmick29-Jan-08 6:59 
GeneralRe: FTP WEB Request error (550) File unavailable Pin
Sean_B30-Jan-08 1:08
Sean_B30-Jan-08 1:08 
GeneralRe: FTP WEB Request error (550) File unavailable Pin
Sean_B30-Jan-08 3:01
Sean_B30-Jan-08 3:01 
GeneralWeb services Pin
dSolariuM28-Jan-08 20:57
dSolariuM28-Jan-08 20:57 
GeneralCross Post Pin
led mike29-Jan-08 5:45
led mike29-Jan-08 5:45 
QuestionAny suggestions for how to "automate" a Drag-n-Drop'ed folder using the new System.Windows.Automation namespace? Pin
Phreud28-Jan-08 18:26
Phreud28-Jan-08 18:26 
First, a friendly gesture: This is my first forum question at codeproject! I have probably read hundreds of articles, and forum threads on CodeProject.com, and to tell you the truth, I find that other people have already asked all the right questions and there are already answers! I love codeproject.com for that!

The reason I am not finding answers is probably due to the fact that I am kicking the tires on something quite new--only available in Visual Studio 2008 with .Net 3.5 if I understand correctly.

Topic of my question: The Microsoft UI Automation Library
[^]

This MSDN article is dated, February 2008, and I can hardly wait until this stuff has been out in the wild longer--because there is little to no searchable resources other than MSDN documentation which is usually quite sparse in my experience.

My first 'hello world' UI automation experiment involves simply daisy-chaining two graphical UI applications on the desktop, referred to below as, extractApp and renameApp. I have all the source code available for extractApp--I wrote it, using C# on .Net 3.5 with Studio 2008. I did NOT write, and do not have access to the sourcecode of renameApp application. From what I can tell, it is a pure win32 app, definitely not a .Net app, and there is no (uncryptic) CLI. Cry | :((

Goal: Application extractApp finishes processing files in a folder, and I would like it to be able to "hand off" this folder (by object or string name) to the renameApp. There is no CLI available to use, however the renameApp does contain a control that supports a DragAndDrop operation. That is, if you drag a folder from an Explorer window, onto this "list1" control of the windows form for renameApp, it will respond to this DragAndDrop'ed folder name.

Side note: There is a ContextMenuHandler in the Windows registry for accomplishing this same "DragAndDrop" type of operation that was installed by this renameApp that I wouldn't mind figuring out how to be able to trigger programmatically from my extractApp as well. If you have any suggestions as to how I might programmatically execute a "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shellex\ContextMenuHandlers\{classid-string}" when there is no (known, published) verb implemented in the registry to use with ShellExecuteEx, or System.Diagnostics.Process.FileName="rundll32.exe shell32.dll,verb" + dirname" I'm all ears as well.

I couldn't figure out how to do this with the information at: http://msdn2.microsoft.com/en-us/library/bb776883.aspx[^] I gave up after discovering that there is this new and cool UI Automation namespace in .net 3.5 anyway...

Problem: I fairly quickly deciphered (from the new Feb. 2008 UI Automation MSDN article) how to get the handle of the control (in the renameApp) which needs to act as the target (or System.Windows.Automation.InvokePattern ??) of the DragAndDrop event triggered normally, by a user, using this short simple code:

Process renameCommandAppProcess = new Process();
renameCommandAppProcess.StartInfo = renameCommandApp;
renameCommandAppProcess.Start();

if (false == renameCommandAppProcess.WaitForInputIdle(10000))
{
    MessageBox.Show("'renameApp' did not respond in a timely manner.", "Missing 'renameApp' application...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
}
else
{
    IntPtr hrenameAppHandle = renameCommandAppProcess.MainWindowHandle;
    if (hrenameAppHandle != IntPtr.Zero)
    {
        if (SetForegroundWindow(hrenameAppHandle))
        {
            // naive approach
            //Thread.Sleep(5000);
            AutomationElement aeForm = AutomationElement.FromHandle(hrenameAppHandle);
            if (aeForm == null)
                MessageBox.Show("'renameApp' did not hand over control in a timely manner.", "Missing 'renameApp' application?", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);

            AutomationElement aeButton = aeForm.FindFirst(TreeScope.Children,
                new PropertyCondition(AutomationElement.NameProperty, "List1"));
            if (aeButton == null)
                MessageBox.Show("'renameApp' did not hand over control: List1.", "Missing 'renameApp' application?", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            else
                MessageBox.Show("'renameApp' found control: List1.", "Found it!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);

            /*
             *
             * Now what?  Which of the "16 patterns" do I use if I need to automate a DragAndDrop from
             * application A to application B?
             *
             * The author of the Feb 2008 article chose simple controls like buttons and textboxes.
             * I need something you can sink your teeth into though,
             * like the target control of a DragAndDrop'ed folder object. :)
             *
             * My first guess was (but this didn't work):
             * InvokePattern ipDropFolderObject1 =
             *  (InvokePattern)aeButton.GetCurrentPattern(InvokePattern.Pattern);
             * ipDropFolderObject1.Invoke();
             * Thread.Sleep(1500);
             */

            // Anyone even using this System.Windows.Automation stuff yet?
            // Do you have any alternative suggestions?
        }
    }
}


By "16 patterns" I am referring to the table at the bottom of "Figure 6" of this article here:
http://www.codeproject.com/script/Forums/Edit.aspx?fid=1650&floc=/script/Forums/View.aspx[^]

Thankyou in advance for even taking the time to read this very lengthy post.

I apologize for any etiquette rules I overlooked in the FAQ. Poke tongue | ;-P

-Phreud
General3.5 to 3.0 Conversion Pin
ss.mmm28-Jan-08 8:23
ss.mmm28-Jan-08 8:23 
GeneralRe: 3.5 to 3.0 Conversion Pin
Pete O'Hanlon28-Jan-08 10:15
mvePete O'Hanlon28-Jan-08 10:15 
GeneralRe: 3.5 to 3.0 Conversion Pin
ss.mmm28-Jan-08 11:01
ss.mmm28-Jan-08 11:01 
GeneralRe: 3.5 to 3.0 Conversion Pin
Ed.Poore28-Jan-08 21:50
Ed.Poore28-Jan-08 21:50 
GeneralRe: 3.5 to 3.0 Conversion Pin
Pete O'Hanlon28-Jan-08 21:53
mvePete O'Hanlon28-Jan-08 21:53 
GeneralRe: 3.5 to 3.0 Conversion Pin
Ed.Poore29-Jan-08 2:08
Ed.Poore29-Jan-08 2:08 
GeneralRe: 3.5 to 3.0 Conversion Pin
Pete O'Hanlon29-Jan-08 2:58
mvePete O'Hanlon29-Jan-08 2:58 
GeneralRe: 3.5 to 3.0 Conversion Pin
Ed.Poore29-Jan-08 3:01
Ed.Poore29-Jan-08 3:01 
Question0xc0150002 error Pin
Arsalan Malik28-Jan-08 4:54
Arsalan Malik28-Jan-08 4:54 
GeneralCross post Pin
led mike28-Jan-08 7:09
led mike28-Jan-08 7:09 
GeneralRe: Cross post Pin
Arsalan Malik29-Jan-08 1:24
Arsalan Malik29-Jan-08 1:24 
GeneralRemoting and events Pin
bwilhite28-Jan-08 3:14
bwilhite28-Jan-08 3:14 
GeneralRe: Remoting and events Pin
led mike28-Jan-08 6:57
led mike28-Jan-08 6:57 
GeneralRe: Remoting and events Pin
bwilhite28-Jan-08 8:21
bwilhite28-Jan-08 8:21 
GeneralRe: Remoting and events Pin
bwilhite28-Jan-08 14:04
bwilhite28-Jan-08 14:04 
GeneralRe: Remoting and events Pin
Joachim Kerschbaumer6-Feb-08 4:24
Joachim Kerschbaumer6-Feb-08 4:24 
GeneralRe: Remoting and events Pin
bwilhite6-Feb-08 10:10
bwilhite6-Feb-08 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.