BlackBerry Screen Shot Utility ... Torch 9850 ...如何创建您自己的捕获脚本/工具的指南

发布于 2024-12-08 18:55:44 字数 3211 浏览 0 评论 0 原文

我为每个人提供这个,希望能避免你在自己寻找这个的过程中受到一些脑损伤。

当我正在开发一个将在各种设备上运行的 BlackBerry 项目时,我遇到了从手机(包括 Torch 9850 )抓取屏幕截图的问题……不如我的 iPhone、Android EVO 或 Infuse,但要好得多比 Storm 还终于开始看起来像真正的智能手机 - 性能和电池寿命也很好)。

通常我会使用我值得信赖的 BBScreenShooter,一切都会好起来的,但当尝试在 9850 上捕获图像时,它总是崩溃。我发布了一些 在此网站上请求帮助,但没有人能告诉我为什么我的 BBScreenShooter 崩溃了或者为什么直接使用 RIM 的 JavaLoader 实用程序时,我会收到“正在检索屏幕<活动>数据...错误:缓冲区太小”

对于那些不知道 BBScreenShooter 将“繁重工作”委托给 JavaLoader 来抓取图像的人。

在 Mark Sohm(我认识的地球上最有知识的 BB 人员之一)的帮助下,他要求我验证我是否使用了 v7 SDK 中包含的 JavaLoader。事实证明我不是。很好,马克,谢谢!

从表面上看,早期版本的 JavaLoader 实用程序具有用于图像捕获的 byte[] 缓冲区,这些缓冲区是硬编码的……而且太小。

因此,对于所有需要从 RIM 新款 480 x 800 手机上捕获屏幕截图的人,我提供了一份快速“操作方法”指南,以帮助您尽快提高工作效率。

第 1 步 - 确保您已下载 v7.0 SDK(不必安装,尽管我想不出不安装的好理由)。对于 Eclipse 用户:

步骤 1a) 转至帮助菜单

步骤 1b) 安装新软件菜单选项

步骤 1c) 添加“BlackBerry - http://www.blackberry.com/go/eclipseUpdate/3.6/java”项目位于“使用”字段中。

步骤 1d) 在“BlackBerry Java Plug-in Category”下,查找“BlackBerry Java SDK v7.0.0.X”复选框,然后单击“下一步”。

步骤 1e) 接受许可协议并继续下载和安装过程。

步骤 2 - 转到新添加的 SDK 的安装目录。我们将获取 JavaLoader 实用程序的路径副本,并在 BAT 文件中使用它,该文件将自动捕获和命名屏幕截图。该文件位于 /plugins/net.rim.ejde.componentpack7.0.0_7.0.0.28/components/bin/JavaLoader.exe

步骤 3 - 创建一个用于保存屏幕截图的文件夹。这也将保存您的 BAT 文件,因为 BAT 文件特定于该特定项目。

步骤 4 - 创建 BAT 文件。在我的示例中,我将所有 IDE、SDK...实际上所有开发环境都保存在与操作系统不同的硬盘上。我将它们保留在驱动器 D 上,但修改您的 BAT 以反映配置的位置和需求。

步骤 4a) 关闭回显非常重要,否则您可能无法使用桌面上的图标来启动此脚本/实用程序。

步骤 4b) 如果您的 BAT 文件与 JavaLoader 在本地运行(同一文件夹),则无需执行此步骤。另一方面,如果您的 JavaLoader 位于不同的硬盘驱动器上并且隐藏在文件夹深处,那么您将必须“更改目录”才能访问它。请注意与“更改目录 - cd”命令一起使用的“/D”开关,以便我们可以在同一步骤中更改驱动器和路径。

步骤 4c) 因为我喜欢对部分文件名使用时间戳...设置局部变量来表示当前日期和时间。

步骤 4d) 以下“for”语句将我的 Windows 7 计算机中的当前日期和时间解析为我想要包含为屏幕截图的文件名的格式... 文件名 == BlackBerry__<拍摄图像的时间>.bmp。

步骤 4e) 将 JavaLoader 捕获的新创建的设备屏幕截图复制到目标文件夹,并使用我们刚刚创建的文件名。

步骤 4f) 现在我们已经成功地将屏幕截图的副本保存在所需的目标文件夹中,我们可以删除 JavaLoader 创建的临时图像。

步骤 4g) 我回应了一个小声明,让我知道这一切都有效。

BAT 文件示例:

@echo off

cd /D D:\Program Files (x86)\EclipseBlackBerry\plugins\net.rim.ejde.componentpack7.0.0_7.0.0.28\components\bin

JavaLoader screenshot tempImage.bmp

set timestampdate=%date%

set timestamptime=%time%

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set timestampdate=%%c-%%a-%%b)

For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set timestamptime=%%a%%b)

copy tempImage.bmp "C:\Users\CirrusFlyer\Desktop\<project name>\Testing\Screenshots\BlackBerry_%timestampdate%_%timestamptime%.bmp"

DEL tempImage.bmp

echo Completed "...\<project name>\Testing\Screenshots\BlackBerry_%timestampdate%_%timestamptime%.bmp"

第 5 步 - 关闭并保存 BAT 文件。我将 BAT 保留在我的实际项目文件夹中,然后创建一个快捷方式并将其放在我的桌面上。这样我就可以启动并运行 Eclipse,并在手机上调试应用程序,当我想要抓取屏幕截图时,只需双击快捷方式即可执行捕获。

这将创建屏幕截图并将其放置在目标目录中:例如 BlackBerry_2011-10-07_1015 PM.bmp。

第 6 步 - 大功告成。快乐编码。希望这有帮助。

我的下一个项目:扩展 Eclipse,以便我可以直接从 IDE 中进行屏幕捕获,就像进行基于 Android 的编程时一样。

I am providing this for everyone to hopefully save you some brain damage in finding this yourself.

As I'm working on a BlackBerry project that will run on various devices I ran into an issue grabbing screenshots from the handset (including the Torch 9850 ... not quite as good as my iPhones or my Android EVO or Infuse, but much better than the Storm and finally starting to look like a real smartphone - great performance and battery life too).

Normally I'd use my trusty BBScreenShooter and everything would be fine, but it kept crashing when attempting to capture images on the 9850. I posted a couple of requests for help on this site, but nobody could tell me why my BBScreenShooter was crashing or why I'd get "Retrieving screen <active> data ... Error: buffer too small" when using RIM's JavaLoader utility directly.

For those who didn't know BBScreenShooter delegates the "heavy lifting" to JavaLoader to grab the images.

With the help of Mark Sohm (easily one of the most knowledgable BB guys I know walking the planet) he asked me to verify I was using JavaLoader that is included in the v7 SDK. Turns out I wasn't. Good catch Mark, and thanks!

From the looks of things it appears the earlier versions of the JavaLoader utility have byte[] buffers they use for image capture that are hardcoded ... and too small.

So, for all those who need to capture screen shots from RIM's new 480 x 800 based handsets I have included a quick "how to" guide to help you get productive ASAP.

Step 1 - Make sure you have the v7.0 SDK downloaded (doesn't have to be installed, though I cannot think of a good reason not to). For Eclipse users:

Step 1a) Go to the Help menu

Step 1b) Install New Software menu choice

Step 1c) Add the "BlackBerry - http://www.blackberry.com/go/eclipseUpdate/3.6/java" items in your "work with" field.

Step 1d) Under the "BlackBerry Java Plug-in Category", look for the "BlackBerry Java SDK v7.0.0.X" checkbox and click NEXT.

Step 1e) Accept the license agreements and continue the download and installation process.

Step 2 - Go to the installation directory for your newly added SDK. We're going to grab a copy of the path to the JavaLoader utility and use it within a BAT file that will automate the capture and naming of screen shots. This will be found at /plugins/net.rim.ejde.componentpack7.0.0_7.0.0.28/components/bin/JavaLoader.exe

Step 3 - Create a folder you'd like to use to save screen captures. This will also hold your BAT file as the BAT file is specific to this particular project.

Step 4 - Create the BAT file. In my example here I keep all my IDEs, SDK, ... effectively all development environments on a different hard drive than my OS. I keep these on drive D, but modify your BAT to reflect the location and needs of your configuration.

Step 4a) It's important to turn the echo off, otherwise you will probably be unable to use the icon on the desktop to launch this script/utility.

Step 4b) If your BAT file is running locally (same folder) as JavaLoader then this step will be unnecessary. On the other hand if your JavaLoader is on a different hard drive and tucked away deep in folders then you'll have to "change directory" to get to it. Notice the "/D" switch that is used with the "change directory - cd" command so that we can change drives and paths in the same step.

Step 4c) As I like to use timestamps for part of my file names ... set local variables to represent the current date and time.

step 4d) The following "for" statements parse out the current date and time from my Windows 7 computer into a format that I want to include as the file names for my screen captures ... file name == BlackBerry_<date image was taken>_<time image was taken>.bmp.

Step 4e) Copy the newly created device screen shot that JavaLoader captured to your target folder and use the file name we've just created.

Step 4f) Now that we've successfully got a copy of the screenshot saved in our desired target folder we can delete the temporary image that JavaLoader created.

Step 4g) I echo a little statement that lets me know it all worked.

Example BAT file:

@echo off

cd /D D:\Program Files (x86)\EclipseBlackBerry\plugins\net.rim.ejde.componentpack7.0.0_7.0.0.28\components\bin

JavaLoader screenshot tempImage.bmp

set timestampdate=%date%

set timestamptime=%time%

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set timestampdate=%%c-%%a-%%b)

For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set timestamptime=%%a%%b)

copy tempImage.bmp "C:\Users\CirrusFlyer\Desktop\<project name>\Testing\Screenshots\BlackBerry_%timestampdate%_%timestamptime%.bmp"

DEL tempImage.bmp

echo Completed "...\<project name>\Testing\Screenshots\BlackBerry_%timestampdate%_%timestamptime%.bmp"

Step 5 - Close and save your BAT file. I kept the BAT in my actual project folder, then created a shortcut and placed it on my desktop. This way I can have my Eclipse up and running and be debugging the application on my handset, and when I want to grab a screen shot simply double-click the shortcut to execute the capture.

This will create screen shots and place them in the target directory: BlackBerry_2011-10-07_1015 PM.bmp, for example.

Step 6 - Your done. Happy coding. Hope this helps.

My next project: extending Eclipse so that I can do screen captures directly from within the IDE the same way I can when doing Android based programming.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文