我正在使用jsfl向fla添加一个新版本的自定义组件。
这将提示用户选择是否替换现有组件。
如果可能的话,我想通过jsfl来回复这个提示。
谢谢。
发布于 2013-10-10 19:35:22
在调用fl.componentsPanel.addItemToDocument之前,我会编写一个程序(带有延迟)来确认'Resolve Library Conflict‘对话框,并用FLfile.runCommandLine调用它。我知道如何在Windows上做到这一点,但在Mac上就不行了。
(在windows中,用于确认替换的程序可以是:
请参阅微软-开发中心-桌面>示例>在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( ... );)
https://stackoverflow.com/questions/19280007
复制相似问题