garry
Joined: 19 Apr 2005 Posts: 1498 Location: switzerland
|
Posted: Thu Nov 26, 2009 10:01 pm Post subject: |
|
|
maybe don't understand what really wanted
an example sends to hidden DOS window , reads and show searched line
| Code: | ;-------- send to DOS and COPY DOS window --------------------------
;-------- from Laszlo ----------------------------------------------
DetectHiddenWindows On
Gui,2:Font,,FixedSys
DosCommand=ver
SearchedText=Microsoft
F1=%A_scriptdir%\test55.txt
ifexist,%F1%
Filedelete,%F1%
Run %ComSpec% /k ,,hide,PID1 ;open a DOS window hidden
Gui,2:Add,Text, x15 y40 ,DOS command:
Gui,2:Add,Edit, x140 y40 h20 w300 vVAR ,%DosCommand%
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
Fileappend,%C2%,%F1% ;can write to a file
;msgbox,262144,Push Escape to finish,%C2%
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%
;---- show a searched line ---
loop,read,%F1%
{
LR=%A_loopreadline%
ifinstring,LR,%SearchedText%
SR=%LR%
}
msgbox,Searched Text [%searchedtext%]=`n%SR%
return
2Guiclose:
process,close,%PID1% ;close hidden DOS
exitapp
;--------------------------------------------------------
|
|
|