Popular Post Moriba Posted April 26, 2014 Popular Post Share Posted April 26, 2014 (edited) Hello, I created this UDF last year for my Orient Myanmar Language System. This UDF can control any Android devices. So used it wisely. ; #CURRENT# ===================================================================================================================== ; _Android_Call ; _Android_CommandExists ; _Android_Connect ; _Android_Dial ; _Android_FileExists ; _Android_Flash ; _Android_ForceStopPackage ; _Android_GetBatteryHealth ; _Android_GetBatteryLevel ; _Android_GetBatteryPlugType ; _Android_GetBatteryStatus ; _Android_GetBatteryTechnology ; _Android_GetBatteryTemperature ; _Android_GetBatteryVoltage ; _Android_GetDeviceID ; _Android_GetExternalStorageDirectory ; _Android_GetLegacyExternalStorageDirectory ; _Android_GetNetworkClass ; _Android_GetNetworkCountryISO ; _Android_GetNetworkOperator ; _Android_GetNetworkOperatorName ; _Android_GetNetworkType ; _Android_GetNetworkTypeName ; _Android_GetPackageInfo ; _Android_GetPhoneType ; _Android_GetProperty ; _Android_GetSerialNumber ; _Android_GetSIMCountryISO ; _Android_GetSIMOperator ; _Android_GetSIMOperatorName ; _Android_GetSIMState ; _Android_GetState ; _Android_HasBusyBox ; _Android_HasRootAccess ; _Android_Install ; _Android_IsAirplaneModeOn ; _Android_IsBatteryCharged ; _Android_IsBatteryLow ; _Android_IsBatteryPresent ; _Android_IsBootloader ; _Android_IsNetworkRoaming ; _Android_IsOffline ; _Android_IsOnline ; _Android_IsScreenOn ; _Android_Pull ; _Android_Push ; _Android_Reboot ; _Android_Remount ; _Android_Send ; _Android_SendSMS ; _Android_Shell ; _Android_StartActivity ; _Android_TakeSnapshot ; _Android_Uninstall ; _Android_WaitForDevice ; _Android_Wake ; _Android_WipeDataCache ; =============================================================================================================================== Download Android UDF (11.22.2014) Download ADB, Fastboot & AAPT Here I will accept whatever your suggestion. Can improve my UDF. I love AutoIt. It's so easy and powerful. Edited November 24, 2014 by Moriba Mobius, konan, DiscGolferPro and 3 others 6 Link to comment Share on other sites More sharing options...
nullschritt Posted April 26, 2014 Share Posted April 26, 2014 Maybe you could add a demo script? Moriba and Xandy 2 Link to comment Share on other sites More sharing options...
Zedna Posted April 29, 2014 Share Posted April 29, 2014 Also describe which tools should be installed to be your UDF working properly. Thanks. Moriba 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Fallinon Posted May 3, 2014 Share Posted May 3, 2014 VERY MUCH THX !!!!!!!!!!!!!! Really Nice work there implementation of create Nandroid Backups or Kernel Dump would be some nice Adds there i guess Link to comment Share on other sites More sharing options...
ToNoHaRa Posted May 31, 2014 Share Posted May 31, 2014 This is easy for beginner,like me to create Android Tools. Thank Link to comment Share on other sites More sharing options...
damian666 Posted June 20, 2014 Share Posted June 20, 2014 (edited) someone has got this working? some examples? i cant seem to get it going, just hangs for me this works to get it going though, but not the udf version of connect O.o GUICtrlSetData($Label1, "Connected: " & "Waiting for Device...") Runwait(@ComSpec & " /c " & "adb kill-server", @ScriptDir, @SW_SHOW) Runwait(@ComSpec & " /c " & "adb start-server", @ScriptDir, @SW_SHOW) Runwait(@ComSpec & " /c " & "adb get-state", @ScriptDir, @SW_SHOW) GUICtrlSetData($Label1, "Connected: " & _Android_IsOnline()) Edited June 20, 2014 by damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
lpxx Posted February 15, 2015 Share Posted February 15, 2015 为什么不给个例子呢? Link to comment Share on other sites More sharing options...
TheSaint Posted February 15, 2015 Share Posted February 15, 2015 Thanks for sharing! Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
JohnOne Posted February 15, 2015 Share Posted February 15, 2015 为什么不给个例子呢? Why do not you give examples? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nitekram Posted May 20, 2015 Share Posted May 20, 2015 Has anyone tried this out, or test to make sure the files are safe? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
argumentum Posted May 20, 2015 Share Posted May 20, 2015 the script, for what I just seen, is a shell for adb.exe ( http://developer.android.com/tools/help/adb.html )If you know what you're doing, then this is may be useful, otherwise, its useless.With the .exe's you save yourself from installing the SDK ( http://forum.xda-developers.com/showthread.php?t=723135 )So ACTIVATE USB DEBUGGING IN YOUR DEVICE and have fun.PS: don't come telling me that your phone broke. I won't be able to help you. Again, have fun. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
nitekram Posted May 20, 2015 Share Posted May 20, 2015 Have you done much programming for the Android? If so, do you have any tools that I might start off with, that will not brick my phone? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
junkew Posted May 25, 2015 Share Posted May 25, 2015 For "bypassing" ADB.EXE you just could start the server thru ADB (so far not found an easy way to only start the adb daemon on the device itsef)http://forum.xda-developers.com/showthread.php?t=803223and once started you can communicate with tcp/ip commands of AutoIT FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted May 25, 2015 Share Posted May 25, 2015 (edited) and an example to start the shell and just get an ls directory overview.expandcollapse popup#include <MsgBoxConstants.au3> ; Assign Local variables the loopback IP Address and the Port. Local $sIPAddress = "127.0.0.1" ;"localhost" ; "127.0.0.1" ; This IP Address only works for testing on your own computer. Local $iPort = 5037 ; Port used for the connection. Example() Func Example() TCPStartup() ; Start the TCP service. ; Register OnAutoItExit to be called when the script is closed. OnAutoItExitRegister("OnAutoItExit") ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified. Local $iSocket = TCPConnect($sIPAddress, $iPort) ; If an error occurred display the error code and return False. If @error Then ; The server is probably offline/port is not opened on the server. Local $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError) Return False Else Consolewrite("Connection successful" & @CRLF) EndIf ;Connect over usb TCPSend($iSocket, adbData("host:transport-usb")) $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ;Connect to the shell TCPSend($iSocket, adbData("shell:")) $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ;See the shell line $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ;Give the LS Command (do not forget CR) TCPSend($iSocket, "ls" & @CR) sleep(2000) $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ; Close the socket. TCPCloseSocket($iSocket) EndFunc ;==>Example Func OnAutoItExit() TCPShutdown() ; Close the TCP service. EndFunc ;==>OnAutoItExit ;Put hexLengthIn front of the data Func adbData($s) return hex(stringlen($s),4) & $s EndFunc Edited May 25, 2015 by junkew argumentum and Moriba 2 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted May 25, 2015 Share Posted May 25, 2015 Fun to play with needs more studyto have this work first run command: adb start-serverthat will start the daemon on the device and the background server program (adb is just besides a client also a hub to start the daemon and the server)extended example with snapshot of the android device without adb.exeaccording to services.txt it should be possible to read framebuffer of device directlyexpandcollapse popup#include <MsgBoxConstants.au3> #include <string.au3> ;Example to communicate with Android device with the ADB server started but bypassing ADB client.exe ;See links like ; https://github.com/android/platform_system_core/tree/master/adb ; http://www.w3.org/TR/PNG-Structure.html ; https://mogutan.wordpress.com/2014/06/25/ways-to-take-android-screenshot-from-command-line/ ; Assign Local variables the loopback IP Address and the Port. Local $sIPAddress = "127.0.0.1" ;"localhost" ; "127.0.0.1" ; This IP Address only works for testing on your own computer. Local $iPort = 5037 ; Port used for the connection. Example() Func Example() TCPStartup() ; Start the TCP service. ; Register OnAutoItExit to be called when the script is closed. OnAutoItExitRegister("OnAutoItExit") ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified. Local $iSocket = TCPConnect($sIPAddress, $iPort) ; If an error occurred display the error code and return False. If @error Then ; The server is probably offline/port is not opened on the server. Local $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError) Return False Else Consolewrite("Connection successful" & @CRLF) EndIf ;Connect over usb TCPSend($iSocket, adbData("host:transport-usb")) $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ;Connect to the shell TCPSend($iSocket, adbData("shell:")) $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ;See the shell line $data=TCPRecv($iSocket,4096,0) consolewrite($data & @CRLF) ;~ ExampleLS($iSocket) ExamplePNG($iSocket) ; Close the socket. TCPCloseSocket($iSocket) EndFunc ;==>Example func TCPReadAway($iSocket, $s) $data=TCPRecv($iSocket,1) while stringinstr($s,$data)=0 $data=TCPRecv($iSocket,1) wend EndFunc Func OnAutoItExit() TCPShutdown() ; Close the TCP service. EndFunc ;==>OnAutoItExit ;Put hexLengthIn front of the data Func adbData($s) return hex(stringlen($s),4) & $s EndFunc func ExamplePNG($iSocket) ;Take a screenshot as png TCPSend($iSocket, "screencap -p" & @CR) sleep(2000) ;~ $data=TCPRecv($iSocket,1024*1024,0) ;Just receive a lot of binary data at once to get the whole picture in directly and not in parts , assume 16 megabytes max ;First block contains a start string to much $tData=TCPRecv($iSocket,1024*1024*16,1) ;89 50 4E is the PNG starting point $startAt=stringinstr($tdata,"89504E") $data=_hextostring(stringmid($tdata,$startAt)) while $tData<>"" $tData=_hextostring(TCPRecv($iSocket,1024*1024*16,1)) $data=$data & $tData WEnd $dataLen=consolewrite("Data length: " & (stringlen($data)/1024) & @CRLF) ;~ $data=stringreplace($data,"\x0D\x0A","\x0A") $data=stringtobinary(stringreplace($data, @CRLF, @LF)) ;Carbage at the end, no need to remove ;49 45 4E 44 AE 42 60 82 is the PNG ending point filedelete("screenshot.png") filewrite("screenshot.png",$data) endfunc func ExampleLS($iSocket) ;Give the LS Command (do not forget CR) TCPSend($iSocket, "ls" & @CR) sleep(2000) ;Read the data quick and dirty max 1 megabyte $data=TCPRecv($iSocket,1024*1024,0) consolewrite($data & @CRLF) EndFunc ;~ https://mogutan.wordpress.com/2014/06/25/ways-to-take-android-screenshot-from-command-line/ ;~ framebuffer: ;~ This service is used to send snapshots of the framebuffer to a client. ;~ It requires sufficient privileges but works as follow: ;~ After the OKAY, the service sends 16-byte binary structure ;~ containing the following fields (little-endian format): ;~ depth: uint32_t: framebuffer depth ;~ size: uint32_t: framebuffer size in bytes ;~ width: uint32_t: framebuffer width in pixels ;~ height: uint32_t: framebuffer height in pixels ;~ With the current implementation, depth is always 16, and ;~ size is always width*height*2 ;~ Then, each time the client wants a snapshot, it should send ;~ one byte through the channel, which will trigger the service ;~ to send it 'size' bytes of framebuffer data. ;~ If the adbd daemon doesn't have sufficient privileges to open ;~ the framebuffer device, the connection is simply closed immediately. func readFB($iSocket) EndFunc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted May 29, 2015 Share Posted May 29, 2015 It looks all possible to directly talk to android phone with ADB daemon/server running (lot of work to extend in udf), easy testable on cmldine with ADB <command> and in previous example shown in code that you can start ADB.EXE / Server/Shell in an interactive way (removing overhead of starting adb over and over again)XML snapshot to identify elements can be done withStore an xml dump on the phoneadb shell uiautomator.dumpGet it to your local directoryadb shell pull /storage/sdcard0/window_dump.xml test.xml Interpret the xmlTODO ;-)Sending eventsSending events (key, mouse, tap etc.) to your android phone is based on the linux event model and can be done with adb shell sendeventhttp://ktnr74.blogspot.nl/2013/06/emulating-touchscreen-interaction-with.html background readinghttps://source.android.com/devices/input/overview.htmlhttps://www.kernel.org/doc/Documentation/input/event-codes.txthttps://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt argumentum 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
RaiNote Posted May 30, 2015 Share Posted May 30, 2015 (edited) Question.. how to start an .exe with an Android Device?!?!?! This could probably only work with Windows Phone.. but however nice made but can't be really used because Autoit don't support .apk/Android Application creating or got I something wrong >.<.. Edited May 30, 2015 by RaiNote C++/AutoIt/OpenGL Easy Coder I will be Kind to you and try to help you till what you want isn't against the Forum Rules~ Link to comment Share on other sites More sharing options...
junkew Posted May 31, 2015 Share Posted May 31, 2015 The ADB.EXE starts on your windows machine but triggers the remote daemon on your android phone (if android debugging is enabled) Ok first of all to do anything with android from windows you need adb.exe on your local windows machine which can be installed in about 15 seconds.http://forum.xda-developers.com/showthread.php?t=2588979after you adb working you can do a lot of nice things from any programming language (including AutoIT)As a starter you can read thishttp://wiki.cyanogenmod.org/w/Doc:_adb_introAnd after that you can read a lot on how to do some stuff from AutoIT where OP did make a nice start of wrapping up functions around adb.exe.ADB consists of https://android.googlesource.com/platform/system/core/+/master/adb/SERVICES.TXTThis can be made a little more efficient by not making adb call each time but just start communicating directlyAs AutoIT is about sending keys, recognizing controls I started with these1. Make screenshot: ADB screencap makes a RAW screenshot, -p makes it PNG (making a lot of screenshots probably faster in RAW format)2. Get the element hierarchy: ADB shell uiautomator dump <file>http://www.bdtool.net/third/android-doc/web-docs/tools/help/uiautomator/index.html3. Get files from your phone to the pc with ADB pull4. Put files to your phone with ADB push5. sendevent / keys or getevent / recordhttp://ktnr74.blogspot.nl/2013/06/emulating-touchscreen-interaction-with.html And with all above combined you can remotely control your android phone Technically I see no reason why you cannot maken an APK with help of AutoIT but probably a lot of work and nobody started such a project http://en.wikipedia.org/wiki/Android_application_package oHenry and argumentum 2 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
oHenry Posted June 30, 2015 Share Posted June 30, 2015 (edited) @junkew You are right, is a good idea an ADB client implemented in pure AutoIT.There are some examples in other languages:https://github.com/vidstige/jadb (Java)https://github.com/CyberAgent/adbkit (JavaScript)https://github.com/google/python-adb (Python)I did something similar in the past but for the Android Monkey Tool.Another approach in order to make AutoIt a "scripting language for mobile automation", is develop an Appium driver on Autoit that implements the Mobile JSON Wire Protocol or try develop an ImperiusGeorge AutoIt driver like this Ruby gem or also a wrapper of Android uiautomator-server testing framework like this Python module.Best regards.Henry Edited July 2, 2015 by oHenry Moriba 1 Regards. Henry Link to comment Share on other sites More sharing options...
Moriba Posted September 4, 2015 Author Share Posted September 4, 2015 (edited) Hey check this new PureAutoItADB UDF. This project is still in beta. Kindly suggest me to improve. Very thanks <snip> Edited December 20, 2016 by Melba23 Link removed - not AutoIt related MathInDOS 1 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