Use Python's wx Library to write a UI interface that will output the Android device to a computer screen, as long as the ADB is installed and the Python library involved is installed. The code is as follows:
ImportWx,subprocess,os,platformclassAutyframe (WX. Frame):def __init__(self): WX. Frame.__init__(Self, None,-1,'Android Auty', size= (350, 300)) Self.panel= WX. Panel (self,-1) #Android devices Combox.Combox_list =[] R= Execute_shell ("ADB devices") forIinchRange (1,len (r)-1): Combox_list.append (R[i].split ("\ t") [0]) wx. Statictext (Self.panel,-1,"Select Devices:", (15, 15)) Self.devices_combobox= Wx.combobox (Self.panel,-1, R[1].split ("\ t") [0], (15, 35), WX. DefaultSize, Combox_list, WX. Cb_dropdown)#Capture button.Self.capture_button = wx. Button (Self.panel,-1,"Capture", pos= (188, +), size= (66,25)) Self.reload_button= WX. Button (Self.panel,-1,"Reload", pos= (258, +), size= (66,25) Self . Bind (WX. Evt_button, Self.captureclick, Self.capture_button) self. Bind (WX. Evt_button, Self.reloadclick, Self.reload_button) Self.capture_button. SetDefault () Self.reload_button. SetDefault ()defCaptureclick (Self, event): Capture_android (Self.devices_combobox. GetValue ())if("Windows" inchPlatform.platform ()): Os.startfile ("D:\\screenshot.png") defReloadclick (Self, event): Self.devices_combobox. Clear () K= Execute_shell ("ADB devices") forIinchRange (1,len (k)-1): Self.devices_combobox. Append (K[i].split ("\ t") [0]) Self.devices_combobox. SetValue (k[1].split ("\ t") [0])defExecute_shell (Shell): P= subprocess. Popen (shell,shell=true,stdout=subprocess. PIPE) out=P.stdout.readlines ()return outdefcapture_android (device_id): Sh1="adb-s"+device_id+"shell/system/bin/screencap-p/sdcard/screenshot.png"SH2="adb-s"+device_id+"pull/sdcard/screenshot.png d:/screenshot.png"Execute_shell (SH1) Execute_shell (SH2)if __name__=='__main__': App=WX. Pysimpleapp () Autyframe (). Show () app. Mainloop ()
Run:
Advantages:
1. Running faster than uiautomatorviewer, quicker than monitor;
2. Can be selected for a plurality of devices, screen cutting;
3. After the screenshot (saved in the D packing directory "screenshot.png" file) will automatically open;
4. After plugging the device, you can reload reload the device list.
Python writes an Android device tool under Windows