this example copies DOS window and write it to GUI, see all and lastline
-start script ( cd\ is predefined)
-ENTER ( see text from DOS command)
-write cd myfolder,
- ENTER (see text from DOS command)
(see sendinput command , this copies DOS window depending language)
Code:
;-------- send to DOS and COPY DOS window --------------------------
;-------- from Laszlo ----------------------------------------------
;--- tagsx=lastlinexx dosxx
DetectHiddenWindows On
Gui,2:Font,,FixedSys
F1=%A_scriptdir%\test55.txt
ifexist,%F1%
Filedelete,%F1%
Run %ComSpec% /k ,,hide,PID1 ;open a DOS window
VAR =cd\ ;------- DOS command preselect
Gui,2:Add,Text, x15 y40 ,DOS command:
Gui,2:Add,Edit, x140 y40 h20 w300 vVAR ,%VAR%
Gui,2:Add, Button, x0 y0 w0 h0 default gSTART1,
Gui,2:Add,Text, x15 y80 ,DOS WINDOW COPIED:
Gui,2:Add,Listbox, x10 y100 h390 w680 vLB3,
Gui,2:Show, x0 y0 h500 w700 ,SendToDOS
GuiControl,2:Focus,VAR
return
;-------------------------------------------------------
START1:
gui,2:submit,nohide
GuiControl,2:,LB3,| ;clear listbox
ControlSend, ,CLS,ahk_pid %PID1%, , , ;send clear screen
ControlSend, ,{enter},ahk_pid %PID1%, , , ;send enter
ControlSend, ,%VAR%,ahk_pid %PID1%, , , ;send input value
ControlSend, ,{enter},ahk_pid %PID1%, , , ;send enter
sleep,1000
WinActivate ahk_pid %PID1%
sleep,1000
ClipBoard =
SendInput !{Space}es{Enter} ;<<<<<<<<< select/copy DOS english
;SendInput !{Space}ba{Enter} ;<<<<<<<<< select/copy DOS german
ClipWait 2
C2:=clipboard
StringGetPos p, C2,`n, R1
P1:=(P+2) ;LAST line
StringMid,t,C2,P1,150
stringreplace,C2,C2,`r`n,|,all
GuiControl,2:,LB3,%C2%
GuiControl,2:,LB3,---------------------------------------------------
GuiControl,2:,LB3,Lastline=%t%
return
2Guiclose:
process,close,%PID1% ;close DOS
exitapp
;--------------------------------------------------------