2013-10-09 18 views

回答

0

我會在調用fl.componentsPanel.addItemToDocument之前編寫一個程序(帶有延遲)來確認「解決庫衝突」對話框並使用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(...); 

相關問題