{"id":2514,"date":"2011-06-29T06:00:08","date_gmt":"2011-06-29T04:00:08","guid":{"rendered":"http:\/\/blogs.wittwer.fr\/whiler\/?p=2514"},"modified":"2012-03-03T13:21:00","modified_gmt":"2012-03-03T12:21:00","slug":"snapshot-android-delphi","status":"publish","type":"post","link":"https:\/\/blogs.wittwer.fr\/whiler\/2011\/06\/29\/snapshot-android-delphi\/","title":{"rendered":"Capture Android depuis Delphi"},"content":{"rendered":"<p>Dans l&rsquo;<a href=\"\/whiler\/2011\/06\/28\/android-screenshot\/\">article pr\u00e9c\u00e9dent<\/a>, j&rsquo;ai cr\u00e9\u00e9 un <a href=\"http:\/\/fr.wikipedia.org\/wiki\/JAR_(format_de_fichier)\" rel=\"glossary\" target=\"_blank\" title=\"Wikipedia, D&eacute;finition de&nbsp;: JAR\" style=\"\" >JAR<\/a><sup style=\"font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA\" ><em>W<\/em><\/sup> qui me permet d&rsquo;effectuer des captures d&rsquo;\u00e9cran depuis un p\u00e9riph\u00e9rique Android.<\/p>\n<p>J&rsquo;ai tout simplement utilis\u00e9 ce <a title=\"Cliquer pour t\u00e9l\u00e9charger le JAR\" href=\"https:\/\/www.whiler.com\/freewares\/download?wgetscreenshot.jar\">JAR<\/a> depuis une application que j&rsquo;ai \u00e9crite en Delphi.<\/p>\n<p> (!!) <strong>Java et le <a target=\"_blank\" href=\"https:\/\/developer.android.com\/sdk\/\">SDK d&rsquo;Android<\/a> doivent \u00eatre install\u00e9s pour que l&rsquo;application puisse fonctionner&nbsp;!<\/strong> Le <a href=\"\/whiler\/2011\/06\/24\/adb-pour-htc-desire-windows-7\/\">pilote ADB<\/a> pour votre t\u00e9l\u00e9phone doit \u00e9galement \u00eatre install\u00e9. Votre t\u00e9l\u00e9phone doit \u00eatre sur le mode <a href=\"\/whiler\/wp-content\/uploads\/2011\/06\/debug.png\">d\u00e9bogage USB<\/a>.<\/p>\n<p>L&rsquo;application est des plus simples&nbsp;:<\/p>\n<ul>\n<li>On pr\u00e9cise l&#8217;emplacement du fichier adb.exe de son installation du SDK Android<\/li>\n<li>Si l&rsquo;on veut capturer un t\u00e9l\u00e9phone\/tablette ou un \u00e9mulateur<\/li>\n<li>On clique sur un des boutons pour lancer la capture<\/li>\n<li>On sauvegarde l&rsquo;image<\/li>\n<\/ul>\n<div id=\"attachment_2538\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"\/whiler\/wp-content\/uploads\/2011\/06\/wGetAndroidSnapshot.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2538\" src=\"\/whiler\/wp-content\/uploads\/2011\/06\/wGetAndroidSnapshot-300x288.jpg\" alt=\"wGetAndroidSnapshot\" title=\"wGetAndroidSnapshot\" width=\"300\" height=\"288\" class=\"size-medium wp-image-2538\" srcset=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/uploads\/2011\/06\/wGetAndroidSnapshot-300x288.jpg 300w, https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/uploads\/2011\/06\/wGetAndroidSnapshot.jpg 964w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2538\" class=\"wp-caption-text\">wGetAndroidSnapshot<\/p><\/div>\n<p>L&rsquo;image est sauvegard\u00e9e \u00e0 sa taille d&rsquo;origine. L&rsquo;affichage ne sert qu&rsquo;\u00e0 pr\u00e9visualiser l&rsquo;image captur\u00e9e.<\/p>\n<p>Vous avez d\u00e9j\u00e0 install\u00e9 le SDK d&rsquo;Android et vous souhaitez faire des captures en toute simplicit\u00e9.. vous pouvez t\u00e9l\u00e9charger cette application depuis <a title=\"Cliquer pour t\u00e9l\u00e9charger wGetAndroidSnapshot\" href=\"https:\/\/www.whiler.com\/freewares\/download?wgetandroidsnapshot.exe\">ce lien<\/a>.<\/p>\n<p>En <a href=\"\/whiler\/2011\/06\/29\/snapshot-android-delphi\/2\/\">seconde page<\/a>, quelques informations compl\u00e9mentaires concernant l&rsquo;application&#8230;<br \/>\n<!--nextpage--><br \/>\nOn remarquera sur la<a href=\"\/whiler\/wp-content\/uploads\/2011\/06\/wGetAndroidSnapshot.jpg\"> capture d&rsquo;\u00e9cran<\/a>, le bouton sous la pr\u00e9visualisation de la t\u00e2che dans Windows 7. Cela a \u00e9t\u00e9 impl\u00e9ment\u00e9 en suivant les explications de cet <a href=\"\/whiler\/2011\/06\/23\/delphi-taskbar-windows-7\/5\/\">article<\/a>.<\/p>\n<p>Pour l&rsquo;ex\u00e9cution du JAR, j&rsquo;ai utilis\u00e9 la m\u00e9thode de <a target=\"_blank\" href=\"https:\/\/www.martinstoeckli.ch\/delphi\/delphi.html#AppStart\">ce site<\/a>.<\/p>\n<p>De plus, si le chemin d&rsquo;ADB n&rsquo;a pas encore \u00e9t\u00e9 renseign\u00e9, j&rsquo;essaye au lancement de l&rsquo;application de le trouver. Pour cela, je me suis amus\u00e9 \u00e0 coder cette fonction (l\u00e0, les \u00e9ventuels d\u00e9veloppeurs <a target=\"_blank\" href=\"https:\/\/www.embarcadero.com\/fr\/products\/delphi\">Delphi<\/a> vont prendre peur <img src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-includes\/images\/smilies\/skype\/\/rofl.gif\" alt=\"(rofl)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> ).<\/p>\n<div class=\"codecolorer-container delphi dawn\" style=\"overflow:auto;white-space:nowrap;width:480px;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/><\/div><\/td><td><div class=\"delphi codecolorer\"><span class=\"kw1\">function<\/span> TfrmMain<span class=\"sy1\">.<\/span><span class=\"me1\">TryToGetADBPath<\/span><span class=\"sy1\">:<\/span> TFileName<span class=\"sy1\">;<\/span><br \/>\n<span class=\"kw1\">var<\/span><br \/>\n&nbsp; reg &nbsp; &nbsp; &nbsp;<span class=\"sy1\">:<\/span> TRegistry<span class=\"sy1\">;<\/span><br \/>\n&nbsp; fnADBPath<span class=\"sy1\">:<\/span> TFileName<span class=\"sy1\">;<\/span><br \/>\n<span class=\"kw1\">label<\/span><br \/>\n&nbsp; CloseKey<span class=\"sy1\">,<\/span> FreeReg<span class=\"sy1\">;<\/span><br \/>\n<br \/>\n&nbsp; <span class=\"kw1\">function<\/span> GetPath<span class=\"br0\">&#40;<\/span><span class=\"kw1\">const<\/span> reg<span class=\"sy1\">:<\/span> TRegistry<span class=\"br0\">&#41;<\/span><span class=\"sy1\">:<\/span> TFileName<span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> reg<span class=\"sy1\">.<\/span><span class=\"me1\">ValueExists<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'UninstallString'<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw1\">then<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; &nbsp; fnADBPath <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> <span class=\"kw3\">IncludeTrailingPathDelimiter<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw3\">ExtractFilePath<\/span><span class=\"br0\">&#40;<\/span>reg<span class=\"sy1\">.<\/span><span class=\"me1\">ReadString<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'UninstallString'<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"sy3\">+<\/span> <span class=\"st0\">'platform-tools\\adb.exe'<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span><span class=\"kw3\">FileExists<\/span><span class=\"br0\">&#40;<\/span>fnADBPath<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw1\">then<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">Exit<\/span><span class=\"br0\">&#40;<\/span>fnADBPath<span class=\"br0\">&#41;<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">end<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">else<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; GetPath <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> <span class=\"st0\">''<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\n<span class=\"kw1\">begin<\/span><br \/>\n&nbsp; Result <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> <span class=\"st0\">''<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; reg &nbsp; &nbsp; &nbsp; <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> TRegistry<span class=\"sy1\">.<\/span><span class=\"me1\">Create<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">try<\/span><br \/>\n&nbsp; &nbsp; reg<span class=\"sy1\">.<\/span><span class=\"me1\">RootKey<\/span> <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> HKEY_LOCAL_MACHINE<span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>reg<span class=\"sy1\">.<\/span><span class=\"me1\">OpenKeyReadOnly<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Android SDK Tools'<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw1\">then<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; &nbsp; Result <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> GetPath<span class=\"br0\">&#40;<\/span>reg<span class=\"br0\">&#41;<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>Result &lt;&gt; <span class=\"st0\">''<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw1\">then<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">goto<\/span> CloseKey<span class=\"sy1\">;<\/span> <span class=\"co1\">\/\/ ah ah ah <\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; reg<span class=\"sy1\">.<\/span><span class=\"me1\">CloseKey<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>reg<span class=\"sy1\">.<\/span><span class=\"me1\">OpenKeyReadOnly<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Android SDK Tools'<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw1\">then<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">begin<\/span><br \/>\n&nbsp; &nbsp; &nbsp; Result <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> GetPath<span class=\"br0\">&#40;<\/span>reg<span class=\"br0\">&#41;<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\nCloseKey<span class=\"sy1\">:<\/span><br \/>\n&nbsp; &nbsp; reg<span class=\"sy1\">.<\/span><span class=\"me1\">CloseKey<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">finally<\/span><br \/>\nFreeReg<span class=\"sy1\">:<\/span><br \/>\n&nbsp; &nbsp; reg<span class=\"sy1\">.<\/span><span class=\"me1\">Free<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><br \/>\n<span class=\"kw1\">end<\/span><span class=\"sy1\">;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Il n&rsquo;est pas n\u00e9cessaire de t\u00e9l\u00e9charger le  <a title=\"Cliquer pour t\u00e9l\u00e9charger le JAR\" href=\"https:\/\/www.whiler.com\/freewares\/download?wgetscreenshot.jar\">JAR<\/a> utilis\u00e9 par l&rsquo;<a title=\"Cliquer pour t\u00e9l\u00e9charger wGetAndroidSnapshot\" href=\"https:\/\/www.whiler.com\/freewares\/download?wgetandroidsnapshot.exe\">application<\/a>. Celui-ci est inclus dans l&rsquo;application et s&rsquo;extrait automatiquement au lancement de celle-ci.<\/p>\n<p><center><a href=\"\/whiler\/category\/computer\/delphi\/\" title=\"Articles concernant Delphi\"><img loading=\"lazy\" decoding=\"async\" src=\"\/whiler\/wp-content\/uploads\/2009\/10\/built_with_delphi.png\" alt=\"D\u00e9velopp\u00e9 en Delphi\" title=\"D\u00e9velopp\u00e9 en Delphi\" width=\"125\" height=\"51\" class=\"size-full wp-image-2721\" \/><\/a><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dans l\u2019article pr\u00e9c\u00e9dent, j\u2019ai cr\u00e9\u00e9 un JAR qui me permet d\u2019effectuer des captures d\u2019\u00e9cran depuis un p\u00e9riph\u00e9rique Android.<\/p>\n<p>J\u2019ai tout simplement utilis\u00e9 ce JAR depuis une application que j\u2019ai \u00e9crite en Delphi&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[132,7,6],"tags":[125,158,27,154,93,134,108,151],"class_list":["post-2514","post","type-post","status-publish","format-standard","hentry","category-android","category-delphi","category-dev","tag-b3lly","tag-android","tag-coloration-syntaxique","tag-delphi","tag-freeware","tag-java","tag-script","tag-windows-7"],"_links":{"self":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/2514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/comments?post=2514"}],"version-history":[{"count":0,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/2514\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/media?parent=2514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/categories?post=2514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/tags?post=2514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}