#include <GUIConstantsEx.au3>
;~ Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $file, $btn, $msg
GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
$file = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
;~ GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files
$btn = GUICtrlCreateButton("运行", 40, 75, 60, 25)
GUISetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
if GUICtrlRead($file)="" then
if BitAND(GUICtrlgetState($btn),$gui_enable) then GUICtrlSetState($btn,$gui_disable)
Else
if BitAND(GUICtrlgetState($btn),$gui_disable) then GUICtrlSetState($btn,$gui_enable)
EndIf
Select
Case $msg = $btn
Run(GUICtrlRead($file))
if @error Then MsgBox(0,0,"未找到可执行文件: "&GUICtrlRead($file)&" !")
EndSelect
WEnd
EndFunc ;==>Example |