Hiding Applications and Open Files While Running

Is it possible to hide applications and there actions while they are in use by an applescript?

I have an applescript written that requires a few programs to open and close, open new documents, etc. I was wondering if there was any way to hide them while the script is running, so I can continue to use my desktop instead of having windows constantly popping up. I don’t know if I can hide them behind the desktop image or something. Or I might be just dreamin. As usual, thanks in advance guys. You are always most helpful.

Hi,

in Leopard most of the applications can run in the background, if you don’t use the keyword activate in your script

What if I want the actions of the program not to appear on screen as well? Such as:

  1. Open Text Edit
  2. Create New Text Doc
  3. Add Text
  4. Save Doc
  5. Quit Text Edit

I have the script to make Text Edit’s Icon not show up in my toolbar when it is running, but the text document still appears on screen while the applescript is completing the actions.

Consider, that TextEdit is actually not required, if the text is plain text.
AppleScript’s text read/write capabilities are sufficient

How would this basic code be re-written to create the text document without using text edit?

set theText to "I Hate Cold Weather."
tell application "TextEdit"
	if (front document exists) = true then
		if (text of the front document) ≠ "" then
			make new document
		end if
	else
		make new document
	end if
	set the text of the front document to theText
	save the front document in "MacintoshHD:Users:test:desktop:weather opinion.txt"
	quit without saving
end tell

I would read this tutorial.

File read/write

Cheers,

Craig


set theText to "I Hate Cold Weather."
set theDocument to ((path to desktop as text) & "weather opinion.txt")

try
	set ff to open for access file theDocument with write permission
	write theText to ff
	close access ff
on error
	try
		close access file theDocument
	end try
end try

Stefan = Genious.

I have one more question seeing as you are so ridiculously helpful. The next hiccup I have is that this script is supposed to be adding text to a file already created. If the document doesn’t exist, then it should be created. I already wrote the script to check for the file, and as you can see basically create it. My hiccup is that once the script determines that the file exists, I need it to find the last line there is text on, and then insert the newly created text on the next line below. Such as:

Weather Opinion.txt Contents Below:

Text in line 1
Text in line 2
Text in line 3
Text in line 4
(I hate cold Weather)<—New Text Needs to be inserted here

just change this line


.
write theText & return to ff starting at eof
.

if the document doesn’t exist, it will be created
if the document exists the text will be appended,

The return statement is not needed, if the text line contains a carriage return character

Works perfect. Truly opened me to a new world without TextEdit. Thank You.