帮我完成一个脚本
如图,在C盘目录下有很多以数字命名的文本文件,只要在选项框中输入相应数字,再点击打开,就可以打开相应文档,或是不点击按钮直接回车也可以打开,这个怎么做,谢谢
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 259, 186, 193, 125)
GUICtrlCreateInput("", 64, 48, 81, 21)
$Button1 = GUICtrlCreateButton("打开", 80, 104, 51, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
ShellExecute("c:\1.txt")
EndSwitch
WEnd
[ 本帖最后由 botanycc 于 2008-10-11 14:35 编辑 ]
$Form1 = GUICreate("Form1", 259, 186, 193, 125)
$input1 = GUICtrlCreateInput("", 64, 48, 81, 21)
$Button1 = GUICtrlCreateButton("打开", 80, 104, 51, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$path = "C:\" & GUICtrlRead($input1) & ".txt"
If Not FileExists($path) Then
MsgBox(64, "提示", "文件不存在")
Else
ShellExecute($path)
EndIf
EndSwitch
WEnd
可以了,谢谢啊,能不能输入数字后 按回车键也能打开
[ 本帖最后由 botanycc 于 2008-10-10 22:09 编辑 ] 使用HotKeySet
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 259, 186, 193, 125)
$input1 = GUICtrlCreateInput("", 64, 48, 81, 21)
$Button1 = GUICtrlCreateButton("打开", 80, 104, 51, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet ( "{ENTER}" , "Open")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$path = "C:\" & GUICtrlRead($input1) & ".txt"
If Not FileExists($path) Then
MsgBox(64, "提示", "文件不存在")
Else
ShellExecute($path)
EndIf
EndSwitch
WEnd
Func Open()
$path = "C:\" & GUICtrlRead($input1) & ".txt"
If Not FileExists($path) Then
MsgBox(64, "提示", "文件不存在")
Else
ShellExecute($path)
EndIf
EndFunc
回复 3# botanycc 的帖子
在2楼的3/4行之间加一行GUICtrlSetState(-1,$GUI_DEFBUTTON)
页:
[1]