1

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番目とそれをtryonエラーで一緒に結びました...

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

この構文が正しいかどうかはわかりませんが、私が達成しようとしていることをカプセル化していると思います。助けてくれてありがとう。

4

1 に答える 1

0

あなたはこのようなことを試すことができます:

set maxWindow to 20

repeat with i from 1 to maxWindow
    try
        set the_number to tTracker(i)
        exit repeat
    end try
end repeat

-- insert the rest of your script
return the_number

-- Handlers
on tTracker(windowNumber)
    try

        tell application "System Events"
            set frontmost of process "Ticket Tracker" to true
            tell process "Ticket Tracker"
                set xxx 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 windowNumber

                if xxx = "" then
                    set xxx to value of attribute "AXvalue" of static text 1 of splitter group 1 of window windowNumber
                end if
            end tell
        end tell
        return xxx

    on error
        tell application "System Events" to tell process "Ticket Tracker"
            set xxx 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 windowNumber
            if xxx = "" then
                set xxx 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 windowNumber
            end if
        end tell
        return xxx

    end try
end tTracker
于 2012-09-27T04:35:36.353 に答える