Selbstgeschriebener Bot funktioniert nicht.

M

MrHttps

Registriert
Thread Starter
Dabei seit
26.04.2021
Beiträge
3
Reaktionspunkte
0
Hallo,

dies ist nicht nur mein erster Beitrag/Frage, sondern auch mein erstes selbstgeschriebenes Apple Script. Ich bin in dem Bereich relativ neu, habe aber mal versucht ein script zu schreiben, welches Spam nachrichten auf WhatsApp verschickt. Selbstverständlich dient dieses Programm nur für private, legale Lernzwecke. Nun habe ich ein Problem, an dem ich nicht weiterkomme.

AppleScript:
display dialog "Wie viele Nachrichten möchtest du senden?" with title "WhatsappBot" buttons {"Weiter", "Abbrechen"} default button 1 default answer "10"
set theNum to text returned of the result
display dialog "Was möchtest du " & theNum & " mal sagen?" with title "WhatsappBot" buttons {"Weiter", "Abbrechen"} default button 1 default answer ""
set theMessage to text returned of the result
display dialog "Wem möchtest du " & theNum & " mal " & theMessage & " schreiben?" with title "WhatsAppBot" buttons {"Starten", "Abbrechen"} default button 1 default answer ""
set theTarget to text returned of the result
tell application "Safari"
    activate
    tell window 1
        set current tab to (make new tab with properties {URL:"https://web.whatsapp.com"})
    end tell
end tell
delay 5
tell application "Safari" to activate
tell application "System Events"
    tell process "Safari"
        key code 9
    end tell
end tell
tell application "Safari" to activate
tell application "System Events"
    tell process "Safari"
        keystroke theTarget
    end tell
end tell
tell application "Safari" to activate
tell application "System Events"
    tell process "Safari"
        key code 76
    end tell
end tell
repeat theNum times
    tell application "Safari" to activate
    tell application "System Events"
        tell process "Safari"
            keystroke theMessage
        end tell
    end tell
    tell application "Safari" to activate
    tell application "System Events"
        tell process "Safari"
            delay 0.1
            key code 76
        end tell
    end tell
end repeat



--ERKLÄRUNG: Es ist eigentlich ganz simple, Man gibt die Anzahl der nachrichten an, was man schicken möchte und an wen. Für Verbesserungen bin ich offen. (Ich habe auch schon versucht statt der Tab Taste mit der maus an die richtige stelle klicken zu lassen, hat aber auch nicht funktioniert)
 
Keystroke Dinger sind immer Gebastel. Wenn man Webseiten manipulieren will ist php oder Java unumgänglich. Habe aber mal Dein Script etwas bereinigt:
Code:
set theNum to text returned of (display dialog "Wie viele Nachrichten möchtest du senden?" with title "WhatsappBot" buttons {"Weiter", "Abbrechen"} default button 1 default answer "10")
set theMessage to text returned of (display dialog "Was möchtest du " & theNum & " mal sagen?" with title "WhatsappBot" buttons {"Weiter", "Abbrechen"} default button 1 default answer "")
set theTarget to text returned of (display dialog "Wem möchtest du " & theNum & " mal " & theMessage & " schreiben?" with title "WhatsAppBot" buttons {"Starten", "Abbrechen"} default button 1 default answer "")
tell application "Safari" to tell window 1 to set current tab to (make new tab with properties {URL:"https://web.whatsapp.com"})
delay 5
tell application "System Events" to  tell process "Safari"
        key code 9
end tell
tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
        keystroke theTarget
end tell
tell application "Safari" to activate
tell application "System Events" to  tell process "Safari"
        key code 76
end tell
repeat theNum times
    tell application "Safari" to activate
    tell application "System Events"  to  tell process "Safari"
            keystroke theMessage
    end tell
    tell application "Safari" to activate
    tell application "System Events"  to  tell process "Safari"
            delay 0.1
            key code 76
    end tell
end repeat
 
  • Gefällt mir
Reaktionen: mausfang
Gelöst:
AppleScript:
Keystroke tab
 
Zurück
Oben Unten