O.rka
O.rka

Reputation: 30757

Applescript to input text in website

set query to text returned of (display dialog "Enter Query" default answer "" buttons {"Input", "Cancel"} default button 1)

open location "http://www.soundcloud.com/"
delay 1
tell application "System Events"
    key code 48
end tell
delay 1
query

So i'm trying to make an applescript that:

1) Prompts with dialogue box to enter data

2) Opens up webpage

3) Presses tab to get to first text box

4) Pastes data from step 1

I've figured out how to get to up to step 4 but when i print the query variable it only prints it within the applescript not the webpage.

Upvotes: 0

Views: 5043

Answers (2)

O.rka
O.rka

Reputation: 30757

set query to text returned of (display dialog "Enter Query" default answer "" buttons {"Input", "Cancel"} default button 1)

open location "http://www.soundcloud.com/"
delay 1
tell application "System Events"
    key code 48
    delay 1
    keystroke query
end tell

I needed to add keystroke into the commandline

Upvotes: 1

adayzdone
adayzdone

Reputation: 11238

Try this instead:

set query to text returned of (display dialog "Enter Query" default answer "" buttons {"Input", "Cancel"} default button 1)

tell application "Safari"
    if not (exists document 1) then reopen
    activate
    set URL of document 1 to "http://rna.tbi.univie.ac.at/cgi-bin/RNAfold.cgi"
    delay 3
    do JavaScript "document.getElementsByName('SCREEN')[0].value=" & quoted form of query & "" in document 1
end tell

Upvotes: 0

Related Questions