Пример #1
0
        private static void DoCloseOpenFileDialog(NktRemoteBridge remoteBridge, Process proc)
        {
            IntPtr hWnd;

            try
            {
                hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Open", "#32770", false);
                if (hWnd == IntPtr.Zero)
                    hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Abrir", "#32770", false);
                if (hWnd == IntPtr.Zero)
                {
                    Console.WriteLine("Cannot find OpenFileDialog window");
                    return;
                }
                //we can try sending a WM_COMMAND with IDOK but we will try to find the ok button and send
                //fake lbuttondown/up to test more methods instead.
                hWnd = remoteBridge.GetChildWindowFromId(proc.Id, hWnd, 1);
                if (hWnd == IntPtr.Zero)
                {
                    Console.WriteLine("Cannot find OpenFileDialog's OK button");
                    return;
                }
                remoteBridge.PostMessage(proc.Id, hWnd, 0x0201, IntPtr.Zero, IntPtr.Zero); //WM_LBUTTONDOWN
                remoteBridge.PostMessage(proc.Id, hWnd, 0x0202, IntPtr.Zero, IntPtr.Zero); //WM_LBUTTONUP
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return;
        }
Пример #2
0
        private static void DoCloseOpenFileDialog(NktRemoteBridge remoteBridge, Process proc)
        {
            IntPtr hWnd;

            try
            {
                hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Open", "#32770", false);
                if (hWnd == IntPtr.Zero)
                    hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Abrir", "#32770", false);
                if (hWnd == IntPtr.Zero)
                {
                    Console.WriteLine("Cannot find OpenFileDialog window");
                    return;
                }
                //we can try sending a WM_COMMAND with IDOK but we will try to find the ok button and send
                //fake lbuttondown/up to test more methods instead.
                hWnd = remoteBridge.GetChildWindowFromId(proc.Id, hWnd, 1);
                if (hWnd == IntPtr.Zero)
                {
                    Console.WriteLine("Cannot find OpenFileDialog's OK button");
                    return;
                }
                remoteBridge.PostMessage(proc.Id, hWnd, 0x0201, IntPtr.Zero, IntPtr.Zero); //WM_LBUTTONDOWN
                remoteBridge.PostMessage(proc.Id, hWnd, 0x0202, IntPtr.Zero, IntPtr.Zero); //WM_LBUTTONUP
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return;
        }
Пример #3
0
        private static void DoGetOpenFileDialogFilename(NktRemoteBridge remoteBridge, Process proc)
        {
            IFileOpenDialog dlg = null;
            object obj = null;
            IntPtr hWnd;
            string s;

            try
            {
                hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Open", "#32770", false);
                if (hWnd == IntPtr.Zero)
                    hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Abrir", "#32770", false);
                if (hWnd == IntPtr.Zero)
                {
                    Console.WriteLine("Cannot find OpenFileDialog window");
                    return;
                }
                obj = remoteBridge.GetComInterfaceFromHwnd(proc.Id, hWnd, ShellIIDGuid.IFileDialog);
                if (obj == null)
                {
                    Console.WriteLine("Cannot find retrieve IFileOpenDialog interface");
                    return;
                }
                dlg = obj as IFileOpenDialog;
                dlg.GetFileName(out s);
                Console.WriteLine("Filename: [" + s + "]");
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                //if (dlg != null)
                //    Marshal.ReleaseComObject(dlg);
                if (obj != null)
                    Marshal.ReleaseComObject(obj);
            }
            return;
        }
Пример #4
0
        private static void DoGetOpenFileDialogFilename(NktRemoteBridge remoteBridge, Process proc)
        {
            IFileOpenDialog dlg = null;
            object obj = null;
            IntPtr hWnd;
            string s;

            try
            {
                hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Open", "#32770", false);
                if (hWnd == IntPtr.Zero)
                    hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Abrir", "#32770", false);
                if (hWnd == IntPtr.Zero)
                {
                    Console.WriteLine("Cannot find OpenFileDialog window");
                    return;
                }
                obj = remoteBridge.GetComInterfaceFromHwnd(proc.Id, hWnd, ShellIIDGuid.IFileDialog);
                if (obj == null)
                {
                    Console.WriteLine("Cannot find retrieve IFileOpenDialog interface");
                    return;
                }
                dlg = obj as IFileOpenDialog;
                dlg.GetFileName(out s);
                Console.WriteLine("Filename: [" + s + "]");
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                //if (dlg != null)
                //    Marshal.ReleaseComObject(dlg);
                if (obj != null)
                    Marshal.ReleaseComObject(obj);
            }
            return;
        }