Re: System Events - Property Lists
Dave
Ok, I now think it IS because I don’t have a Property List File Object, Creation: set myParentDictionary to make new property list item with properties {kind:record} — File Object in set myPropertyListFile to make new property list file with properties {contents:myParentDictionary, name:pMWLPrefsFilePOSIXPath of me} tell application "System Events" tell property list file pPrefsFileObject of me set pModOrderFileURL of me to value of property list item "pModOrderFileURL" set pModOrderList of me to value of property list item "pModOrderList" set pModInfoList of me to value of property list item "pModInfoList" end tell end tell —Test Reading Back here, works ok tell property list file myPropertyListFile of me set pModOrderFileURL of me to (value of property list item "pModOrderFileURL") set pModOrderList of me to value of property list item "pModOrderList" set pModInfoList of me to value of property list item "pModInfoList" end tell It does this if it doesn’t find a prefs file, to create one. Then of subsequent Run of the Script I want to restore them: — — This doesn’t work since I’m passing the File Path String instead of a File Object -- tell application "System Events" tell property list file pMWLPrefsFilePOSIXPath of me set pModOrderFileURL of me to (value of property list item "pModOrderFileURL") set pModOrderList of me to value of property list item "pModOrderList" set pModInfoList of me to value of property list item "pModInfoList" end tell end tell But I don’t have the File Object that was around (myPropertyListFile) when it was created. So, given the file on the disk, how to I get a new a File Object? I am assuming you can read back the file?!?!? It doesn’t actually say you can, it would be typical of Apple to give you something to write a property list but not give you one to read it back again, and when it comes to AppleScript it wouldn’t surprise me in the least. Fed up with poor documentation….. All the Best Dave
|
|
|
|
Re: System Events - Property Lists
Dave
Hi,
it doesn’t look if it is:
Since it accepts a property list. I can write it ok and look at the file in XCode, however when I come to read back the values it gives error: value of property list item "pModOrderFileURL" of property list file "/Users/surfacedetail/Documents/MWL/MWLPrefs/MWLPrefs.plist” Its like it doesn’t release that “value” is a property of the Object. This is confusing, should it be a Property File Object or a File Path? Or can it be either. I can’t find any documentation on this and hardly any examples. The one decent example I found does it this way. I’ve been stuck on this for over 2 hours and can’t fathom what it needs to make it happy! I really loath this aspect of apple script poor docs, unhelpful error message and no support (except places like this). Oh well, could be worse I suppose. Thanks in advance for any suggestions. All the Best Dave
|
|
|
|
System Events - Property Lists
Dave
Hi All,
I have a question about the System Events Property List Suite. I have code to setup a property list file and it seems to work ok. It creates it and sets it to the initial values: set myParentDictionary to make new property list item with properties {kind:record} set myPropertyListFile to make new property list file with properties {contents:myParentDictionary, name:pMWLPrefsFilePOSIXPath of me} tell property list items of myPropertyListFile make new property list item at end with properties {kind:string, name:"pModOrderFileURL", value:pModOrderFileURL of me} make new property list item at end with properties {kind:list, name:"pModOrderList", value:pModOrderList of me} make new property list item at end with properties {kind:list, name:"pModInfoList", value:pModInfoList of me} end tell To update values to: on SetPersistentValue(thePropertyName, theValue) tell application "System Events" tell property list file (pMWLPrefsFilePOSIXPath of me) set value of property list item thePropertyName to theValue end tell end tell end SetPersistentValue This all work ok (or seems to), however when I come to restore the values: tell application "System Events" tell property list file pPrefsFileObject of me set pModOrderFileURL of me to value of property list item "pModOrderFileURL" set pModOrderList of me to value of property list item "pModOrderList" set pModInfoList of me to value of property list item "pModInfoList" end tell end tell I get an error: value of property list item "pModOrderFileURL" of property list file "/Users/surfacedetail/Documents/MWL/MWLPrefs/MWLPrefs.plist”. I’m guessing its because it expects a Property List File Object, not a Path String, however I’m at a loss as to know how to get this object, when it was created I was making a new file, but now I want to reference the same file, bet I can’t find a way of objecting the Object for an existing plist file. Any help greatly appreciated. All the Best Dave
|
|
|
|
Re: Testing the list
Jean-Christophe Helary <jean.christophe.helary@...>
Yes it is.
On Apr 28, 2020, at 22:31, Steve Mills via groups.io <sjmills@...> wrote: Jean-Christophe Helary ----------------------------------------------- http://mac4translators.blogspot.com @brandelune
|
|
|
|
Re: Testing the list
Willis Grant
Yep
From: applescript@apple-dev.groups.io <applescript@apple-dev.groups.io> on behalf of Steve Mills via groups.io <sjmills@...>
Sent: Tuesday, April 28, 2020 9:31 AM To: AppleScript List <applescript@apple-dev.groups.io> Subject: [applescript] Testing the list Is this thing on?
-- Steve Mills Drummer, Mac geek
|
|
|
|
Re: Help with POSIX File/Folder Paths
Dave
I posted this a few days ago, I’ve sorted it out now, took a while for my brain to re-enter AppleScript Mode!
toggle quoted messageShow quoted text
|
|
|
|
Testing the list
Steve Mills
Is this thing on?
-- Steve Mills Drummer, Mac geek
|
|
|
|
Re: Help with POSIX File/Folder Paths
Dave
Opps, found a typeo: Folder actually looks like this: Test1.tp2 Test1 (Folder) Test2.tp2 Test3.tp2 Test4.tp2 Test4 (Folder) and the return should be: myFileList: Test1.tp2, Test4.tp2 myFolderList: Test1,Test4
|
|
|
|
Help with POSIX File/Folder Paths
Dave
Hi, I’m modifying a large existing script. The Script does a lot of File Munging and passes things around as POSIX file/folder paths. I haven’t done any AppleScript in a very long time and I don’t have access to my past work. I know I have done this before but I just can’t remember what the trick is! Basically I want to scan a Folder and check if: There is a file with a “.to2” (or specified) extension and if so, check if there is also a folder of the same name and if there is, add the Full POSIX file path to one list and the Full POSIX Folder path to another. So, if we have a base folder of " /Users/xxxxxxxx/Desktop/Dave's Mock Folder/“, my functions get passed this Folder string. If it contained the Following files: Test1.txt Test1 (Folder) Test2.txt Test3.txt Test4.txt Test4 (Folder) then return should be: myFileList: Test1.txt, Test4.txt myFolderList: Test1,Test4 I’ve got it to almost work in test form below, but the check for the existence of the folder always report true - see comment below. Any help greatly appreciated! Thanks Dave tell application "Finder" set mySaveASDelimiters to AppleScript's text item delimiters set myScriptFilePath to (path to me) set mySourceFolder to folder of myScriptFilePath set mySourceFolderPathString to mySourceFolder as string set myPOSIXSourceFolder to my POSIX path of mySourceFolderPathString log "myScriptFilePath: [" & myScriptFilePath & "]" log "mySourceFolder: [" & mySourceFolder & "]" log "mySourceFolderPathString: [" & mySourceFolderPathString & "]" log "myPOSIXSourceFolder: [" & myPOSIXSourceFolder & "]" set myFileAliasList to the entire contents of mySourceFolder log "-----" set myTP2FileList to {} set myTP2FolderList to {} repeat with myFile in myFileAliasList set myTemp to properties of myFile set myFileName to name of myFile if (myFileName starts with "setup-") and (myFileName ends with ".tp2") then set AppleScript's text item delimiters to "." set myTP2FolderName to first text item of myFileName set AppleScript's text item delimiters to "-" set myTP2FolderName to last text item of myTP2FolderName set AppleScript's text item delimiters to mySaveASDelimiters set myTP2FolderPath to myPOSIXSourceFolder & myTP2FolderName as string log "myTP2FolderPath: " & myTP2FolderPath -- — The (exists folder myTP2FolderPath) ALWAYS return true, e.g. I never get a beep/dialog -- tell application "System Events" if not (exists folder myTP2FolderPath) then beep display dialog "Could not find Mod folder for Mod: " & myTP2FolderName return {} end if end tell log "myFileName: " & myFileName log "myTP2FolderName: " & myTP2FolderName set end of myTP2FileList to myFileName set end of myTP2FolderList to myTP2FolderName end if end repeat log "-----" log "myTP2FileList: " & myTP2FileList log "myTP2FolderList: " & myTP2FolderList return myTP2FileList end tell
|
|
|
|
Acrobat and PDF page boxes
rocketjam@...
The following script returns a page box and bleed box even if the PDF it is run on does not contain said boxes.
tell application id "com.adobe.Acrobat.Pro" try set trimSize to get trim box of page 1 of active doc set bleedSize to get bleed box of page 1 of active doc end try end tell Is there a way to have Acrobat tell you if the page boxes are present or not in a PDF? Thanks, RJay
|
|
|
|
Problems accessing properties of "window" class in System Prefences
Ilya Shebalin
Hello,
Whenever I try to refer to properties of the class «window» of Processes Suite "System Events» raises an error despite said properties being part of the dictionary for «window» element. So, even though «visible» is there the line «return visible of window 1 of process TheProcess» (the process is active and has its windows opened) returns «error number -1728 from visible of window 1 of process TheProcess». Now getting the value of the property «properties» returns coherent results but (1) the property is not listed in the Dictionary (2) the set of values it represents doesn’t include all the properties of the class «window» as per the dictionary. What gives?
|
|
|
|
Re: Automator task working with Mail
Takaaki Naganoya
2019/02/06 4:09、Keith Kaiser <wa0tjt@...>のメール:
Welcome to AppleScript Mailing List. You’d better to make “Service” workflow to open fixed URL (https://www.qrz.com/lookup/) and selected string (wa0tjt). I think it is not Mail.app oriented issue. Takaaki Naganoya -- Takaaki Naganoya maro@... http://piyocast.com/as/
|
|
|
|
Automator task working with Mail
Keith Kaiser
I want to select a callsign (short string) in a Mail document, right click it and have it open; https://www.qrz.com/lookup/wa0tjt
the clicked string would be the wa0tjt part. I created a 'Run Shell Script' workflow but I can't figure out how to make use of it in Mail. Would someone please walk me through the procedure to make this work.
|
|
|
|
Re: Dynamic creation of an AppleScript via AppleScript
2551phil
On top of what Chris said, you can also create and run AppleScripts as .sh files. Just write your AppleScript with a shebang targeting osascript: #! /usr/bin/osascript display dialog "hello, world" Best Phil
|
|
|
|
Re: Dynamic creation of an AppleScript via AppleScript
Christopher Stone
On 09/03/2018, at 09:24, Markus Ruggiero <mailinglists@...> wrote:
I want to create an AppleScript .scpt file programmatically without using Script Editor. Hey Markus, Have a look at these two post on the Applescript Users List. -- Best Regards, Chris
osacompile -o <object-file> <source-file> (see the man page)
|
|
|
|
Dynamic creation of an AppleScript via AppleScript
Markus Ruggiero
Hi,
I want to create an AppleScript .scpt file programmatically without using Script Editor. The goal is to have some Apple Script commands in a plain text file to be used as a template. I want to create an AppleScript that should ask the user a couple questions and then use the answers to fill in the "template" and finally save the resulting script to disk. Simplified example: Template.txt contains set theApplication to XXXXX tell application theApplication -- many things.... end tell My script should ask the user for the name of the application, then load the template and replace XXXXX by what the user has given. At the end the result should become a .scpt file on disk. Thanks for any help ---markus---
|
|
|
|
Re: AppleScript script unable to respond to a script statement correctly
Shane Stanley
On 25 Jun 2018, at 12:48 am, Ilya Shebalin <iljashebalin2@...> wrote:
Let's say in one loop itemRef contains a reference to item 3 of RecList. If the loop before called "set RecList to every record of RecList", and item 2 of RecList was not a record, then what was item 4 is now going to be item 3. You can change the contents of items in a list while looping, but you generally shouldn't do anything that might disturb the indexing. -- Shane Stanley <sstanley@...> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
|
|
Re: AppleScript script unable to respond to a script statement correctly
Ilya Shebalin
Could I kindly ask you to elaborate a bit?
toggle quoted messageShow quoted text
24.06.2018, в 5:19, Shane Stanley написал(а):
On 24 Jun 2018, at 12:07 pm, Ilya Shebalin <iljashebalin2@...> wrote:You're redefining the value, and length, of RecList within you loop. That's a recipe for chaos.
|
|
|
|
Re: AppleScript script unable to respond to a script statement correctly
Shane Stanley
On 24 Jun 2018, at 12:07 pm, Ilya Shebalin <iljashebalin2@...> wrote:
You're redefining the value, and length, of RecList within you loop. That's a recipe for chaos. -- Shane Stanley <sstanley@...> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
|
|
AppleScript script unable to respond to a script statement correctly
Ilya Shebalin
Hello,
I wrote a script which re-arranges items in a continuous order. The items are records each containing two properties: text which is a paragraph of the original text and a number which denotes the paragraph's position in the original text. The items are to be ordered by placing them according to the numbered parameter values so that I could easily reverse the order by simply applying reverse property of list class to get the items sorted in a continuous ascending order. The script is as follows: set RecList to {{ParagraphText:"On 18 Jun 2018, at 3:28 pm, Ilya Shebalin <iljashebalin2@...> wrote:", ParagraphPosition:1}, {ParagraphText:"That's how the as \"class utf8\" compiles in ScriptDebugger:", ParagraphPosition:3}, {ParagraphText:"", ParagraphPosition:4}, {ParagraphText:"Type this into a Script Debugger window:", ParagraphPosition:5}, {ParagraphText:"", ParagraphPosition:6}, {ParagraphText:"current date", ParagraphPosition:7}, {ParagraphText:"Compile, then go to the View Menu and choose Show Raw (Chevron) Syntax, and compile again. What do you see now?", ParagraphPosition:9}, {ParagraphText:"", ParagraphPosition:2}, {ParagraphText:"", ParagraphPosition:8}} set NewRecList to {} repeat until RecList is {} repeat with itemRef in RecList if ParagraphPosition of contents of itemRef = (count RecList) then "log (count RecList):" log (count RecList) "log ParagraphPosition of contents of itemRef = (count RecList):" log (ParagraphPosition of contents of itemRef = (count RecList)) set end of NewRecList to contents of itemRef set (contents of itemRef) to missing value --a problem here! "log (contents of ItemRef):" log (contents of itemRef) set RecList to every record of RecList "log RecList:" log RecList "log (count RecList):" log (count RecList) end if end repeat end repeat return {List1:NewRecList, List2:RecList} Notice the log statements. Despite the fact that all statements resolve to true and contains expected values NewRecList contains duplicates of some items leaving alone others whereas the logic does not seemingly imply that. It should assign missing value to an item and consider only records, but it fails for that particular items. Tell me please what mistake I made. Happy day, I.S.
|
|
|