modified=20140310
;f1:="ping www.autohotkey.com"
;f1:="ipconfig.exe /all"
e4x=
(join&
date /t
time /t
)
f1 .= comspec " /c " e4x
Gui,1: Color, ControlColor, Black
Gui,1: Font, CDefault, FixedSys
Gui , Margin, x5, y5
Gui , Show, w200 h50, Test
Gui , Add, Edit, cWhite x5 y10 w180 vDate,
gosub,get
GuiControl,1:Focus,Date
Return
Guiclose:
exitapp
get:
gui,1:submit,nohide
aa:=StdoutToVar_CreateProcess(F1)
stringreplace,aa,aa,`r`n,$,all
stringsplit,g,aa,$
GuiControl,1:,date,%g1%-- %g2%
return
;--------- http://ahkscript.org/boards/viewtopic.php?f=6&t=791 ---
;-- from user cyruz
;-- Last edited by cyruz on Sun Mar 09, 2014 12:51 pm, edited 6 times in total
StdoutToVar_CreateProcess(sCmd, sDir:="", ByRef nExitCode:=0) {
DllCall( "CreatePipe", PtrP,hStdOutRd, PtrP,hStdOutWr, Ptr,0, UInt,0 )
DllCall( "SetHandleInformation", Ptr,hStdOutWr, UInt,1, UInt,1 )
VarSetCapacity( pi, (A_PtrSize == 4) ? 16 : 24, 0 )
siSz := VarSetCapacity( si, (A_PtrSize == 4) ? 68 : 104, 0 )
NumPut( siSz, si, 0, "UInt" )
NumPut( 0x100, si, (A_PtrSize == 4) ? 44 : 60, "UInt" )
NumPut( hStdInRd, si, (A_PtrSize == 4) ? 56 : 80, "Ptr" )
NumPut( hStdOutWr, si, (A_PtrSize == 4) ? 60 : 88, "Ptr" )
NumPut( hStdOutWr, si, (A_PtrSize == 4) ? 64 : 96, "Ptr" )
If ( !DllCall( "CreateProcess", Ptr,0, Ptr,&sCmd, Ptr,0, Ptr,0, Int,True, UInt,0x08000000
, Ptr,0, Ptr,sDir?&sDir:0, Ptr,&si, Ptr,&pi ) )
Return ""
, DllCall( "CloseHandle", Ptr,hStdOutWr )
, DllCall( "CloseHandle", Ptr,hStdOutRd )
DllCall( "CloseHandle", Ptr,hStdOutWr ) ; The write pipe must be closed before reading the stdout.
VarSetCapacity(sTemp, 4095)
While ( DllCall( "ReadFile", Ptr,hStdOutRd, Ptr,&sTemp, UInt,4095, PtrP,nSize, Ptr,0 ) )
sOutput .= StrGet(&sTemp, nSize, A_FileEncoding)
DllCall( "GetExitCodeProcess", Ptr,NumGet(pi,0), Ptr,&nExitCode ), nExitCode := NumGet(nExitCode)
DllCall( "CloseHandle", Ptr,NumGet(pi,0) )
DllCall( "CloseHandle", Ptr,NumGet(pi,A_PtrSize) )
DllCall( "CloseHandle", Ptr,hStdOutRd )
Return sOutput
}
暂无讨论,说说你的看法吧