找回密码
 加入
搜索
查看: 2096|回复: 4

帮我完成一个脚本

[复制链接]
发表于 2008-10-10 20:11:52 | 显示全部楼层 |阅读模式


如图,在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 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-10-10 21:48:44 | 显示全部楼层

$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
 楼主| 发表于 2008-10-10 22:04:38 | 显示全部楼层
可以了,谢谢啊,能不能输入数字后 按回车键也能打开

[ 本帖最后由 botanycc 于 2008-10-10 22:09 编辑 ]
发表于 2008-10-10 22:47:26 | 显示全部楼层
使用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
发表于 2008-10-11 16:54:32 | 显示全部楼层

回复 3# botanycc 的帖子

在2楼的3/4行之间加一行

GUICtrlSetState(-1,$GUI_DEFBUTTON)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 21:57 , Processed in 0.072372 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表