Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

I do not under stand how to use run


  • Please log in to reply
4 replies to this topic
luvan
  • Members
  • 25 posts
  • Last active: Feb 11 2011 09:22 PM
  • Joined: 17 Mar 2007
If I run a commando like
run, xxx.exe /?

Then I get the helptext in MsgBox.
but I want it in a variable
How do I solve this problem?

Carcophan
  • Members
  • 1578 posts
  • Last active: Nov 27 2013 06:46 PM
  • Joined: 24 Dec 2008
:?:


Do you want the name of the program you are trying to run, to be a variable?


What does this mean? "Then I get the helptext in MsgBox. "

HotKeyIt
  • Moderators
  • 7099 posts
  • Last active: Today, 01:43 PM
  • Joined: 18 Jun 2008
Try this:
run, xxx.exe /? >> "%A_ScriptDir%\exehelp.txt"

FileRead,[color=orange]help[/color],%A_ScriptDir%\exehelp.txt

ToolTip % help

Sleep, 1000

ExitApp


SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
Sometimes when you run xyz.exe /? you get the help for that program, if you want that help in a variable, you can redirect the output to a file and read that.
Run, xyz.exe /? > help.txt
FileRead, help, help.txt
MsgBox % Help

Edit: hotkeyit beat me to it :D

garry
  • Members
  • 2987 posts
  • Last active: Oct 28 2014 07:00 PM
  • Joined: 19 Apr 2005
this a little complicated, if write to text not possible
write DOS window to a file and listbox
example DOS command, start script , input dos-command, enter
xcopy /?
( usually works the command like
xcopy /? >test.txt )

;-------- send to DOS and COPY DOS window --------------------------
;-------- from Laszlo ----------------------------------------------

english=y       ;-- sendinput to hidden DOS window english
german=n

DosCommand=xcopy /?     ;dos command
SearchedText=list       ;searched word

DetectHiddenWindows On
Gui,2:Font,,FixedSys


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 =
;------------------------ ENGLISH  or  GERMAN -----------------
if english=y
  SendInput !{Space}es{Enter}          ; select/copy DOS english
else
  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=%SR%`n%LR%
  }
msgbox,Searched Text [%searchedtext%]=`n%SR%
return


2Guiclose:
process,close,%PID1%               ;close hidden DOS
exitapp
;--------------------------------------------------------