カルテット スクリーンショット applescript(次々版)


カルテットがアップデートされて(v57301)、レセプトが次々点検できる様になりました。かなりよくなりました!!


画面の切り替えにうちの環境だと5〜6秒くらいかかります。

せっかち(?)で、画面を保存して見たい方のために、今回のカルテット(v57301)用のapplescriptを作りました。

ほぼ前回の物と同じですが、今回は、最初のレセプトプレビューを開いた状態[F7を押した状態]でAppleScriptをはじめて(実行して)下さい!!

マウスで画面中央をクリックしないと右矢印が効かなかったので、ユーザー定義関数、mouseClickハンドラを使用しました。


http://www.naito-dental.com/receiptss3a.zip

receiptss3aのAppleScript

                                                                                • -

tell application "Finder"
make new folder at desktop with properties {name:"receipt"} --デスクトップにreceiptフォルダを作製
end tell

tell application "Karte"
activate

tell application "Finder"
set desktopBounds to get the bounds of the window of desktop --スクリーンのサイズ(解像度)を得る
set rightX to item 3 of desktopBounds -- 右下のX座標(leftRight)
set bottomY to item 4 of desktopBounds -- 右下のY座標(topBottom)
set rightXMiddle to (rightX / 2) -- 水平的真ん中
set bottomYMiddle to (bottomY / 2) --垂直的真ん中
my mouseClick({rightXMiddle, bottomYMiddle}, "left", 1, "", 1) --マウスで画面中央をクリック
end tell

repeat with num from 1 to 5 --レセプト合計数に変更して下さい
--
delay 40 --待ち時間設定。各環境によって変えて下さい
set tgt_file to num & ".png" --ファイル名設定
do shell script "screencapture ~/Desktop/receipt/" & tgt_file --スクリーンショット
--
delay 3 --待ち時間設定。各環境によって変えて下さい
tell application "System Events"
key code 124 --右矢印入力(次のレセプトへ)
end tell
--
end repeat
--
end tell

                                                                                              • -
    • ユーザー定義関数、mouseClickハンドラ

on mouseClick(thePosition, theButton, theClickCount, theModifierKeys, thePressSec)
(*
ver.2010.6.11
thePosition は {"mouse", "mouse"} で現在のマウスの位置をクリックする
theButton は "left" "right" "middle"
theClickCount はクリック回数。2でダブルクリック
theModifierKeys は command shift control option fn caps
thePressSecは押している時間。秒
*)
set theModifierKeys to theModifierKeys & " - "
set thePressSecText to thePressSec as text
set theRubyScript to "require 'osx/cocoa';
if ARGV[0] == 'mouse' then
event=OSX::CGEventCreate(nil);
pos = OSX::CGEventGetLocation(event);
print pos.x , ',', pos.y;
else
pos = [ARGV[0], ARGV[1]];

end

buttonInput = ARGV[2];
clickCount = ARGV[3].to_i;
modifierKeys = ARGV[4];
thePressSec = ARGV[5].to_f;

if buttonInput == 'left' then
button=0;
eventTypeDown=1;
eventTypeUp=2;
end

if buttonInput == 'right' then
button=1;
eventTypeDown=3;
eventTypeUp=4;
end

if buttonInput == 'middle' then
button=2;
eventTypeDown=25;
eventTypeUp=26;
end

eventFlag = 0;

if modifierKeys.index('command' ) != nil then
eventFlag |= 0x00100000;
end

if modifierKeys.index('shift' ) != nil then
eventFlag |= 0x00020000;
end

if modifierKeys.index('option' ) != nil then
eventFlag |= 0x00080000;
end

if modifierKeys.index('control' ) != nil then
eventFlag |= 0x00040000;
end

if modifierKeys.index('fn' ) != nil then
eventFlag |= 0x00800000;
end

if modifierKeys.index('caps' ) != nil then
eventFlag |= 0x00010000;
end



ev=OSX::CGEventCreateMouseEvent(nil, eventTypeDown, pos, button);
OSX::CGEventSetIntegerValueField(ev, 1, clickCount);
OSX::CGEventSetFlags(ev, eventFlag);
OSX::CGEventPost(0,ev);

sleep thePressSec;

ev2=OSX::CGEventCreateMouseEvent(nil, eventTypeUp, pos, button);
OSX::CGEventSetIntegerValueField(ev2, 1, clickCount);
OSX::CGEventSetFlags(ev2, eventFlag);
OSX::CGEventPost(0,ev2);
"
do shell script "/usr/bin/ruby -e " & quoted form of theRubyScript & " " & item 1 of thePosition & " " & item 2 of thePosition & " " & theButton & " " & theClickCount & " " & quoted form of theModifierKeys & " " & quoted form of thePressSecText
end mouseClick