use scripting additionson run args set the text item delimiters to linefeed try set theArgs to quoted form of args as text on error set theArgs to "error" end try set this_story to theArgs & return & ((current date) as string) & return set theFile to ((("Macintosh HD:Users:mariovanginneken:Library:Application Support:Comos:") as string) & "wieheeftgebeld.txt") writeTextToFile(this_story, theFile, true)end runon writeTextToFile(theText, theFile, overwriteExistingContent) try -- Convert the file to a string set theFile to theFile as string -- Open the file for writing set theOpenedFile to open for access file theFile with write permission -- Clear the file if content should be overwritten if overwriteExistingContent is true then set eof of theOpenedFile to 0 -- Write the new content to the file write theText to theOpenedFile starting at eof -- Close the file close access theOpenedFile -- Return a boolean indicating that writing was successful return true -- Handle a write error on error -- Close the file try close access file theFile end try -- Return a boolean indicating that writing failed return false end tryend writeTextToFile
echo "%telefoonnummer%" > "/Users/mariovanginneken/Library/Application Support/Comos/wieheeftgebeld.txt"
use framework "Foundation"use scripting additionson run set the text item delimiters to linefeed set arguments to (current application's NSProcessInfo's processInfo's arguments) as list if first item of arguments contains "osascript" then set arguments to rest of arguments -- skip osascript path if (count arguments) is 1 then set end of arguments to "no arguments" repeat with anItem in rest of arguments -- skip the main executable path set theArgs to quoted form of anItem as text set this_story to theArgs & return & ((current date) as string) & return set theFile to (path to home folder as text) & "Library:Application Support:Comos:wieheeft1.txt" writeTextToFile(this_story, theFile, true) --display dialog this_story --display dialog theFile end repeat # osascript still returns the last resultend runon writeTextToFile(theText, theFile, overwriteExistingContent) try -- Convert the file to a string set theFile to theFile as string -- Open the file for writing set theOpenedFile to open for access file theFile with write permission -- Clear the file if content should be overwritten if overwriteExistingContent is true then set eof of theOpenedFile to 0 -- Write the new content to the file write theText to theOpenedFile starting at eof -- Close the file close access theOpenedFile -- Return a boolean indicating that writing was successful return true -- Handle a write error on error -- Close the file try close access file theFile end try -- Return a boolean indicating that writing failed return false end tryend writeTextToFile
on writeTextToFile(theText, theFile, overwriteExistingContent) try ... -- Open the file for writing tell current application set theOpenedFile to open for access file theFile with write permission end tell ...end writeTextToFile
use scripting additionsuse framework "Foundation"on run set the text item delimiters to linefeed set arguments to (current application's NSProcessInfo's processInfo's arguments) as list if first item of arguments contains "osascript" then set arguments to rest of arguments -- skip osascript path if (count arguments) is 1 then set end of arguments to "no arguments" repeat with anItem in rest of arguments -- skip the main executable path set theText to anItem as text set filename to "wieheeftgebeld.txt" set thepath to (path to home folder as text) & "Documents:" set myFile to thepath & filename writeTextToFile(theText, myFile) --display dialog this_story --display dialog theFile end repeat # osascript still returns the last resultend runon writeTextToFile(theText, theFilew) try -- Convert the file to a string set theFilew to theFilew as string -- Open the file for writing set theOpenedFile to open for access theFilew with write permission -- Clear the file if content should be overwritten set eof of theOpenedFile to 0 -- Write the new content to the file write theText to theOpenedFile starting at eof -- Close the file close access theOpenedFile -- Return a boolean indicating that writing was successful return true -- Handle a write error on error -- Close the file try close access file theFile end try -- Return a boolean indicating that writing failed return false end tryend writeTextToFile
Ik had die methode ook al geprobeerd inderdaad en vanuit Terminal werkt die, maar het probleem is dat de VOIP software volgens mij alleen een applicatie toestaat en daarbij een argument.
on rundo shell script "echo \"" & args &"\" > \"/Users/mariovanginneken/Library/Application Support/Comos/wieheeftgebeld.txt\""end run
Maar een AppleScript kun je wel aanroepen? Dan kun je een heel eenvoudig AppleScript maken dat niet veel meer doet dan (let op: dit is niet getest!):
import Foundationlet homeURL = FileManager.default.homeDirectoryForCurrentUserlet commandURL = URL(fileURLWithPath: "Desktop/LogCallerID.app/Contents/MacOS/applet", relativeTo: homeURL)//let commandURL = URL(fileURLWithPath: "Desktop/LogCallerID.sh", relativeTo: homeURL)for i in 1...100 { try Process.run(commandURL, arguments: ["callerid: \(i)"]).waitUntilExit()}
#!/bin/shecho $1 > ~/Desktop/CallerIDLog.txt