Hi,
In order to automatise some entries, I would like to fill a form automatically on my web page. To do so, I extract the text I want to past in from textedit, ues some tabs and then … I do not know how to “paste” my text in !:rolleyes:
Sorry to be so new at this but if you could help, I would be really grateful !!!
Here is what I have so far :
tell application "TextEdit"
set a to text of document 1
end tell
set delim to {"Image.id="}
set TID to text item delimiters
set valueList to {}
repeat with i in delim
set text item delimiters to i
set end of valueList to word 1 of text item 2 of a
end repeat
set text item delimiters to TID
valueList
tell application "Safari"
activate
end tell
tell application "System Events"
keystroke tab
keystroke tab
at the end, I just need to "paste in"valueList ! sounds easy but I do not manage !!!
thanks for any help !!!
Try this (using System Events):
keystroke "v" using command down
Hi and thanks for the fast answer !
Unfortunately, either I am too stupid or there is something wrong : I just added the suggested “keystroke “v” using command down” at the end of my scrip and it just past it “keystroke “v” using command down” in the field instead of pasting the value from “valueList”…
any more idea ???
here is where I am :
tell application "TextEdit"
set a to text of document 1
end tell
set delim to {"Image.id="}
set TID to text item delimiters
set valueList to {}
repeat with i in delim
set text item delimiters to i
set end of valueList to word 1 of text item 2 of a
end repeat
set text item delimiters to TID
valueList
tell application "Safari"
activate
end tell
tell application "System Events"
keystroke tab
keystroke tab
keystroke "v" using command down
end tell
patimages,
There might be a better way to do this using javascript. Please post your html source code from the form you are trying to post to. If you don’t know how to get the source of a page in Safari you can simply right click and select view source or under the view menu select view source. Select all and paste here.
CarbonQuark
patimages, you never change the clipboard in your script (that’s what gets pasted).
Try something like this:
set ASTID to AppleScript's text item delimiters
try
tell application "TextEdit" to set sourceText to text of document 1
set AppleScript's text item delimiters to "Image.id="
set the clipboard to word 1 of text item 2 of sourceText
set AppleScript's text item delimiters to ASTID
tell application "Safari" to activate
tell application "System Events"
keystroke tab & tab
keystroke "v" using command down
end tell
on error errMsg number errNum
set AppleScript's text item delimiters to ASTID
display dialog "Error " & errNum & return & return & errMsg with icon caution buttons {"Cancel"} default button 1
end try
Also, CarbonQuark’s idea will probably work better if you can figure that out.