Jump to content

Recommended Posts

Posted

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?

 

Posted

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

 

Saludos

Posted (edited)
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...