如何在GUI控件中使用GuiDropFiles?

时间:2013-06-10 21:35:20

标签: scripting autohotkey

如何将GuiDropFiles与GUI控件一起使用?

我的表单中有几个edit字段,我希望能够将文件单独删除并与它们一起使用。

这就是我提出的:

首先,我的控件设置如下:

WS_EX_ACCEPTFILES=0x10

Gui, add, edit,  vedit1, %file_1%
WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1

我的拖放程序就是这样:

GuiDropFiles:  ; Support drag & drop.
    Loop, parse, A_GuiControlEvent, `n
    {
        thisfile := a_loopfield  ; Get the first file only (in case there's more than one).
        thiscontrol := a_guicontrol
        break
    }

    alert(thisfile . "`r" . thiscontrol)

    if(thiscontrol = edit1)
        guicontrol,,%edit1%, %thisfile%
    if(thiscontrol = edit2)
        guicontrol,,%edit2%, %thisfile%
    if(thiscontrol = edit3)
        guicontrol,,%edit3%, %thisfile%

return

我正在使用autohotkey文档中的basic example。我也尝试了example from here,但它一直说,“不要放在编辑框上”。 任何线索都会很棒。

1 个答案:

答案 0 :(得分:0)

想出来(经过几个小时后)。

首先,我不需要这个:WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1

我不需要在编辑控件上设置任何样式。

所有我需要的是这个,因为我的编辑控件的变量名以“UI_file”开头,所以这是有效的:

GuiDropFiles:  ; Support drag & drop.

    Loop, parse, A_GuiEvent, `n
    {
        thisfile := A_LoopField  ; Get the first file only (in case there's more than one).
        thiscontrol := a_guicontrol
        break
    }
    ;alert(thisfile . "`r" . thiscontrol)

    If InStr(A_GuiControl, "UI_file")
        guicontrol,,%A_GuiControl%, %thisfile%

return