• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Viele hassen ihn, manche schwören auf ihn, wir aber möchten unbedingt sehen, welche Bilder Ihr vor Eurem geistigen Auge bzw. vor der Linse Eures iPhone oder iPad sehen könnt, wenn Ihr dieses Wort hört oder lest. Macht mit und beteiligt Euch an unserem Frühjahrsputz ---> Klick

Variable Textinhalte kopieren und einfügen

mattwill

Erdapfel
Registriert
02.04.16
Beiträge
4
Hallo liebe Community,

ich versuche erstmalig mit dem Automator einen lästigen Arbeitsablauf loszuwerden. Mein Problem ist, dass beim aufzeichnen des Arbeitsablaufs nur immer genau derselbe Textinhalt des Textfeldes kopiert und wieder eingefügt wird und nicht variiert. Der Kunden heisst aber nicht immer "Max Mustermann"...
Es geht um eine Bearbeitung von Tickets in einem Webinterface, hier mal der Code:
Code:
_____________________________
on run {input, parameters}

--

delay 1.613532

set timeoutSeconds to 2.000000

set uiScript to "click UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Queue-Ansicht\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


--

delay 5.498363

set timeoutSeconds to 2.000000

set uiScript to "click group 18 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Queue-Ansicht\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- ⌘C drücken

delay 0.199749

set timeoutSeconds to 2.000000

set uiScript to "keystroke \"c\" using command down"

my doWithTimeout( uiScript, timeoutSeconds )


-- Auf die URL „Inhalt“ klicken.

delay 5.150694

set timeoutSeconds to 2.000000

set uiScript to "click static text 1 of UI Element \"Inhalt\" of group 10 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Queue-Ansicht\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- Auf die URL „Freie Felder“ klicken.

delay 2.194377

set timeoutSeconds to 2.000000

set uiScript to "click static text 1 of UI Element \"Freie Felder\" of group 5 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Inhalt :: 2016040210001109\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- Auf den Titel „<fill in title>“ klicken.

delay 2.912435

set timeoutSeconds to 2.000000

set uiScript to "click radio button 1 of tab group 1 of window \"OTRS :: Ticket :: Freie Felder :: 2016040210001109\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- Auf das Textfeld klicken.

delay 1.132129

set timeoutSeconds to 2.000000

set uiScript to "click text field 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Subscriptions\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- ⌘V drücken

delay 1.112045

set timeoutSeconds to 2.000000

set uiScript to "keystroke \"v\" using command down"

my doWithTimeout( uiScript, timeoutSeconds )


-- „Max Mustermann" in das Textfeld eingeben.

delay 0.927076

set timeoutSeconds to 2.000000

set uiScript to "click text field 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Subscriptions\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- Löschen drücken

delay 0.885039

set timeoutSeconds to 2.000000

set uiScript to "keystroke \"\" "

my doWithTimeout( uiScript, timeoutSeconds )


-- Typ 'Herr'

delay 0.504069

set timeoutSeconds to 2.000000

set uiScript to "keystroke \"Herr\""

my doWithTimeout( uiScript, timeoutSeconds )


-- „Herr Max Mustermann“ in das Textfeld eingeben.

delay 1.647039

set timeoutSeconds to 2.000000

set uiScript to "click text field 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Subscriptions\" of application process \"Safari\""

my doWithTimeout( uiScript, timeoutSeconds )


-- ⌥X drücken

delay 0.456013

set timeoutSeconds to 2.000000

set uiScript to "keystroke \"≈\" using option down"

my doWithTimeout( uiScript, timeoutSeconds )


-- Löschen drücken

delay 2.864205

set timeoutSeconds to 2.000000

set uiScript to "keystroke \"\" "

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
_______________________________________

Wäre toll, wenn das irgendwie ginge!

Danke und viele Grüße

Matz
 
Zuletzt bearbeitet von einem Moderator:

m1LLo

Osnabrücker Reinette
Registriert
29.05.10
Beiträge
991
@mattw Bitte editieren deinen Code Ausschnitt im ersten Beitrag.
 

mattwill

Erdapfel
Registriert
02.04.16
Beiträge
4
Code:
on run {input, parameters}
    -- 
    delay 1.613532
    set timeoutSeconds to 2.000000
    set uiScript to "click UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Queue-Ansicht\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- 
    delay 5.498363
    set timeoutSeconds to 2.000000
    set uiScript to "click group 18 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Queue-Ansicht\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- ⌘C drücken
    delay 0.199749
    set timeoutSeconds to 2.000000
    set uiScript to "keystroke \"c\" using command down"
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Auf die URL „Inhalt“ klicken.
    delay 5.150694
    set timeoutSeconds to 2.000000
    set uiScript to "click static text 1 of UI Element \"Inhalt\" of group 10 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Queue-Ansicht\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Auf die URL „Freie Felder“ klicken.
    delay 2.194377
    set timeoutSeconds to 2.000000
    set uiScript to "click static text 1 of UI Element \"Freie Felder\" of group 5 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"OTRS :: Ticket :: Inhalt :: 2016040210001109\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Auf den Titel „<fill in title>“ klicken.
    delay 2.912435
    set timeoutSeconds to 2.000000
    set uiScript to "click radio button 1 of tab group 1 of window \"OTRS :: Ticket :: Freie Felder :: 2016040210001109\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Auf das Textfeld klicken.
    delay 1.132129
    set timeoutSeconds to 2.000000
    set uiScript to "click text field 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Subscriptions\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- ⌘V drücken
    delay 1.112045
    set timeoutSeconds to 2.000000
    set uiScript to "keystroke \"v\" using command down"
    my doWithTimeout( uiScript, timeoutSeconds )

    -- „015202480698“ in das Textfeld eingeben.
    delay 0.927076
    set timeoutSeconds to 2.000000
    set uiScript to "click text field 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Subscriptions\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Löschen drücken
    delay 0.885039
    set timeoutSeconds to 2.000000
    set uiScript to "keystroke \"\" "
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Typ '49'
    delay 0.504069
    set timeoutSeconds to 2.000000
    set uiScript to "keystroke \"49\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- „4915202480698“ in das Textfeld eingeben.
    delay 1.647039
    set timeoutSeconds to 2.000000
    set uiScript to "click text field 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Subscriptions\" of application process \"Safari\""
    my doWithTimeout( uiScript, timeoutSeconds )

    -- ⌥X drücken
    delay 0.456013
    set timeoutSeconds to 2.000000
    set uiScript to "keystroke \"≈\" using option down"
    my doWithTimeout( uiScript, timeoutSeconds )

    -- Löschen drücken
    delay 2.864205
    set timeoutSeconds to 2.000000
    set uiScript to "keystroke \"\" "
    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
 

mattwill

Erdapfel
Registriert
02.04.16
Beiträge
4
Hat jemand eine Idee? Eigentlich müsste doch nur immer die Zwischenablage gefüllt und wieder eingefügt werden, oder? Ich kenne mich mit Automator oder Apple Script leider noch überhaupt nicht aus, daher wäre ich dankbar für Eure Hilfe. Der Name des Kunden soll aus einem Webinterface (OTRS-Ticketsystem) kopiert und in ein anderes Interface eingegeben werden. Eigentlich immer nur copy/paste. Dann soll davor immer "Herr" geschrieben werden.

Schönen Sonntag

Grüße
 

Pill

Adams Parmäne
Registriert
07.07.12
Beiträge
1.310
Du kannst die Zwischenablage auslesen oder füllen mit get the clipboard oder set the clipboard to "text".