Supportvragen Mac > Programmeren in bijvoorbeeld C(++), Cocoa, Java, BASIC, en Swift
Simpel script nodig tussen CRM applicatie en VoIP software
mcmt:
Probeer eens
--- Code: ---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
--- Einde van code ---
(volgens ShaneStanley in deze link).
Cenobyte:
Ik had zelf deze al in elkaar gedokterd en die lijkt nu te werken!
Bedankt voor het duwtje in de goede richting :thumbs-up:
--- Code: ---use scripting additions
use 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 result
end run
on 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 try
end writeTextToFile
--- Einde van code ---
het ModeratorTeam:
van het ModeratorTeam De titel van dit draadje is aangepast (was “Simpel script nodig”), zodat het duidelijker is waar het om gaat en beter vindbaar is.
Jakko W:
--- Citaat van: Cenobyte, 23 juni 2023 - 11:21 ---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.
--- Einde van citaat ---
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!):
--- Code: ---on run
do shell script "echo \"" & args &"\" > \"/Users/mariovanginneken/Library/Application Support/Comos/wieheeftgebeld.txt\""
end run
--- Einde van code ---
Cenobyte:
--- Citaat van: Jakko W, 23 juni 2023 - 19:38 ---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!):
--- Einde van citaat ---
Nee, een AppleScript zelf kon ik niet aanroepen, alleen een gecompilede versie ervan ("Exporteer als app"). Blijkbaar gelden er dan ook ineens andere regels, dus moest ik de manier met NSProcessInfo toepassen en dat werkte wel, na enkele uren knutselen :withstupid:
Navigatie
[0] Berichtenindex
[#] Volgende pagina
[*] Vorige pagina
Naar de volledige versie