AutoHotkey Community

It is currently May 27th, 2012, 11:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: October 14th, 2010, 8:25 am 
Offline

Joined: December 3rd, 2008, 5:37 am
Posts: 158
Location: chennai,india
hi. Suppose, if i am in C drive in command prombt, the texts in command prombt will be like this,

Quote:
c:\>


I just want to caputure this last line "c:\>"
For example, if i type,
"cd MyFolder"(assume that MyFolder is a directory in c drive), then, the command prombt will have texts like this


Quote:
c:>cd MyFolder
c:\MyFolder>

Now i want to get this line(last line in command prombt c:\MyFolder>).
In simple, when i run a program, it should give me the last line in the command prombt.
Can anyone help me in how to write a program for this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2010, 11:21 am 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2250
Location: switzerland
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
;--------------------------------------------------------


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group