找回密码
 加入
搜索
查看: 5150|回复: 9

[系统综合] 【已解决】 如何选择并执行EXE文件

  [复制链接]
发表于 2015-3-7 09:53:34 | 显示全部楼层 |阅读模式
本帖最后由 dnvplj 于 2015-3-7 14:37 编辑

请问各位朋友:在下图中如何选择\Soft\1.EXE文件(任意分区)并显示路径,按“执行”后1.EXE文件运行安装程序。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 396, 109, 192, 124)
$Group2 = GUICtrlCreateGroup("", 8, 8, 385, 97)
GUICtrlCreateInput("", 16, 24, 313, 21)
$Button1 = GUICtrlCreateButton("选择", 336, 24, 49, 25)
$Button2 = GUICtrlCreateButton("执    行", 232, 64, 73, 33)
$Button3 = GUICtrlCreateButton("退    出", 312, 64, 73, 33)
$Label1 = GUICtrlCreateLabel("可选任意分区文件(U盘)", 16, 72, 200, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        FileOpenDialog('选择文件','','exe文件(*.exe)',1)
                Case $Button2
                        
                Case $Button3
                        
                        Exit                        

        EndSwitch
WEnd

本帖子中包含更多资源

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

×
发表于 2015-3-7 10:33:25 | 显示全部楼层
回复 1# dnvplj

$Input = GUICtrlCreateInput("", 16, 24, 313, 21)

Case $Button1
$Inputa = FileOpenDialog('选择文件', '', 'exe文件(*.exe)', 1, '', $Form1)
GUICtrlSetData($Input, $Inputa)
Case $Button2
RunWait("" & GUICtrlRead($Input))
 楼主| 发表于 2015-3-7 13:14:30 | 显示全部楼层
回复 2# chzj589
首先感谢2楼朋友的回复,现存在2个问题:
1、返回的路径显示为一个“4”,没有返回完整的路径
2、文件选择后,点“执行”没有反映,程序没有运行。

本帖子中包含更多资源

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

×
发表于 2015-3-7 13:22:51 | 显示全部楼层
回复 3# dnvplj
代码你是怎样加进去的?我自己有调试通过的
 楼主| 发表于 2015-3-7 13:26:18 | 显示全部楼层
回复 4# chzj589
按2楼的代码加的
发表于 2015-3-7 13:27:50 | 显示全部楼层
回复 5# dnvplj
贴出来看一下,可能加错了。
 楼主| 发表于 2015-3-7 13:28:36 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\我的文档\Desktop\4-1\4-01.kxf
Global $gu_Form2 = GUICreate("文件选择", 391, 103, 193, 125)
Global $gu_Group1 = GUICtrlCreateGroup("", 8, 8, 377, 89)
Global $gu_Input1 = GUICtrlCreateInput("", 16, 24, 297, 21)
Global $gu_Button1 = GUICtrlCreateButton("选  择", 321, 21, 57, 25)
Global $gu_Button2 = GUICtrlCreateButton("执  行", 240, 56, 65, 33)
Global $gu_Button3 = GUICtrlCreateButton("退  出", 313, 56, 65, 33)
Global $gu_Label1 = GUICtrlCreateLabel("请选择正确的EXE文件", 16, 64, 164, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $gu_Button1

$gu_Inputa1 = FileOpenDialog('选择文件', '', 'exe文件(*.exe)', 1, '', $gu_Form2)

                        GUICtrlSetData($gu_Input1, $gu_Input1)

                Case $gu_Button2
                        
                        RunWait("" & GUICtrlRead($gu_Input1))
                        
                Case $gu_Button3
                        
                        Exit

        EndSwitch
WEnd
发表于 2015-3-7 13:33:15 | 显示全部楼层
回复 7# dnvplj
这句错了:
GUICtrlSetData($gu_Input1, $gu_Input1)
应该是:
GUICtrlSetData($gu_Input1, $gu_Inputa1)

评分

参与人数 1金钱 +10 收起 理由
dnvplj + 10 乐于助人

查看全部评分

发表于 2015-3-7 13:34:51 | 显示全部楼层
FileOpenDialog帮助里有实例
 楼主| 发表于 2015-3-7 13:35:17 | 显示全部楼层
回复 8# chzj589
这回可以了,谢谢你朋友。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 16:17 , Processed in 0.134549 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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