Jump to content
HamidZaeri

How to get output of Run

Recommended Posts

HamidZaeri

Hi

When I run this adb command via CMD:

adb shell "dumpsys window windows | grep -E 'mFocusedApp'| cut -d / -f 1 | cut -d ' ' -f 7"

I get the output (The Package name of running app on android device)

 

But when I use it in autoit as below:

Local $appfor = RunWait($adbpath & " shell "&'"'&"dumpsys window windows | grep -E "&"'"&"mFocusedApp"&"'"&"| cut -d / -f 1 | cut -d "&"'"&" "&"'"&" -f 7"&'"',@TempDir,@SW_HIDE)
ClipPut($appfor)

I get "0" in the clipboard!

What's wrong with my code?

 

Share this post


Link to post
Share on other sites
Danyfirex

Hello. RunWait Return the procress Exit Code. check StdoutRead and StderrRead in help file.

 

Saludos

  • Like 1

Share this post


Link to post
Share on other sites
HamidZaeri
1 hour ago, Danyfirex said:

Hello. RunWait Return the procress Exit Code. check StdoutRead and StderrRead in help file.

 

Saludos

I did this?!

#include <AutoItConstants.au3>
$appfor = RunWait($adbpath & " shell "&'"'&"dumpsys window windows | grep -E "&"'"&"mFocusedApp"&"'"&"| cut -d / -f 1 | cut -d "&"'"&" "&"'"&" -f 7"&'"',@TempDir,@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)
$Mes = StdoutRead($appfor)
ClipPut($Mes)

But nothing in the clipboard!

Would you please fix my code?

 

Edit:

I think I managed it! (changed RunWait to Run)

$appfor = Run($adbpath & " -s " & $winfo[1] & " shell "&'"'&"dumpsys window windows | grep -E "&"'"&"mFocusedApp"&"'"&"| cut -d / -f 1 | cut -d "&"'"&" "&"'"&" -f 7"&'"',@TempDir,@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)
$sOutput = ''
While 1
   $sOutput &= StdoutRead($appfor)
     If @error Then
         ExitLoop
     EndIf
WEnd
ClipPut(StringTrimRight($sOutput,3))

 

Edited by HamidZaeri

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×