|
本帖最后由 neity 于 2009-5-25 19:10 编辑
代码如下:
#include <GuiConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
Dim $out
$foo = Run(@ComSpec & " /c DiskPart.exe", "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
If @error Then
MsgBox(16, "Error", "diskpart.exe not run")
Exit
EndIf
StdinWrite($foo, "list disk")
StdinWrite($foo)
While 1
$out &= StdoutRead($foo)
If @error Then ExitLoop
WEnd
$var = StringRegExp($out, "\d*.GB", 3)
;_ArrayDisplay($var)
$hGui = GuiCreate("Test", 300, 200)
$diskLabel = GUICtrlCreateLabel("Selected size: 0", 70, 30, 120, 17)
$diskSlider = GUICtrlCreateSlider(30, 50, 220, 30)
GUICtrlSetLimit(-1, $var[0])
$selButton = GUICtrlCreateButton("Select", 20, 150, 50, 25)
GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL")
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $selButton
MsgBox(64, "Message", "Selected " & GUICtrlRead($diskSlider) & " GB")
EndSwitch
WEnd
Func WM_HVSCROLL($hWnd, $Msg, $wParam, $lParam)
Switch $LParam
Case GUICtrlGetHandle($diskSlider)
GUICtrlSetData($diskLabel, "Selected size: " & GUICtrlRead($diskSlider) & " GB")
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
执行以后,stdinwrite()不工作。请高手解答,谢谢! |
|