linac 发表于 2011-9-1 00:27:08

怎样将执行结果返回到edit中呢

点击一个button执行net user命令,怎样将执行后的结果显示在edit中呢?

sunafter 发表于 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

linac 发表于 2011-9-1 16:38:26

感谢您的帮助。

arkhe 发表于 2011-9-1 23:35:27

也可以这样:
net user >reslut.log
fileread→result.log
GUICtrlSetData

netegg 发表于 2011-9-2 09:15:16

回复 4# arkhe

这样虽说也可以,但是要创建文件(不管是不是临时的),没有直接返回数据更合适

arkhe 发表于 2011-9-3 00:51:42

回复arkhe

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

呵呵,工作的原因,习惯了.....只是提供另外一种方法。
而且对于要多次filter数据的操作,文本反而好些。

netegg 发表于 2011-9-3 01:15:15

回复 6# arkhe
也是,看后续到底是想怎么操作了,不一定哪个更好,合适就行
页: [1]
查看完整版本: 怎样将执行结果返回到edit中呢