Jump to content

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

stdout to variable - putting 2 arguments in comspec



  • Please log in to reply
4 replies to this topic
dwilbank
  • Members
  • 367 posts
  • Last active: Dec 05 2015 12:57 AM
  • Joined: 20 Feb 2009

Good sirs.

A nice fellow named Garry gave me this example of using two arguments in comspec

objShell := ComObjCreate("WScript.Shell")
objExec := objShell.Exec(ComSpec " /c exiftool " F1 s F3) ; works
strStdOut := ""
while, !objExec.StdOut.AtEndOfStream
strStdOut := objExec.StdOut.ReadAll()
MsgBox %strStdOut%
 

but the following doesn't work for me, and it has two arguments as well

objShell := ComObjCreate("WScript.Shell")
objExec := objShell.Exec(ComSpec " /c get_code " Var1 Var2)
strStdOut := ""
while, !objExec.StdOut.AtEndOfStream
strStdOut := objExec.StdOut.ReadAll()
MsgBox %strStdOut%
 

In DOS I would just type

 

\user> get_code C235641 48.123

 

 

See how the second argument has a decimal in it?

Could that be the problem?

I tried putting quotes around the "48.123" and escaping the period.

 

What else could be making this fail?

 

Thanks



rbrtryn
  • Members
  • 1177 posts
  • Last active: Sep 11 2013 08:04 PM
  • Joined: 22 Jun 2011
✓  Best Answer

You need a literal space between Var1 and Var2 in your Exec call:

objExec := objShell.Exec(ComSpec " /c get_code " Var1 " " Var2)

My Scripts are written for the latest released version of AutoHotkey.

Need a secure, accessible place to backup your stuff? Use Dropbox!


dwilbank
  • Members
  • 367 posts
  • Last active: Dec 05 2015 12:57 AM
  • Joined: 20 Feb 2009

thank you sir

 

can't wait to get back and try it!



garry
  • Spam Officer
  • 3219 posts
  • Last active: Feb 06 2016 09:32 PM
  • Joined: 19 Apr 2005

sorry , I was wrong, variable F3 not needed , result is in memory

;- example needs exiftool.exe ----------------
;--http://www.sno.phy.queensu.ca/~phil/exiftool/
;transform,S,chr,32                                           ;- space not used
F1="%A_scriptdir%\xxb.jpg"                                    ;- check picture
;F3="%A_scriptdir%\result_exiftool.txt"                       ;- file not used
objShell := ComObjCreate("WScript.Shell")
;objExec := objShell.Exec(ComSpec " /c exiftool " F1 s F3)    ;- F3 not needed 
objExec := objShell.Exec(ComSpec " /c exiftool " F1 )
strStdOut := ""
while, !objExec.StdOut.AtEndOfStream
    strStdOut := objExec.StdOut.ReadAll()
MsgBox %strStdOut%
exitapp



dwilbank
  • Members
  • 367 posts
  • Last active: Dec 05 2015 12:57 AM
  • Joined: 20 Feb 2009

either way, the example helped my script work

thx