Ok I modify this script a bit, so I could take text on a html page and copy it to a txt docuemnt and put it on the desktop. But my question is, How can i get it to save it in BBEdit, because I need a special “Unix” format instead of it being saved in the regualr txt files. I tried a bunch of things, and still failed, well thanks for the help.
tell application "System Events"
tell application process "Internet Explorer"
delay 250
tell window 1
keystroke "a" using command down
keystroke "c" using command down
end tell
end tell
end tell
delay 3 --> Seems to help
(* Define the file contents and write the file *)
tell me
activate
set theFileContents to the clipboard
end tell
set theTargetFile to (((path to desktop) as string) & "ConnectND") as file specification
try
open for access theTargetFile with write permission
set eof of theTargetFile to 0
write (theFileContents) to theTargetFile starting at eof
close access theTargetFile
on error
try
close access theTargetFile
end try
end try
P.S I forgot to tell yeah, is it also possiable, to have it so you dont see BBEdit pop up with a new page, it just puts the data in there and puts it on your desktop, just like how it dumps it as a txt file on your desktop.
Ok this is what I figured out my self, for now its close enough, even though I didnt want BBEdit to pop up, just run in the background, but here it is:
tell application "System Events"
tell application process "Internet Explorer"
delay 250
tell window 1
keystroke "a" using command down
keystroke "c" using command down
end tell
end tell
end tell
delay 3 --> Seems to help
(* Define the file contents and write the file *)
tell me
activate
set theFileContents to the clipboard
end tell
tell application "BBEdit 6.5"
activate
tell application "System Events"
tell application process "BBEdit 6.5"
delay 20
tell window 1
keystroke "v" using command down
end tell
end tell
end tell
save document 1 to (((path to desktop) as string) & "ConnectND")
try
open for access theTargetFile with write permission
set eof of theTargetFile to 0
write (theFileContents) to theTargetFile starting at eof
close access theTargetFile
on error
try
close access theTargetFile
end try
end try
end tell
try
tell application "Internet Explorer" to quit
tell application "BBEdit 6.5" to quit
end try
Oh I should prob. put the whole thing up, this couldnt of been done without these guys. I still have more commenting to put in here, and a lot of other crap, but thanks again guys for all your help, and I will make sure I will donate the money to you guys. Thanks. Also I will posts it up one more time, after I have the script done 100%, so for all of you who need to do the same thing I needed to do.
try
tell application "Internet Explorer" to quit
tell application "BBEdit 6.5" to quit
end try
delay 15
tell application "Internet Explorer"
Activate
GetURL ("http://studentadmin.connectnd.us:8080/psp/NDPP84/EMPLOYEE/NDSP80/e/?url=http%3a%2f%2fstudentadmin.connectnd.us%3a80%2fservlets%2ficlientservlet%2fNDSP80%2f%3fICType%3dPanel%26Menu%3dCOMMUNITY_ACCESS%26Market%3dGBL%26PanelGroupName%3dCLASS_SEARCH" as string)
my waitLoaded()
do script "
with (frames['TargetContent']) {
main.CLASS_SRCH_WRK2_INSTITUTION.selectedIndex = 5;
main.CLASS_SRCH_WRK2_STRM.value = '0430';
submitAction_main(document.main,'CLASS_SRCH_BASIC');
}
" window (item 1 of (get ListWindows))
my waitLoaded()
do script "
with (frames['TargetContent']) {
main.CLASS_SRCH_WRK2_CAMPUS.selectedIndex = 1;
submitAction_main(document.main,'CLASS_SRCH_WRK2_CLASS_SRCH_PB');
}
" window (item 1 of (get ListWindows))
my waitLoaded()
with timeout of (30 * minutes) seconds
do script "
with (frames['TargetContent']) {
submitAction_main(document.main, '#ICOK');
}
" window (item 1 of (get ListWindows))
end timeout
end tell
to waitLoaded()
tell application "Internet Explorer"
repeat
delay 3
if (do script "frames['TargetContent'].document.readyState" window (item 1 of (get ListWindows))) = "complete" then exit repeat
end repeat
end tell
end waitLoaded
tell application "System Events"
tell application process "Internet Explorer"
delay 250
tell window 1
keystroke "a" using command down
keystroke "c" using command down
end tell
end tell
end tell
delay 3 --> Seems to help
(* Define the file contents and write the file *)
tell me
activate
set theFileContents to the clipboard
end tell
tell application "BBEdit 6.5"
activate
tell application "System Events"
tell application process "BBEdit 6.5"
delay 20
tell window 1
keystroke "v" using command down
end tell
end tell
end tell
save document 1 to (((path to desktop) as string) & "ConnectND")
try
open for access theTargetFile with write permission
set eof of theTargetFile to 0
write (theFileContents) to theTargetFile starting at eof
close access theTargetFile
on error
try
close access theTargetFile
end try
end try
end tell
try
tell application "Internet Explorer" to quit
tell application "BBEdit 6.5" to quit
end try
[/quote]
You don’t need to use GUI-scripting (blech!) to get the page’s text and put it into BBEdit. IE (believe it or not) and BBEdit are both very scriptable. Here’s how to get the text of a page in IE and put it into an existing window in BBEdit:
tell application "Internet Explorer"
set pageText to do script "document.body.innerText"
end tell
tell application "BBEdit"
set text of window 1 to text of window 1 & pageText
activate
end tell
No need to change the clipboard, make BBEdit come to front, etc. You can have BBEdit make a new window, or whatever else, as well.