One, push files to the phone
The use of Minicap is highly targeted, and different "minicap" and "minicap.so" files are produced for different architectures of CPUs and SDKs.
Get CPU Version
$ABI =adb shell getprop ro.product.cpu.abi
Get SDK version
$SDK =adb shell getprop ro.build.version.sdk
1, there is a way to succeed, can be successful operation: through the ADB shell into the corresponding directory of the phone/data/local/tmp directory, the implementation of $LD _library_path=/data/local/tmp/data/local/tmp/ minicap-p [email protected]/0-s >/mnt/sdcard/tmp.jpg command is OK, then pull to win computer.
2, if the DOS command prompt, directly execute adb shell ld_library_path=/data/local/tmp/data/local/tmp/minicap-p [email protected]/0-s > C: \ Tmp.jpg, the resulting picture is displayed as corrupted.
adb Shell "$LD _library_path=/data/local/tmp/data/local/tmp/minicap-p [email protected]/0-s" > C \ Tmp.jpg
Additionally this is a shell command that exports the results directly to the Windows side with the problem of file header parsing (because the phone is a bit different from the encoding format of Linux and Windows)
Import Osclass banner:def __init__ (self): self. Version = 0 # release information self. length = 0 # banner a self. Pid = 0 # process ID self. realwidth = 0 # The true width of the device self. realheight = 0 # The true height of the device self. virtualwidth = 0 # The virtual width of the device is self. Virtualheight = 0 #设备的虚拟高度 self. Orientation = 0 # device Direction self. Quirks = 0 # Device Info get policy def toString: message = "Banner [version=" + str (self). Version) + ", length=" + str (self. Length) + ", pid=" + str (self. Pid) + ", realwidth=" + str (self. Realwidth) + ", realheight=" + str (self. Realheight) + ", virtualwidth=" + str (self. Virtualwidth) + ", virtualheight=" + str (self. Virtualheight) + ", orientation=" + str (self. Orientation) + ", quirks=" + str (self. Quirks) + "]" return message#!/usr/bin/env python#-*-coding:utf-8-*-"' Created on December 29, 2016 @author:fengbo" ' F Rom Banner import bannerimport socketimport threadingfrom itsdangerous import bytes_to_intfrom Queue imporT queueprefu Link: https://www.jianshu.com/p/f8b8123cd062: Jane letters book Copyright belongs to the author, any form of reprint please contact the author to obtain authorization and indicate the source.
Class Minicapstream: __instance = None __mutex = Threading. Lock () def __init__ (self): self. ip = "127.0.0.1" # defines the IP self. Port = 1313 # listens on the ports self. Pid = 0 # process id self.banner = banner () # for storing banner header information # Self.minicapsocket = Socket.socket (socket . Af_inet,socket. SOCK_STREAM) Self.minicapsocket=none self. Readimagestreamtask = None Self.push = None Self.picture = Queue () @staticmethod def GETBU Ilder (): "" "Return a single instance of Testbuilder object" "" if (minicapstream.__instance = = None): Minicapstream.__mutex.acquire () if (minicapstream.__instance = = None): minicapstream.__inst ance = Minicapstream () minicapstream.__mutex.release () return minicapstream.__instance def get_d ( Self): Print self.picture.qsize () def run (self): #开始执行 #启动socket连接 self.minicapsocket= Sock Et.socket (SocKet.af_inet,socket. SOCK_STREAM) #定义socket类型, network communication, TCP self.minicapSocket.connect (self. Ip,self. PORT) # return self. Readimagestream () self. Readimagestreamtask = Threading. Thread (target=self. Readimagestream). Start () def readimagestream (self): #读取图片流到队列 readbannerbytes = 0 Bannerlength = 2 Readframebytes = 0 Framebodylength = 0 databody = "" While True: REALLEN=SELF.MINICAPSOCKET.RECV (4096) length = Len (reallen) if not length : Continue cursor = 0 while cursor < length: #just do it If Readbannerbytes < Bannerlength:if readbannerbytes==0: Self.banner.Version = Bytes_to_int (Reallen[cursor]) elif readbannerbytes==1 : Bannerlength = bytes_to_Int (reallen[cursor]) self.banner.Length = bannerlength elif Readban Nerbytes in [2,3,4,5]: Self.banner.Pid + = (Bytes_to_int (reallen[cursor)) << ((readbannerbytes -2) * 8)) >> 0; Elif readbannerbytes in [6,7,8,9]: Self.banner.RealWidth + = (Bytes_to_int (reallen[cursor)) << ((readBannerBytes-6) * 8)) >> 0; Elif readbannerbytes in [10,11,12,13]: Self.banner.RealHeight + = (Bytes_to_int (reallen[cursor)) < ;< ((readBannerBytes-10) * 8)) >> 0; Elif readbannerbytes in [14,15,16,17]: Self.banner.VirtualWidth + = (Bytes_to_int (reallen[cursor)) & lt;< ((readBannerBytes-14) * 8)) >> 0; Elif readbannerbytes in [18,19,20,21]: Self.banner.VirtualHeight + = (Bytes_to_int (reallen[cursor)) << (Readbannerbytes- * 8)) >> 0; elif Readbannerbytes = = 22:self.banner.orientation = Bytes_to_int (Reallen[cursor]) *90 elif Readbannerbytes = = 23:self.banner.quirks = Bytes_to_int (Reallen[cursor]) Cursor + = 1 Readbannerbytes + = 1 if readbannerbytes = = Bannerlength: Print self.banner.toString () elif Readfra Mebytes < 4:framebodylength =framebodylength+ (Bytes_to_int (Reallen[cursor]) << (readframebyte s*8)) >> 0) cursor + + 1 Readframebytes + 1 Else: If Length-cursor >= framebodylength: Databody = Databody + reallen[cursor: (cursor+framebodylength)] If Bytes_to_int (databody[0])!=0xff or Bytes_to_int (databody[1])!=0xd8:return Self.picture.put (databody) # self.save_file (' D:/pic.png ', databody) Cursor + = Framebodylength Framebodylength = 0 Readframebytes = 0 databody = "" Else:databody = Dat Abody + reallen[cursor:length] framebodylength-= length-cursor; Readframebytes + = Length-cursor; cursor = length; # adb Shell ld_library_path=/data/local/tmp/data/local/tmp/minicap-p [email protected]/0# adb forward T cp:1313 localabstract:minicap def save_file (self,file_name, data): File=open (file_name, "WB") File.write (data) File.flush () File.close () if __name__ = = ' __main__ ': a = Minicapstream.getbuilder () Print ID (a) a.run () # pri NT A.pictureprefu Link: https://www.jianshu.com/p/f8b8123cd062 Source: Jane Letters Book Copyright belongs to the author, any form of reprint please contact the author to obtain authorization and indicate the source.
################################################################################# Copyright (C) Riverbank Computing limited.## Copyright (C) the Nokia Corporation and/or its subsidiary (-ies). # All Rights reserved.#### this fil E is part of the examples of pyqt.#### $QT _begin_license:bsd$## your may use this file under the terms of the BSD LICENSE a S follows:#### "redistribution and use in source and binary forms, with or without## modification, is permitted provided That the following conditions are## met:## * Redistributions of source code must retain the above copyright## notice , this list of conditions and the following disclaimer.## * redistributions in binary form must reproduce the above copy right## notice, this list of conditions and the following disclaimer in## the documentation and/or other materials Provided with the## distribution.## * Neither the name of the Nokia Corporation and its subsidiary (-ies) nor## the Names of its contributors is USEd to endorse or promote## products derived from this software without specific prior written## permission.#### TH Is software are provided by the COPYRIGHT holders and contributors## ' as is ' and any EXPRESS OR implied warranties, Includi NG, but not## LIMITED to, the implied warranties of merchantability and FITNESS for## A particular PURPOSE is disclaimed. In NO EVENT shall the copyright## OWNER OR CONTRIBUTORS is liable for any DIRECT, INDIRECT, incidental,## Special, Exempl ARY, or consequential damages (including, but not## LIMITED to, procurement of substitute GOODS OR SERVICES; LOSS of use,## DATA, OR profits; or business interruption) however caused and on any## theory of liability, WHETHER in contract, STRICT liability, OR tort# # (including negligence OR OTHERWISE) arising in any on-the-use## of this software, even IF advised of the Possibi Lity of SUCH DAMAGE. " # # $QT _end_license$############################################################################## #from PyQT4 import Qtcore, qtguifrom minicapstream import minicapstreamimport threadingfrom time import sleep class Screens Hot (qtgui.qwidget): def __init__ (self): Super (screenshot, self). __init__ () Self.obje = Minicapstr Eam.getbuilder () self.inst () Self.picture = self.obje.picture Self.screenshotlabel = Qtgui.qlabel () Self.screenshotLabel.setSizePolicy (QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) s Elf.screenshotLabel.setAlignment (QtCore.Qt.AlignCenter) self.screenshotLabel.setScaledContents (True) Self.sc Reenshotlabel.setminimumsize (640) Self.createoptionsgroupbox () self.createbuttonslayout () mainLa yout = Qtgui.qvboxlayout () mainlayout.addwidget (Self.screenshotlabel) mainlayout.addwidget (self.optionsGroup Box) mainlayout.addlayout (self.buttonslayout) self.setlayout (mainlayout) Self.shootscreen () Self.delayspinbox.SetValue (5) self.setwindowtitle ("screenshot") Self.resize (480,640) # def resizeevent (self, event) : # scaledsize = Self.originalPixmap.size () # Scaledsize.scale (Self.screenshotLabel.size (), QtCore.Qt.KeepAs Pectratio) # if not Self.screenshotLabel.pixmap () or scaledsize! = Self.screenshotLabel.pixmap (). Size (): # Self.updatescreenshotlabel () def inst (self): t= threading. Thread (Target=self.obje.run) T.start () def newscreenshot (self): when true:if not Self.picture.empty (): Sleep (0.1) Self.shootscreen () else:sleep (0 .2) # if self.hideThisWindowCheckBox.isChecked (): # self.hide () # self.newScreenshotButton.se Tdisabled (True) # # QtCore.QTimer.singleShot (Self.delaySpinBox.value () * 1000,# Self.shootscreen) def savescreenshot (self): format = ' png ' Initialpath = QtcoRe. Qdir.currentpath () + "/untitled." + Format FileName = QtGui.QFileDialog.getSaveFileName (self, "Save as", Initialpath, "%s Files (*.%s);; All Files (*) "% (Format.upper (), format)) # if filename:# self.originalPixmap.save (fileName, format) def shootscreen (self): if Self.delaySpinBox.value ()! = 0:qtgui.qapp.beep () # Garba GE collect any existing image first. Self.originalpixmap = none# Self.originalpixmap = QtGui.QPixmap.grabWindow (QtGui.QApplication.desktop (). WinId ()) # Self.updatescreenshotlabel () Pixmap=qtgui.qpixmap () Pixmap.loadfromdata (Self.picture.get ()) s Elf.screenshotLabel.setPixmap (PIXMAP); Self.newScreenshotButton.setDisabled (False) if self.hideThisWindowCheckBox.isChecked (): Self.show () d EF Updatecheckbox (self): if self.delaySpinBox.value () = = 0:self.hidethiswindowcheckbox.setdisabled (True ) Else:self.hideThisWindowCheckBox.setDisabled (False) def createoptionsgroupbox (self): self.opt Ionsgroupbox = Qtgui.qgroupbox ("Options") Self.delayspinbox = Qtgui.qspinbox () self.delaySpinBox.setSuffix (" S ") Self.delaySpinBox.setMaximum (Self.delaySpinBox.valueChanged.connect (self.updatecheckbox) sel F.delayspinboxlabel = Qtgui.qlabel ("screenshot Delay:") Self.hidethiswindowcheckbox = Qtgui.qcheckbox ("Hide this Wi Ndow ") Optionsgroupboxlayout = Qtgui.qgridlayout () optionsgroupboxlayout.addwidget (Self.delayspinboxlabel, 0 , 0) optionsgroupboxlayout.addwidget (self.delayspinbox, 0, 1) optionsgroupboxlayout.addwidget (Self.hideThisW Indowcheckbox, 1, 0, 1, 2) self.optionsGroupBox.setLayout (optionsgroupboxlayout) def createbuttonslayout (self): Self.newscreenshotbutton = Self.createbutton ("New screenshot", Self.newscreenshot) Self.s Avescreenshotbutton = SELf.createbutton ("Save screenshot", self.savescreenshot) Self.quitscreenshotbutton = Self.createbutto N ("Quit", self.close) Self.buttonslayout = Qtgui.qhboxlayout () self.buttonsLayout.addStretch () self.b Uttonslayout.addwidget (Self.newscreenshotbutton) self.buttonsLayout.addWidget (Self.savescreenshotbutton) sel F.buttonslayout.addwidget (Self.quitscreenshotbutton) def createbutton (self, Text, member): Button = QTGUI.QPUSHB Utton (text) button.clicked.connect (Member) return button Def Updatescreenshotlabel (self): SELF.SCR Eenshotlabel.setpixmap (self.originalPixmap.scaled (Self.screenshotLabel.size (), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)) If __name__ = = ' __main__ ': import sys app = QTGUI.QAP Plication (sys.argv) screenshot = screenshot () screenshot.show () Sys.exit (App.exec_ ()) Prefu Link: Https://www.jianshu. com/p/f8b8123cd062 Source: Jane LettersThe copyright of the book is owned by the author, and any form of reprint is to be contacted by the author for authorization and attribution.
Python+minicap (b)