找回密码
 加入
搜索
查看: 4439|回复: 14

[系统综合] 见笑了,写了个框框,却不知道怎么实现功能[已解决]

  [复制链接]
发表于 2010-9-19 06:24:34 | 显示全部楼层 |阅读模式
本帖最后由 无名蜘蛛 于 2010-9-19 08:58 编辑
#include <GUIConstantsEx.au3>
$winman = GUICreate("运行命令",300,100,-1,-1)
$inputcmd = GUICtrlCreateInput("",20,30,180,25)
$buttoncmd = GUICtrlCreateButton("运行",210,25,70,35)
GUISetState()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $gui_event_close
                        Exit
        EndSwitch
WEnd
我知道这很扯淡,希望有人能帮我解决,还有就是不用点击运行,在框框里输入命令直接回车也运行的那种!!!
拜谢!!!!!!!!!

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

 楼主| 发表于 2010-9-19 06:54:55 | 显示全部楼层
我把他改成
#include <GUIConstantsEx.au3>
$winman = GUICreate("运行命令",300,100,-1,-1)
$inputcmd = GUICtrlCreateInput("",20,30,180,25)
$buttoncmd = GUICtrlCreateButton("运行",210,25,70,35)
GUISetState()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $gui_event_close
                        Exit
                Case $buttoncmd
                        $inputcmdcmd = GUICtrlRead($inputcmd)
                        Run($inputcmdcmd)
        EndSwitch
WEnd


但是只可以运行环境变量里的EXE
控制台必须加mmc才识别例如mmc gpedit.msc直接gpedit.msc是不可用的
除了Run其他的不知道可以不?
 楼主| 发表于 2010-9-19 07:00:41 | 显示全部楼层
最后想法
#include <GUIConstantsEx.au3>
$winman = GUICreate("运行命令",300,100,-1,-1)
$inputcmd = GUICtrlCreateInput("",20,30,180,25)
$buttoncmd = GUICtrlCreateButton("运行",210,25,70,35)
GUISetState()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $gui_event_close
                        Exit
                Case $buttoncmd
                        $inputcmdcmd = GUICtrlRead($inputcmd)
                        Run(@ComSpec & "/c" &$inputcmdcmd,"",@SW_HIDE)
        EndSwitch
WEnd
还是失败
发表于 2010-9-19 07:15:29 | 显示全部楼层
本帖最后由 netegg 于 2010-9-19 07:17 编辑

那个用这个函数不行, 看看关于wm_click消息的操作可能有帮助
发表于 2010-9-19 07:39:34 | 显示全部楼层
本帖最后由 republican 于 2010-9-19 07:57 编辑

回复 3# 无名蜘蛛

你自己写的命令不规范而已。
#include <GUIConstantsEx.au3>
$winman = GUICreate("运行命令",300,100,-1,-1)
$inputcmd = GUICtrlCreateInput("",20,30,180,25)
$buttoncmd = GUICtrlCreateButton("运行",210,25,70,35)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
GUISetState()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $gui_event_close
                        Exit
                Case $buttoncmd
                        Run("cmd /c " &GUICtrlRead($inputcmd),"",@SW_HIDE)
        EndSwitch
WEnd


本帖子中包含更多资源

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

×

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-9-19 07:51:09 | 显示全部楼层
回复 5# republican


    你有试过吗?
我复制过去,测试不可以啊?
 楼主| 发表于 2010-9-19 07:56:40 | 显示全部楼层
终于搞好了,汗!!

不知道可用实现回车,不需要点运行???????
#include <GUIConstantsEx.au3>
$winman = GUICreate("运行命令",300,100,-1,-1)
$inputcmd = GUICtrlCreateInput("",20,30,180,25)
$buttoncmd = GUICtrlCreateButton("运行",210,25,70,35)
GUISetState()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $gui_event_close
                        Exit
                Case $buttoncmd
                        $inputcmdcmd = GUICtrlRead($inputcmd)
                        Run("cmd /c "&$inputcmdcmd,"",@SW_HIDE)
        EndSwitch
WEnd
 楼主| 发表于 2010-9-19 08:12:05 | 显示全部楼层
全部完成
#include <GUIConstantsEx.au3>
$winman = GUICreate("运行命令",300,100,-1,-1)
HotKeySet("{Enter}","_entercmd")
$inputcmd = GUICtrlCreateInput("",20,30,180,25)
$buttoncmd = GUICtrlCreateButton("运行",210,25,70,35)
GUISetState()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $gui_event_close
                        Exit
                Case $buttoncmd
                        $inputcmdcmd = GUICtrlRead($inputcmd)
                        Run("cmd /c "&$inputcmdcmd,"",@SW_HIDE)
        EndSwitch
WEnd

;回车运行命令的函数
Func _entercmd()
        Local $enterinput
        $enterinput = GUICtrlRead($inputcmd)
        Run("cmd /c "&$enterinput,"",@SW_HIDE)
EndFunc
发表于 2010-9-19 08:26:36 | 显示全部楼层
回复 8# 无名蜘蛛

这样子就好了,五楼的代码已经包含了。
GUICtrlSetState($buttoncmd,$GUI_DEFBUTTON)
 楼主| 发表于 2010-9-19 08:27:10 | 显示全部楼层
不过还有一大缺陷,不能运行CMD其他都可用运行
 楼主| 发表于 2010-9-19 08:30:29 | 显示全部楼层
难道还要做个判断输入的是CMD或者CMD.EXE是就直接运行,不是就跳过?
发表于 2010-9-19 08:35:07 | 显示全部楼层
回复 11# 无名蜘蛛


本帖子中包含更多资源

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

×
发表于 2010-9-19 08:36:21 | 显示全部楼层
回复 10# 无名蜘蛛

CMD使用"ShellExecute"就可以打开
我以前也写过运行,请你参考(你写的比我好,可可)
http://www.autoitx.com/forum.php ... 7677&highlight=

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-9-19 08:57:31 | 显示全部楼层
就是这个问题,龙哥,谢了{:face (197):}
发表于 2010-9-19 08:57:41 | 显示全部楼层
学到了1```
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 12:27 , Processed in 0.088827 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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