Click Menu Item - unspezifisches Fenster

Silberne

Mitglied
Thread Starter
Dabei seit
07.03.2022
Beiträge
5
Reaktionspunkte
0
Hallo Leute,

Ich bin absoluter Beginner in Apple Script. Ich aber fasziniert von seinen Möglichkeiten. Ich muss viele sich wiederholende Klickaufgaben machen. Perfekt für Automation?

Ich hänge aber schon bei der ersten Hürde. Ich muss in Safari immer wieder gleiche Schaltflächen drücken allerdings ändern sich die Fensternamen und darum wird der Script unterbrochen. Wie kann ich das umgehen?

So sieht mein Script aus:
Code:
on run {input, parameters}
    -- 57 DKB
    delay 0.115138
    set timeoutSeconds to 2.000000
    set uiScript to "click menu item \"57 DKB\" of menu 1 of group 1 of tab group 1 of splitter group 1 of window \"Ausgabe AMEU-INV-DE-2020-5820200 - sevDesk\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )
    return input
end run

on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"System Events\"
" & uiScript & "
end tell"
            exit repeat
        on error errorMessage
            if ((current date) > endDate) then
                error "Can not " & uiScript
            end if
        end try
    end repeat
end doWithTimeout

Ich dachte jetzt in meinem jugendlichen Leichtsinn ich kürze alle genauen Bezeichnungen wie z.B. \"Ausgabe AMEU-INV-DE-2020-5820200 - sevDesk\" raus:

Code:
on run {input, parameters}
    -- 57 DKB
    delay 0.115138
    set timeoutSeconds to 2.000000
    set uiScript to "click menu item \"57 DKB\" of menu 1 of group 1 of tab group 1 of splitter group 1 of window of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )
    return input
end run

on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"System Events\"
" & uiScript & "
end tell"
            exit repeat
        on error errorMessage
            if ((current date) > endDate) then
                error "Can not " & uiScript
            end if
        end try
    end repeat
end doWithTimeout

Leider geht das natürlich nicht. Weil das Skript eben nach dem Fenster sucht, mit dem ich die "Meine Aktion aufnehmen" aufgenommen hatte.

Kann mir einer einen Tipp geben in welche Richtung ich recherchieren kann? "set uiScript find click targets" zu googeln z.B. hat keinen Erfolg gezeigt ..
 
Kann mir einer einen Tipp geben in welche Richtung ich recherchieren kann? "set uiScript find click targets" zu googeln z.B. hat keinen Erfolg gezeigt ..
Aus der Hüfte ins Blaue: evtl. window_id bzw. set win_ID to window id of ….
 
Im Zusammenhang mit click? Sorry ich bin sehr neu in Apple Script...

Wie kann ich die vorhandenen win_id auslesen, damit ich adressieren kann? mit get?
 
Zuletzt bearbeitet:
Ich habe folgenden Script gefunden:
Code:
tell application "Safari" to set the URL of the active tab of window 1 to theUrl
 
Heißt erstmal
Code:
tell application "Safari" to set the URL of the active tab of window 1 to theUrl
dann den Code den ich bereits habe nur non-variable ID:
Code:
\"Ausgabe AMEU-INV-DE-2020-5820200 - sevDesk\"
ersetze ich mit
Code:
theUrl
Ohne \"?
Code:
 set uiScript to "click menu item \"57 DKB\" of menu 1 of group 1 of tab group 1 of splitter group 1 of window theUrl of application process \"Safari\""
 
Zuletzt bearbeitet:
Sieht dann so aus:
Code:
on run {input, parameters}
    -- 57 DKB
    delay 0.115138
    set timeoutSeconds to 2.000000
    tell application "Safari" to set the URL of the active tab of window 1 to theUrl
    set uiScript to "click menu item \"57 DKB\" of menu 1 of group 1 of tab group 1 of splitter group 1 of window theUrl of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )
    return input
end run

on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"System Events\"
" & uiScript & "
end tell"
            exit repeat
        on error errorMessage
            if ((current date) > endDate) then
                error "Can not " & uiScript
            end if
        end try
    end repeat
end doWithTimeout
 
Zurück
Oben Unten