Hiding Program Actions in Backround

Discussion in 'Mac Programming' started by thriftinkid, Jan 14, 2009.

  1. thriftinkid macrumors regular

    Joined:
    Mar 24, 2008
    #1
    I need the actions of the program my applescript is running not to appear on screen.

    Such as:

    1. Open Text Edit
    2. Create New Text Doc
    3. Add Text
    4. Save Document as "Doc Name"
    5. Quit Text Edit

    I know not using the command "Activate" will run the program in the backround, and 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.

    Thanks again as usual in advance guys.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Does the file need to be rich text? Could it just be plain text? If you just need to create a plain text file with some particular contents, you could just do this with a command like:
    Code:
    echo "Some text for my file" > /Users/yourname/Desktop/newfile.txt
    
    Otherwise I don't know if you could tell textedit to hide as soon as you open the document, etc. I'm not too familiar with applescript, but that would be the direction i would take if you need a rich text document saved.

    -Lee
     
  3. thriftinkid thread starter macrumors regular

    Joined:
    Mar 24, 2008
    #3
    Here is a quick basic applescript idea of what I want to do on a very small scale. I just don't know where to insert your echo command.


    Code:
    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
     

Share This Page