首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSFL -响应"Replace Existing Item“对话框

JSFL -响应"Replace Existing Item“对话框
EN

Stack Overflow用户
提问于 2013-10-10 02:38:32
回答 1查看 424关注 0票数 0

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

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

如果可能的话,我想通过jsfl来回复这个提示。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-10-10 19:35:22

在调用fl.componentsPanel.addItemToDocument之前,我会编写一个程序(带有延迟)来确认'Resolve Library Conflict‘对话框,并用FLfile.runCommandLine调用它。我知道如何在Windows上做到这一点,但在Mac上就不行了。

(在windows中,用于确认替换的程序可以是:

请参阅微软-开发中心-桌面>示例>在C#中快速枚举顶级窗口

代码语言:javascript
复制
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中,这个程序可以用以下命令启动:

代码语言:javascript
复制
FLfile.runCommandLine("start ConfirmReplace.exe");
fl.componentsPanel.addItemToDocument( ... );

)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19280007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档