SeharH Posted August 10, 2017 Share Posted August 10, 2017 (edited) Hello every one Iam really new'be to autoit and to any script writing so advanclly sorry if iam not following the right way to ask the things. Come to the point.--- Currently i do write a script in autoit for android devices i do run commands from adb shell cmd.now my question is how to show the out put result into my gui.like below i run a command and i want to show its out put into my gui. I do really respect of my all of seniors kindly help me out Thanks Edited August 10, 2017 by SeharH Link to comment Share on other sites More sharing options...
water Posted August 10, 2017 Share Posted August 10, 2017 Welcome to AutoIt and the forum! If you use Run in your AutoIt script to execute the command you could set parameter opt_flag to $STDOUT_CHILD to grab the output of your command. Function SdtoutRead then allows to read this output and process in your script. Please check the help file for functions Run and StdoutRead for further details and examples. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 Well Very much thanks you Iam totally new here so let me make a demo fram so you can please guide me for what to do and where to do Thanks Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 (edited) here is simple frame with single button and edit box where i want to show the out put Code Quote #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 577, 329, 330, 318) $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetData(-1, "Logs") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists(@TempDir & "\adb.exe") Then FileInstall("adb.exe", @TempDir & "\adb.exe", 1) EndIf If Not FileExists(@TempDir & "\AdbWinApi.dll") Then FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", 1) EndIf If Not FileExists(@TempDir & "\AdbWinUsbApi.dll") Then FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", 1) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case @Buildprop Buildprop() EndSwitch WEnd Func Buildprop() Run("adb shell getprop ro.build.id","".@SW_HIDE) Edited August 10, 2017 by SeharH Link to comment Share on other sites More sharing options...
water Posted August 10, 2017 Share Posted August 10, 2017 Use this (or something similar) to grab all output of your command: Global $iPID = Run("adb shell getprop ro.build.id","".@SW_HIDE), $STDOUT_CHILD) Global $sOutput = "" While 1 $sOutput = StdoutRead($iPID) If @error Then ExitLoop ; Exit the loop if the process closes or StdoutRead returns an error. MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) WEnd My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 4 minutes ago, water said: Global $iPID = Run("adb shell getprop ro.build.id","".@SW_HIDE), $STDOUT_CHILD) Global $sOutput = "" While 1 $sOutput = StdoutRead($iPID) If @error Then ExitLoop ; Exit the loop if the process closes or StdoutRead returns an error. MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) Over my head Sorry but really i have no idea where to add these codes and how to alighn them.Iam highly apriciated if you can edit for me simple frame Link to comment Share on other sites More sharing options...
water Posted August 10, 2017 Share Posted August 10, 2017 (edited) Imbed this lines in your script as function Buildprop: Local $iPID = Run("adb shell getprop ro.build.id","".@SW_HIDE), $STDOUT_CHILD) Local $sLogs = "" While 1 $sLogs = $sLogs & @CRLF & StdoutRead($iPID) If @error Then ExitLoop ; Exit the loop if the process closes or StdoutRead returns an error. WEnd Edited August 10, 2017 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 Sorry but can you please embed for me in my code so i can understand where to set these line My code Quote #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 577, 329, 330, 318) $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetData(-1, "Logs") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists(@TempDir & "\adb.exe") Then FileInstall("adb.exe", @TempDir & "\adb.exe", 1) EndIf If Not FileExists(@TempDir & "\AdbWinApi.dll") Then FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", 1) EndIf If Not FileExists(@TempDir & "\AdbWinUsbApi.dll") Then FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", 1) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case @Buildprop Buildprop() EndSwitch WEnd Func Buildprop() Run("adb shell getprop ro.build.id","".@SW_HIDE) Link to comment Share on other sites More sharing options...
water Posted August 10, 2017 Share Posted August 10, 2017 As I stated above: Insert my code in your function Buildprop. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 Where iam making mistake accept my appoligize sir for being not understand anything yet Link to comment Share on other sites More sharing options...
water Posted August 10, 2017 Share Posted August 10, 2017 Line 11: Remove the bracket after @SW_Hide. Line 33: Replace @ with $ Line 39: The dot before @SW_Hide, should be a comma My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TheDcoder Posted August 10, 2017 Share Posted August 10, 2017 Hello, you can find a good example of capturing the output of a commandline program in my Process UDF, Just download the repository and play with Example.au3 RestrictedUser and ponty 1 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 (edited) 10 minutes ago, water said: Line 11: Remove the bracket after @SW_Hide. Line 33: Replace @ with $ Line 39: The dot before @SW_Hide, should be a comma Followed and left it now with this one on below Thanks sir very much for bieng help me allot Edited August 10, 2017 by SeharH Link to comment Share on other sites More sharing options...
TheDcoder Posted August 10, 2017 Share Posted August 10, 2017 Replace the dot/fullstop with a comma on line 11 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 well much improved but while i press Build prop info button than there is no out put show in the gui i have removed the line because the gui has been dissappear Quote If @error Then ExitLoop ; Exit the loop if the process closes or StdoutRead returns an error. Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 so i want to show the out put on pointed area any where Link to comment Share on other sites More sharing options...
Simpel Posted August 10, 2017 Share Posted August 10, 2017 Put the scripted part by @water into your function Buildprop instead of inserting some of the lines everywhere inside your script: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> ; add because of declaration $STDOUT_CHILD #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 577, 329, 330, 318) $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) Global $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) ; make it Global, so that Func Buildprop() can use it GUICtrlSetData(-1, "Logs") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists(@TempDir & "\adb.exe") Then FileInstall("adb.exe", @TempDir & "\adb.exe", 1) EndIf If Not FileExists(@TempDir & "\AdbWinApi.dll") Then FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", 1) EndIf If Not FileExists(@TempDir & "\AdbWinUsbApi.dll") Then FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", 1) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Buildprop Buildprop() EndSwitch WEnd Func Buildprop() Local $iPID = Run("adb shell getprop ro.build.id","",@SW_HIDE, $STDOUT_CHILD) Local $sLogs = "" While 1 $sLogs = $sLogs & @CRLF & StdoutRead($iPID) If @error Then ExitLoop ; Exit the loop if the process closes or StdoutRead returns an error. WEnd GUICtrlSetData($Logs, $sLogs) ; Set the $sLog into your Edit EndFunc Regards, Conrad SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 3 minutes ago, Simpel said: Put the scripted part by @water into your function Buildprop instead of inserting some of the lines everywhere inside your script: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> ; add because of declaration $STDOUT_CHILD #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 577, 329, 330, 318) $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) Global $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) ; make it Global, so that Func Buildprop() can use it GUICtrlSetData(-1, "Logs") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists(@TempDir & "\adb.exe") Then FileInstall("adb.exe", @TempDir & "\adb.exe", 1) EndIf If Not FileExists(@TempDir & "\AdbWinApi.dll") Then FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", 1) EndIf If Not FileExists(@TempDir & "\AdbWinUsbApi.dll") Then FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", 1) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Buildprop Buildprop() EndSwitch WEnd Func Buildprop() Local $iPID = Run("adb shell getprop ro.build.id","",@SW_HIDE, $STDOUT_CHILD) Local $sLogs = "" While 1 $sLogs = $sLogs & @CRLF & StdoutRead($iPID) If @error Then ExitLoop ; Exit the loop if the process closes or StdoutRead returns an error. WEnd GUICtrlSetData($Logs, $sLogs) ; Set the $sLog into your Edit EndFunc Regards, Conrad Finally.Thanks you all my seniors so much Soon i will share my script Link to comment Share on other sites More sharing options...
kosamja Posted August 10, 2017 Share Posted August 10, 2017 (edited) #NoTrayIcon #RequireAdmin #include <Constants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("Form1", 577, 329, 330, 318) Global $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) Global $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetOnEvent($Buildprop, '_Buildprop') GUISetOnEvent($GUI_EVENT_CLOSE, '_AllExit', $Form1) GUICtrlSetData($Logs, "Logs" & @CRLF) GUISetState(@SW_SHOW, $Form1) If not FileExists(@TempDir & "\adb.exe") Then FileInstall("adb.exe", @TempDir & "\adb.exe", $FC_OVERWRITE) If not FileExists(@TempDir & "\AdbWinApi.dll") Then FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", $FC_OVERWRITE) If not FileExists(@TempDir & "\AdbWinUsbApi.dll") Then FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", $FC_OVERWRITE) While 1 Sleep(1000) WEnd Func _AllExit() GUIDelete(@GUI_WinHandle) Exit EndFunc Func _Buildprop() $iPID = Run("adb shell getprop ro.build.id", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput = StringStripWS(StdoutRead($iPID), $STR_STRIPLEADING + $STR_STRIPTRAILING) GUICtrlSetData($Logs, GUICtrlRead($Logs) & 'Display id | ' & $sOutput & @CRLF) EndFunc Edited August 10, 2017 by kosamja Link to comment Share on other sites More sharing options...
SeharH Posted August 10, 2017 Author Share Posted August 10, 2017 (edited) 10 minutes ago, kosamja said: expandcollapse popup#NoTrayIcon #RequireAdmin #include <Constants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("Form1", 577, 329, 330, 318) Global $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) Global $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetOnEvent($Buildprop, '_Buildprop') GUISetOnEvent($GUI_EVENT_CLOSE, '_AllExit') GUICtrlSetData($Logs, "Logs") GUISetState(@SW_SHOW, $Form1) Select Case not FileExists(@TempDir & "\adb.exe") FileInstall("adb.exe", @TempDir & "\adb.exe", $FC_OVERWRITE) Case not FileExists(@TempDir & "\AdbWinApi.dll") FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", $FC_OVERWRITE) Case not FileExists(@TempDir & "\AdbWinUsbApi.dll") FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", $FC_OVERWRITE) EndSelect While 1 Sleep(1000) WEnd Func _AllExit() GUIDelete(@GUI_WinHandle) Exit EndFunc Func _Buildprop() $iPID = Run("adb shell getprop ro.build.id", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) EndFunc Also good idea but i dont want to open out put in dialogbox i want to show the out put in bellow area also now my question is how to set the output value name so when i ever i get result of "adb shell getprop ro.build.id" than i get out put as below Display id | LMY47V Also output txt has been copied into logs box very down whats that issue? Example Edited August 10, 2017 by SeharH Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now