JSFL - 响应“替换现有项目”对话框

时间:2013-10-09 18:38:32

标签: flash jsfl

我正在使用jsfl为fla添加新版本的自定义组件。

这会提示用户选择是否替换现有组件。

如果可能,我想通过jsfl回复此提示。

感谢。

1 个答案:

答案 0 :(得分:0)

我会编写一个程序(有延迟)来确认'Resolve Library Conflict'对话框,并在调用fl.componentsPanel.addItemToDocument之前用FLfile.runCommandLine调用它。 我知道如何在Windows中执行此操作,但不能在Mac上执行此操作。

(在Windows中程序确认更换可能是:
请参阅Microsoft - 开发人员中心 - 桌面>样品>在C#中快速枚举顶级窗口

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace FlashHack
{
    class Program
    {
        protected delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        protected static extern int GetWindowText(IntPtr hWnd, StringBuilder strText, int maxCount);
        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        protected static extern int GetWindowTextLength(IntPtr hWnd);
        [DllImport("user32.dll")]
        protected static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
        [DllImport("user32.dll")]
        protected static extern bool IsWindowVisible(IntPtr hWnd);
        [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
        internal static extern IntPtr GetParent(IntPtr hwnd);
        [DllImport("User32.dll", EntryPoint = "SetForegroundWindow")]
        private static extern IntPtr SetForegroundWindowNative(IntPtr hWnd);
        protected static bool AnswerResolveLibraryConflictDlg(IntPtr hWnd, IntPtr lParam)
        {
            int size = GetWindowTextLength(hWnd);
            if (size++ > 0 && IsWindowVisible(hWnd))
            {
                StringBuilder sb = new StringBuilder(size);
                GetWindowText(hWnd, sb, size);
                if (sb.ToString() == "Resolve Library Conflict")
                {
                    IntPtr parent = GetParent(hWnd);
                    Console.WriteLine(sb.ToString());
                    if (parent != null)
                    {
                        SetForegroundWindowNative(parent);
                        SendKeys.SendWait("{TAB} {ENTER}");
                    }
                }
            }
            return true;
        }
        static void Main(string[] args)
        {
            System.Threading.Thread.Sleep(1000); // Must wait for the 'Resolve Library Conflict'-dlg
            Console.WriteLine("Now!");
            EnumWindows(new EnumWindowsProc(AnswerResolveLibraryConflictDlg), IntPtr.Zero);
        }
    }
}

在jsfl中,这个程序可以用以下方式开始:

FLfile.runCommandLine("start ConfirmReplace.exe");
fl.componentsPanel.addItemToDocument( ... );

相关问题