|
#1
| |||
| |||
| Using Applescript to open a file Hi, I'm trying to use a menu built in Adobe Flash to open a powerpoint file by calling an executable which I'm trying to write in applescript. I've no idea how to do it, and I can't find any tutorials because it's probably such a simple command. When I have tried it with the following line of code: tell application "Finder" activate select file "flyer2.ppt" open selection end tell it brings up a message saying "Finder cannot get file". I've tried being more specific as to the location of the file, but it's pretty much stabbing in the dark. If you could tell me how to write this simple function which allows an executable file to open another file in its native software then I'd be most grateful. Thanks, Ewar |
|
#2
| |||
| |||
| Hi Ewar, You don't even need to bring up the finder to open files using AppleScript, it can be all done in the background with code like follows: Code: set filepath to POSIX path of "DandyDisk:Users:martin:Desktop:test.ppt" try set command to "open " & quoted form of filepath do shell script command end try |
|
#3
| |||
| |||
| Hi Martin, the code that you posted works for opening files on your own computer very well; all you have to do is set the correct path. I too, wish to use applescript to open files. Suppose I made an application with applescript that has a second application nested inside its package contents. I know the application bundle is really just a folder, but I am having difficulty getting the script you supplied to open Quote:
|
|
#4
| |||
| |||
| It's quite easy: Code: -- Mac path to a hidden sript file in the bundle set hiddenscriptpath to (((path to me) as text) & "Contents:Resources:script.app") -- Converting the Mac path to a Posix path set hiddenscriptpath to POSIX path of hiddenscriptpath -- Quoting the Posix path set qtdhiddenscriptpath to quoted form of hiddenscriptpath -- executing the script file try set command to "open " & qtdhiddenscriptpath do shell script command end try |
|
#5
| |||
| |||
| Thanks! Thank you very much! Speaking about the time, I want to be able to track a certain event when a certain people's log onto their computer for a little independent project of mine. Fortunately, iChat has a function where it can alert me by opening an applescript, but I want to be able to generate a text log file where it displays the time of login. I have encountered two problems so far :L First is the actual script. I know it shouldn't be that complicated, but I know how to acquire the date. What I want to do is to paste it into a text document or something of the sort. Here is what I have, but I don't know how I can save a result to the clipboard. In addition, I would prefer using a sticky note instead of TextEdit. Here is my faulty script. Quote:
Sorry for being such a computer-illiterate person |
|
#6
| |||
| |||
| Hi ejang, AppleScript can write into text files, no need to hijack TextEdit for this task. It's quite easy: Code: set curdate to (current date) as string set logmsg to "LOGIN:" & tab & curdate & return set logfilepath to (((path to desktop) as text) & "logins.txt") set logsucess to my log2file(logmsg, logfilepath) on log2file(logmsg, logfilepath) try set logfile to open for access logfilepath with write permission write logmsg to logfile starting at eof close access logfile return true on error try close access logfile end try return false end try end log2file If you want to read and set the clipboard, you can use this code: Code: -- setting the clipboard content set myname to "Martin Michel" set the clipboard to myname -- reading the clipboard content set clipboardcontent to the clipboard Code: set curdate to (current date) as text tell application "TextEdit" activate if not (exists document 1) then set newdoc to make new document end if set text of document 1 to curdate end tell Quote:
|
![]() |
| Bookmarks |
| Thread Tools | |
| |