找回密码
 加入
搜索
查看: 2371|回复: 6

[AU3基础] 怎样将执行结果返回到edit中呢

  [复制链接]
发表于 2011-9-1 00:27:08 | 显示全部楼层 |阅读模式
点击一个button执行net user命令,怎样将执行后的结果显示在edit中呢?
发表于 2011-9-1 01:00:03 | 显示全部楼层
还有点小问题,仅供参考,有时候会出现乱码
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("test", 251, 175, -1, -1)
$ButtonOk = GUICtrlCreateButton("确定", 78, 144, 75, 25, $BS_NOTIFY)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 233, 129)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $ButtonOk
                        Rundos()
        EndSwitch
WEnd
Func Rundos()
Local $foo = Run(@ComSpec & " /c net user", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
Local $lines=""
While 1
    $line = StdoutRead($foo)
        $lines=$line&$lines
    If @error Then ExitLoop
        If $line<>"" Then GUICtrlSetData($Edit1, $lines)
Wend
EndFunc
 楼主| 发表于 2011-9-1 16:38:26 | 显示全部楼层
感谢您的帮助。
发表于 2011-9-1 23:35:27 | 显示全部楼层
也可以这样:
net user >reslut.log
fileread→result.log
GUICtrlSetData
发表于 2011-9-2 09:15:16 | 显示全部楼层
回复 4# arkhe

这样虽说也可以,但是要创建文件(不管是不是临时的),没有直接返回数据更合适
发表于 2011-9-3 00:51:42 | 显示全部楼层
回复  arkhe

这样虽说也可以,但是要创建文件(不管是不是临时的),没有直接返回数据更合适
netegg 发表于 2011-9-2 09:15


呵呵,工作的原因,习惯了.....只是提供另外一种方法。
而且对于要多次filter数据的操作,文本反而好些。
发表于 2011-9-3 01:15:15 | 显示全部楼层
回复 6# arkhe
也是,看后续到底是想怎么操作了,不一定哪个更好,合适就行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 01:30 , Processed in 0.153650 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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