找回密码
 加入
搜索
查看: 16580|回复: 32

au3回显DOS命令

 火.. [复制链接]
发表于 2008-8-6 16:11:15 | 显示全部楼层 |阅读模式
au3怎么回显DOS命令信息?
PCBAR已经把源码放出来。谢谢。

[ 本帖最后由 redapple2008 于 2008-8-10 12:57 编辑 ]
发表于 2008-8-6 18:42:58 | 显示全部楼层
 楼主| 发表于 2008-8-6 23:59:49 | 显示全部楼层
如楼上的例子还是解决不了问题
帮忙改一下了,我要让DOS回显的内容写在列表框中。谢谢
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Opt('MustDeclareVars', 1)
Local $add, $clear, $mylist, $Button1, $nmsg
#Region ### START Koda GUI section ### Form=
GUICreate("AForm1", 633, 451, 193, 125)
        $mylist = GUICtrlCreateList("", 5, 32, 721, 97)
        GUICtrlSetLimit(-1, 200) 
        GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Button1", 8, 408, 617, 33, 0)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
          _test()
    EndSwitch
WEnd


Func _test()
Local $foo,$line,$lines,$currentRead
$foo = Run(@ComSpec & " /c v.bat", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
$lines =""
While 1
        if $foo then
    $line = StdoutRead($foo,0,1)
   If @error Then ExitLoop
        If $line Then
            $currentRead = StdoutRead($foo)
            GUICtrlSetData($mylist, $currentRead, 1)
                        MsgBox(0,"test",$currentRead)
        EndIf
        EndIf
        Wend
EndFunc


[ 本帖最后由 redapple2008 于 2008-8-7 00:12 编辑 ]

本帖子中包含更多资源

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

×
 楼主| 发表于 2008-8-7 18:00:59 | 显示全部楼层
有没有高手出来说话呀?
 楼主| 发表于 2008-8-7 19:22:25 | 显示全部楼层
搞了好久也搞不定。寻求帮助。
 楼主| 发表于 2008-8-8 00:00:20 | 显示全部楼层
做人还是自已动手的好
 楼主| 发表于 2008-8-8 11:19:02 | 显示全部楼层
还是搞不定,郁闷呀!
发表于 2008-8-8 17:30:20 | 显示全部楼层
这种我会:Run(@ComSpec, @SystemDir, @SW_HIDE
这种不会:Run(@ComSpec & " /c v.bat", @ScriptDir, @SW_HIDE
等高人解答
 楼主| 发表于 2008-8-8 18:07:14 | 显示全部楼层
原帖由 kakinkgb 于 2008-8-8 17:30 发表
这种我会:Run(@ComSpec, @SystemDir, @SW_HIDE
这种不会:Run(@ComSpec & " /c v.bat", @ScriptDir, @SW_HIDE
等高人解答

给一段代码看看,谢谢。
 楼主| 发表于 2008-8-8 18:42:12 | 显示全部楼层
$foo = Run(" c v.bat", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
改了也不行,晕。
发表于 2008-8-9 14:10:13 | 显示全部楼层
调用批处理文件应该用:
Local $foo = Run(@ScriptDir & "\V.BAT",  @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
 楼主| 发表于 2008-8-10 00:16:57 | 显示全部楼层
试过了不行的。具体不知道错在哪里了?
发表于 2008-8-10 10:34:49 | 显示全部楼层
是不是这样的


#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseAnsi=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <StaticConstants.au3>

Local $add, $clear, $mylist, $Button1, $nmsg
#Region ### START Koda GUI section ### Form=
GUICreate("AForm1", 633, 451, 193, 125)
$myedit = GUICtrlCreateEdit("", 5, 32, 620, 200)
$Button1 = GUICtrlCreateButton("Button1", 8, 408, 617, 33, 0)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
        $nmsg = GUIGetMsg()
        Switch $nmsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _test()
        EndSwitch
WEnd

Func _test()
        Local $foo, $line, $lines, $currentRead
        $foo =  Run("v.bat", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        While 1
                $line = StdoutRead($foo)
                If @error Then ExitLoop
        GUICtrlSetData($myedit, $line, -1)
;~                 MsgBox(0, "test", $line)
        WEnd
EndFunc   ;==>_test

V.bat
@echo off
echo 欢迎使用由冰剑修改制作的清除系统垃圾文件批处理小程序    

echo 清理垃圾文件,速度由电脑文件大小而定。在没看到结尾信息时 

echo 请勿关闭本窗口。 感谢灵感小菜提供源程序

echo.

echo 正在清除系统垃圾文件,请稍后......

echo 删除补丁备份目录
RD %windir%\$hf_mig$ /Q /S

echo 把补丁卸载文件夹的名字保存成2950800.txt
dir %windir%\$NtUninstall* /a:d /b >%windir%\2950800.txt

echo 从2950800.txt中读取文件夹列表并且删除文件夹
for /f %%i in (%windir%\2950800.txt) do rd %windir%\%%i /s /q

echo 删除2950800.txt
del %windir%\2950800.txt /f /q

echo 删除补丁安装记录内容(下面的del /f /s /q %systemdrive%\*.log已经包含删除此类文件)
del %windir%\KB*.log /f /q

echo 删除系统盘目录下临时文件
del /f /s /q %systemdrive%\*.tmp

echo 删除系统盘目录下临时文件
del /f /s /q %systemdrive%\*._mp

echo 删除系统盘目录下日志文件
del /f /s /q %systemdrive%\*.log

echo 删除系统盘目录下GID文件(属于临时文件,具体作用不详)
del /f /s /q %systemdrive%\*.gid

echo 删除系统目录下scandisk(磁盘扫描)留下的无用文件
del /f /s /q %systemdrive%\*.chk

echo 删除系统目录下old文件
del /f /s /q %systemdrive%\*.old

echo 删除回收站的无用文件
del /f /s /q %systemdrive%\recycled\*.*

echo 删除系统目录下备份文件
del /f /s /q %windir%\*.bak

echo 删除应用程序临时文件
del /f /s /q %windir%\prefetch\*.*

echo 删除系统维护等操作产生的临时文件
rd /s /q %windir%\temp & md %windir%\temp

echo 删除当前用户的COOKIE(IE)
del /f /q %userprofile%\cookies\*.*

echo 删除internet临时文件
del /f /s /q "%userprofile%\local settings\temporary internet files\*.*"

echo 删除当前用户日常操作临时文件
del /f /s /q "%userprofile%\local settings\temp\*.*"

echo 删除访问记录(开始菜单中的文档里面的东西)
del /f /s /q "%userprofile%\recent\*.*"

echo.


1
Run("v.bat", @SystemDir, @SW_HIDE)
Run(@ComSpec & " /c v.bat", @ScriptDir, @SW_HIDE)
是一样的,起码我测试结果是一样的
2
回显起码要用edit控件吧,楼主怎么会用list??
3
编译要用ansi,否则出乱码
4
批处理开头最好加个@echo off
换行不是echo 空白,而是echo.
题外话
5
看来楼主还有很多功课要做

本帖子中包含更多资源

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

×

评分

参与人数 3金钱 +13 贡献 +1 收起 理由
wjq0886 + 5 精品回答
lsq726 + 5 精品文章
redapple2008 + 3 + 1 精品文章

查看全部评分

 楼主| 发表于 2008-8-10 12:55:23 | 显示全部楼层
向PCBAR学习了。谢谢。研究了好久也没有搞定的问题。
看来我的确还有很多功课要做
发表于 2008-8-10 18:06:50 | 显示全部楼层

回复 14# pcbar 的帖子

是否也不能完全显示回显,出错不能显示,比如某某程序正在被调用,不能被执行等问题。修改一下:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Local $add, $clear, $mylist, $Button1, $nmsg
#Region ### START Koda GUI section ### Form=
GUICreate("AForm1", 500, 280)
$mylist = GUICtrlCreateEdit("", 20, 20, 460, 180)
$Button1 = GUICtrlCreateButton("测试回显", 230, 220, 70, 33, 0)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
        $nmsg = GUIGetMsg()
        Switch $nmsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _test()
        EndSwitch
WEnd


Func _test()
        Local $foo = Run(@ScriptDir & "\V.BAT", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
        Local $line
        While 1
                $line = StdoutRead($foo)
                If @error Then ExitLoop
                GUICtrlSetData($mylist, $line, -1)
        WEnd

        While 1
                $line = StderrRead($foo)
                If @error Then ExitLoop
                GUICtrlSetData($mylist, $line, -1)
        WEnd
EndFunc   ;==>_test

[ 本帖最后由 即即 于 2008-8-10 19:04 编辑 ]

评分

参与人数 1金钱 +10 收起 理由
顽固不化 + 10 这个补充很有价值

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 19:54 , Processed in 0.093903 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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