howm の ImageCapture を見ていて
OpenOffice.org writer でもできるんじゃない?
と思いつき、やってみたところなかなか便利そうでした。
直接呼び出すのは scrotScreen や importWindowOrRectangle といったプロシージャで、
これをツールバーに登録したりショートカットキーを割り当てて使うのがおすすめです。
OpenOffice.org Basic です。気が向いたら修正するかもしれません。
Linux では import を使えばできるだろう……と思っていたのですが、
一部のウィンドウが真っ黒になってしまう問題があったので
scrot
(Ubuntu の場合は apt でインストール可)も使えるようにしてみました。
ただし、scrot の場合は「選択したウィンドウ」ないし
「現在アクティブなウィンドウ」は取り込めないようです。
Windows の場合 WinShot
または boxcutter が別途必要です。
ただし、boxcutter の場合は
「選択したウィンドウ」ないし
「現在アクティブなウィンドウ」は取り込めないようです。
個別のウィンドウのスクリーンショットは Alt + Print Screen
でクリップボードにコピーして貼ればいいので特に問題ない気もしますが。
rem The MIT License
rem
rem Copyright (c) 2010 sonota <yosiot8753@gmail.com>
rem
rem Permission is hereby granted, free of charge, to any person obtaining a copy
rem of this software and associated documentation files (the "Software"), to deal
rem in the Software without restriction, including without limitation the rights
rem to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
rem copies of the Software, and to permit persons to whom the Software is
rem furnished to do so, subject to the following conditions:
rem
rem The above copyright notice and this permission notice shall be included in
rem all copies or substantial portions of the Software.
rem
rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
rem IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
rem FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
rem AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
rem LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
rem OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
rem THE SOFTWARE.
rem ----------------------------------------------------------------------
rem for scrot (Linux)
sub scrotScreen
scrotCommon("")
end sub
sub scrotRectangle
scrotCommon(" -s ")
end sub
rem ----------------------------------------------------------------------
rem for ImageMagick import (Linux)
rem 取り込みたいウィンドウをクリック、またはドラッグで矩形選択
sub importWindowOrRectangle
importCommon(" -frame ")
end sub
sub importScreen
importCommon(" -window root ")
end sub
rem ----------------------------------------------------------------------
rem for WinShot (Windows)
sub winshotRectangle
winshotCommon(" -Bitmap -Rectangle -Close -File ")
end sub
sub winshotWindow
winshotCommon(" -Bitmap -ActiveWindow -Close -File ")
end sub
sub winshotScreen
winshotCommon(" -Bitmap -Desktop -Close -File ")
end sub
rem ----------------------------------------------------------------------
rem for boxcutter (Windows)
sub boxcutterRectangle
boxcutterCommon("")
end sub
sub boxcutterScreen
boxcutterCommon(" --fullscreen ")
end sub
rem ----------------------------------------------------------------------
rem コマンドのパスの設定 / set command path
sub scrotCommon(options as String)
imageCapture("/usr/bin/scrot", options, "SHELL")
end sub
sub importCommon(options as String)
imageCapture("/usr/bin/import", options, "SHELL")
end sub
sub winshotCommon(options as String)
imageCapture("C:\xxx\winshot153a\WinShot.exe", options, "UNO_SYSTEM_SHELL_EXECUTE")
end sub
sub boxcutterCommon(options as String)
imageCapture("C:\xxx\boxcutter.exe", options, "SHELL")
end sub
rem ----------------------------------------------------------------------
sub imageCapture(commandPath as String, options as String, wayOfExec as String)
dim document as Object
dim dispatcher as Object
dim tempImagePath as String
dim platform as String
dim waitMSec as Integer
rem ----------------------------------------------------------------------
rem 設定 / settings
platform = "LINUX"
rem platform = "WINDOWS"
waitMSec = 5000
rem ----------------------------------------------------------------------
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
select case platform
case "LINUX":
tempImagePath = "/tmp/image-capture-temp.png"
case "WINDOWS":
tempImagePath = Environ("TEMP") + "\image-capture-temp.png"
end select
rem ----------------------------------------------------------------------
wait waitMSec
beep
wait 100
select case wayOfExec
case "SHELL"
shell( convertToUrl(commandPath), 0, options + " " + tempImagePath, True)
case "UNO_SYSTEM_SHELL_EXECUTE"
Dim oSvc as object
oSvc = createUnoService("com.sun.star.system.SystemShellExecute")
oSvc.execute( ConvertToUrl(commandPath), options + " " + tempImagePath, 0 )
wait 1000
rem スクリーンショット取得まで待つ代わりに
msgbox("スクリーンショット取得後に押してください。") rem "Click after shoot"
case else
msgbox("コマンド実行方法の指定に誤りがあります。") rem "wayOfExec unknown"
exit sub
end select
insertImage(tempImagePath)
dispatcher.executeDispatch(document, ".uno:Escape", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
rem ----------------------------------------------------------------------
rem modify anchor
dim oDoc as object
oDoc = ThisComponent
oDrawPage = oDoc.DrawPage
oDrawPageObj = oDrawPage.getByIndex(oDrawPage.Count - 1)
oDrawPageObj.AnchorType = 1 rem 1: as char
kill(tempImagePath)
end sub
sub insertImage(tempImagePath as string)
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = converttourl(tempImagePath)
args1(1).Name = "FilterName"
args1(1).Value = "<すべての書式>"
args1(2).Name = "AsLink"
args1(2).Value = false
args1(3).Name = "Style"
args1(3).Value = "図"
dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())
end sub