AppleScriptをサポートしていない社内アプリケーションの電話番号をターゲットにするUIスクリプトを含むスクリプトがあります(したがって、UIスクリプトが必要です)。私が首尾よく書いた部分は次のとおりです。
tell application "System Events" to set frontmost of process "Ticket Tracker" to true
tell application "System Events"
tell process "Ticket Tracker"
try
try
set the_number to value of attribute "AXvalue" of static text 14 of group 1
of scroll area 1 of splitter group 2 of splitter group 1 of window 1
if the_number = "" then
set the_number to value of attribute "AXvalue" of static text 1 of
splitter group 1 of window 1
end if
on error
set the_number to value of attribute "AXvalue" of combo box 3 of
tab group 1 of scroll area 1 of splitter group 2 of splitter group 2 of
splitter group 1 of window 1
if the_number = "" then
set the_number to value of attribute "AXvalue" of static text 11
of tab group 1 of scroll area 1 of splitter group 2 of splitter group 2
of splitter group 1 of window 1
end if
end try
このコードの後半は、新しく開いた2番目のウィンドウから番号を取得しようとすることです。最初のウィンドウが開いていて、それが番号を取得したいウィンドウである場合、「ウィンドウ1」は完全に細かいインデックスです。ただし、新しいウィンドウを開き、2番目のウィンドウ(最初に開いたウィンドウ)が番号を取得するウィンドウである場合は、「ウィンドウ2」を探す必要があります。そのため、コードの最初のブロックを組み合わせました。あなたが見ることができるように2番目とそれをtryとonエラーで一緒に結びました...
on error
try
set the_number to value of attribute "AXvalue" of static text 14
of group 1 of scroll area 1 of splitter group 2 of splitter group 1
of window 2
if the_number = "" then
set the_number to value of attribute "AXvalue" of static text 1
of splitter group 1 of window 2
end if
on error
set the_number to value of attribute "AXvalue" of combo box 3 of
tab group 1 of scroll area 1 of splitter group 2 of splitter group 2
of splitter group 1 of window 2
if the_number = "" then
set the_number to value of attribute "AXvalue" of static text 11
of tab group 1 of scroll area 1 of splitter group 2 of splitter group 2
of splitter group 1 of window 2
end if
end try
end try
end tell
end tell
これは優れたスターターコンセプトでしたが、私のスクリプトを使用する他の人は「チケットトラッカー」アプリケーションの操作方法が異なり、6または7までの「ウィンドウインデックス」を検索する必要がありました。
私がやりたいのは、私が持っているコードのブロックの前半を使用するスクリプトオブジェクトを作成し、それが「window x」を見つけられない場合は、「window x + 1」を見つけて、試行を続けることです。成功するまで(約20の制限付き)。私はスクリプトオブジェクトに非常に慣れておらず、まだ概念を理解しようとしていますが、これは私がこれまでに持っているものです:
Script indexFinder
property x : 1
to tryAgain
set x to x + 1
try
try
set the_number to value of attribute "AXvalue" of static text 14 of group 1
of scroll area 1 of splitter group 2 of splitter group 1 of window x
if the_number = "" then
set the_number to value of attribute "AXvalue" of static text 1 of
splitter group 1 of window x
end if
on error
set the_number to value of attribute "AXvalue" of combo box 3 of
tab group 1 of scroll area 1 of splitter group 2 of splitter group 2 of
splitter group 1 of window x
if the_number = "" then
set the_number to value of attribute "AXvalue" of static text 11
of tab group 1 of scroll area 1 of splitter group 2 of splitter group 2
of splitter group 1 of window x
end if
end try
on error
repeat tryAgain
end try
end tryAgain
end script
この構文が正しいかどうかはわかりませんが、私が達成しようとしていることをカプセル化していると思います。助けてくれてありがとう。