找回密码
 加入
搜索
楼主: xavier880819

用TimerInit 和 TimerDiff统计是时间取整的问题。

[复制链接]
 楼主| 发表于 2009-8-28 13:53:44 | 显示全部楼层
对于回显问题,希望有大虾可以对我在12楼的问题给支个招
发表于 2009-8-28 14:54:36 | 显示全部楼层
高深,我是看不懂了
发表于 2009-8-28 14:54:43 | 显示全部楼层
太复杂了,
发表于 2009-8-28 17:59:46 | 显示全部楼层
这个在Dos里面应该是使用了sprintf() 函数,格式化让其同一行显示。
au3里面可以试试StringFormat或者StringRegExpReplace,不过估计很难搞。

不知道你要实现这个回显的目的?有时不一定非得走一条道...
 楼主| 发表于 2009-8-31 13:36:30 | 显示全部楼层
19# afan


倒没有什么特殊的目的,就是想让这个回显能像DOS里面那样会比较好看
 楼主| 发表于 2009-8-31 13:53:19 | 显示全部楼层
算了,这个倒不算是什么大问题,不好看也无所谓了。
再请问一下大家,在回显里面的东西,最后可以存到一个.log或者.txt的文件里面吗?谢谢了!
发表于 2009-8-31 14:06:23 | 显示全部楼层
本帖最后由 afan 于 2009-8-31 14:16 编辑

在回显的那一句 GUICtrlSetData($myedit, $line, -1) 下面加一行

FileWrite('1.txt', $line & @CRLF)
 楼主| 发表于 2009-8-31 14:34:10 | 显示全部楼层
22# afan

好的,谢谢afan,我去试试看
 楼主| 发表于 2009-8-31 14:41:50 | 显示全部楼层
确实可以记录,但是记录出来的txt文件是不连贯的,查看起来非常不方便,中间空了很多行。这个问题能不能得到解决呢??
发表于 2009-8-31 16:14:00 | 显示全部楼层
最后再用以下函数加个删除空行不就行了,呵呵
_FileReadToArray
_FileWriteToLine
 楼主| 发表于 2009-8-31 16:32:31 | 显示全部楼层
25# afan


原来还可以这样,我去试试看
 楼主| 发表于 2009-8-31 17:02:53 | 显示全部楼层
我去看了帮助,但是不是很明白。特别是_FileWriteToLine,还要定义需要写的第几行需要写入。这个貌似存在一点问题。

请问afan可以给出一点例子么?
发表于 2009-8-31 18:15:08 | 显示全部楼层
#include <File.au3>
Dim $aArray2, $b
_FileReadToArray('1.txt', $aArray2)
For $x = 1 To $aArray2[0]
        If $aArray2[$x] = "" Then
                _FileWriteToLine('1.txt', $x - $b, '', 1)
                $b += 1
        EndIf
Next
 楼主| 发表于 2009-9-1 09:13:40 | 显示全部楼层
28# afan


谢谢afan,我去试试看
 楼主| 发表于 2009-9-1 09:58:15 | 显示全部楼层
好像还是不行,我调试过放在不同的地方也不行
#Region ;
#AutoIt3Wrapper_UseAnsi=y
#EndRegion ;
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#include <File.au3>

GUICreate("Formater Ver 1.4", 633, 380, 193, 125)
Dim $xz, $a, $b, $zx, $Q, $F, $ff,$H, $M, $S,$aArray2, $z,$x
Local $add, $clear, $mylist, $Button1, $sf, $format
$myedit = GUICtrlCreateEdit("", 5, 32, 620, 200)
$Button1 = GUICtrlCreateButton("Start Format Disc", 380, 250, 245, 33, 0)
GUICtrlCreateGroup("  Choose Format Way  ", 230, 250, 140, 100)
$Q = GUICtrlCreateRadio("Quick Format", 250, 280, 100, 20)
$F = GUICtrlCreateRadio("Full Format", 250, 300, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUISetState()
$var = DriveGetDrive("REMOVABLE")
$xz = GUICtrlCreateCombo("Select The Disc", 20, 250, 200, 30)
For $i = 1 To $var[0]
GUICtrlSetData($xz, $var[$i])
Next

GUISetState(@SW_SHOW)

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
$F111 = MsgBox(1 + 48, 'Attention', 'Are you sure you want to format this disc?')
Select
Case $F111 = 1
If BitAND(GUICtrlRead($Q), $GUI_CHECKED) Then $format = '/Q/'
If BitAND(GUICtrlRead($F), $GUI_CHECKED) Then $format = '/'
 _test()

Case $F111 = 2
ContinueLoop
EndSelect

 EndSwitch
WEnd

Func _test()
Local $foo, $line, $lines, $currentRead
$a = TimerInit()
 $zx = GUICtrlRead($xz)
$foo = Run(@ComSpec & " /c " & 'Format ' & $zx & '/FS:FAT32/V:Haha' & $format & 'X/Y', "", @SW_HIDE, $STDOUT_CHILD)
While 1
$line = StdoutRead($foo)
 If @error Then ExitLoop
 GUICtrlSetData($myedit, $line, -1)
 FileWrite(@ScriptDir & "\1.txt", $line & @CRLF)
 _FileReadToArray(@ScriptDir & "\1.txt", $aArray2)
For $x = 1 To $aArray2[0]
If $aArray2[$x] = "" Then
 _FileWriteToLine(@ScriptDir & "\1.txt", $x - $z, '', 1)
$z += 1
EndIf
Next
  WEnd
$b = TimerDiff($a)
 $c = $b / 1000
_TicksToTime(Int($b), $H, $M, $S)
Msgbox(64,"Finish","This format cost you  " & $H & ' Hours ' & $M & ' Minutes ' & $S & ' Seconds')

EndFunc;==>_test
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-27 21:22 , Processed in 0.069770 second(s), 13 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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