applescript

applescript get only file name of a folder

对着背影说爱祢 提交于 2019-12-11 13:22:43
问题 I have the following script that list the contents (files and folder) of a folder set the_files to (list folder (choose folder) without invisibles) e.g folder root has a file text1.txt and folders subroot2 and subroot3 but how can I get just the file name (only text1.txt) of a folder root (exclude subroot2 and subroot3)? thanks 回答1: tell application "Finder" files of folder (choose folder) -- Finder file objects name of files of folder (choose folder) -- names of files end tell 来源: https:/

AppleScript to create a duplicate of Xcode target

我们两清 提交于 2019-12-11 12:19:44
问题 Is there any way to create a duplicate of target using AppleScript. I am using below code but it shows Error : Xcode got an error: Targets can not be copied. tell application "Xcode" tell active workspace document set firstProject to (get first project) set firstTarget to (get second target of firstProject) tell application "Xcode" to duplicate firstTarget end tell end tell above scripts is for the project that is currently open in Xcode. I have different approach to achieve it but not

Javascript to fill a formatted text field on a web site

北战南征 提交于 2019-12-11 12:16:37
问题 I know virtually nothing about Javascript. By a monkey-see, monkey-do approach I’ve managed to successfully use Javascript within AppleScript/Safari to fill text fields on a web-site using the following command: do JavaScript "document.getElementById('ElementID').value ='TextToEnter';" in document 1 I’ve been able to enter text into all fields except one. The fields that work are labeled as input type="text” . The field that doesn’t work is complex in that the entered text can be formatted

script auto correcting incorrectly when i compile and key down key up not working as well

只愿长相守 提交于 2019-12-11 12:10:35
问题 alright I'm currently having a lot of issues with my applescript editor. currently when ever i do a Key up key down sequence it will always key the letter A. for example. tell application "System Events" key down "u" key up "u" delay 1 end tell this will keystroke A and i don't know why. ^ thats only a minor issue though my big problem is that i want to swap between three different video game applications. They are all a duplicate of the same game. Heres how my basic script goes. tell

Applescript: trim spaces and return line

余生长醉 提交于 2019-12-11 12:05:03
问题 I wrote an AppleScript that returns a random string from a text file delineated by commas: set some_file to "Macintosh HD:Users:Zade:Library:Application Support:Notational Data:Words.txt" as alias set the_text to read some_file as string set the text item delimiters of AppleScript to ", " set the_lines to (every text item of the_text) return some item of the_lines But I now have a text file delineated by new lines instead of commas. And each line begins with anywhere from 0-20 spaces. I want

Sandbox entitlement to script iTunes via NSAppleScript

荒凉一梦 提交于 2019-12-11 12:03:30
问题 I'm trying to script iTunes from NSAppleScript in my Cocoa app in order to add a file to the library. In my entitlements file, I added the following: <key>com.apple.security.scripting-targets</key> <dict> <key>com.apple.itunes</key> <array> <string>com.apple.itunes.library.read-write</string> </array> </dict> I then call the AppleScript like this: var error: NSDictionary? = nil let appleScript = NSAppleScript(source: "tell application \"iTunes\" to add (POSIX file \"\(path)\") to library

Automating InDesign to place italicized text in a new paragraph

一世执手 提交于 2019-12-11 11:52:35
问题 I'm making a book about quotes. Got in the thousands of them. They all apear like this: Patience is a tree whose root is bitter, but its fruit very sweet. Persian proverb And I would like to make them appear like this Patience is a tree whose root is bitter, but its fruit very sweet. Persian proverb So I basically need the program to understand that when the text ends with regular, then have a space and then there is italic the space needs to be converted into a paragraph enter (^p). Don't

How to open a file in subprocess on mac osx

雨燕双飞 提交于 2019-12-11 11:22:04
问题 I want to open a file and wait the execution of next instruction till file is not closed. I followed the link How to open a file on mac OSX 10.8.2 in python python but it didn't work. subprocess.call(['open','-W',FileName]) opens the file in texteditor, but executes next statement only when text-editor is quit from dock forcefully, even though I closed the opened file.Means, it should execute next statement only when file is closed, and then texteditor should automatically quit from dock. I

Applescript to check if files exist

China☆狼群 提交于 2019-12-11 10:58:53
问题 I want to check if any of particular files (dictionaries) exist in "/Library/Dictionaries/". Here is my Applescript code lines: tell application "Finder" try set theFolder to ("/Library/Dictionaries/") set fileNames to {"dict1.dictionary", "dict2.dictionary", "dict3.dictionary", "dict_n.dictionary"} on error set fileNames to false end try if fileNames is not false then try display dialog "You have already got the dictionary." end try end if end tell Weirdly, the message You have already got

How do I interprete a record returned as a NSAppleScript result

£可爱£侵袭症+ 提交于 2019-12-11 10:53:24
问题 I run an applescript from an objective-c application using NSAppleScript the executeAndReturnError method. This returns an NSAppleEventDescriptor object containing the result of the script. My script returns an applescript record. How do interpret the record in objective-c? For instance if the returned script record is { name:"Jakob", phone:"12345678" } how do I get the string "Jakob" in the name property? 回答1: Here's a method to convert the record to a dictionary. Note that I didn't try this