Post

Replies

Boosts

Views

Activity

Reply to External drives reported as "lifs"
I have encountered the same problem on Ventura 13.0.1. As a workaround I've used DiskArbitration, which seems to report file system correctly: #include <DiskArbitration/DiskArbitration.h> DASessionRef session = DASessionCreate(kCFAllocatorDefault); CFURLRef mpURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/Volumes/NO NAME/"), kCFURLPOSIXPathStyle, YES); DADiskRef diskRef = DADiskCreateFromVolumePath(kCFAllocatorDefault, session, mpURL); CFDictionaryRef description = DADiskCopyDescription(diskRef); NSDictionary* diskInfo = (__bridge NSDictionary *)description; NSLog(@"%@", [diskInfo valueForKey:@"DAVolumeKind"]);
Nov ’22
Reply to How would I Activate a window using its Window index on applescript?
It looks like Visual Studio Code doesn't have an AppleScript dictionary, so perhaps use System Events? tell application "System Events" tell process "Code" -- selecting window to raise by its title, modify as needed set w to item 1 of (windows whose title is "Untitled-1") perform action "AXRaise" of item 1 of w end tell activate application "Visual Studio Code" end tell
Jan ’23
Reply to [Applescript] set miniatured property failed
You are not addressing some generic "window" class, but different "window" classes belonging to a different processes, which just happen to have the same name. They may have different properties and actions. Take a look at those applications' respective dictionaries (cmd+shift+o in the Script Editor) and you'll notice "miniaturized" is in Safari dictionary, but not in Finder dictionary, for example. You can have consistency across the applications if you use "System Events" to minimize the windows: tell application "System Events" to set the value of attribute "AXMinimized" of window 1 of process "Finder" to true
May ’23
Reply to Run a python script as a quick action in finder on selected folder
I would suggest utilising AppleScript to do it. In Shortcuts you can add the action "Run Applescript" to change directory before calling python script. See the following example: on run {input, parameters} set mPath to "" try tell application "Finder" to set mPath to quoted form of POSIX path of ((get target of front window) as alias) end try set outputString to do shell script "cd " & mPath & "; python3 -c 'import os; print(os.getcwd())'" return outputString end run You can also execute AppleScript commands directly from Python using osascript: import subprocess subprocess.run(['/usr/bin/osascript', '-e', 'try', '-e', 'tell application "Finder" to set mPath to quoted form of POSIX path of ((get target of front window) as alias)', '-e', 'end try'])
Mar ’24
Reply to Help with a script to automate data entry
It would be much easier to debug if you provided your document, your explanation of what you are trying to achieve is not super clear to me. I assume you start with no data in sheet 2 and you don't care that I'm overwriting data in sheet 2 - is this true? Anyway, please go through this code and read the comments. It takes maybe 2-3 minutes on my computer to finish the script. tell application "Numbers" activate -- the following code is just to show you how do I think your document looks like make new document tell front document -- there should already be one sheet, let's rename it to GAMES set name of active sheet to "GAMES" -- create sheet TRIALS2 -- this should also create table 1 make new sheet set name of active sheet to "TRIALS2" -- making sure table 1 has at least 67 rows, otherwise we cannot access row 67 if (row count of table 1 of sheet "GAMES" < 67) then set row count of table 1 of sheet "GAMES" to 67 end if -- making sure table 1 has at least 2 columns, otherwise we cannot access column B if (column count of table 1 of sheet "GAMES" < 2) then set column count of table 1 of sheet "GAMES" to 2 end if -- inserting some value into cell B67 set value of cell "B67" of table 1 of sheet "GAMES" to random number end tell -- this is when to start if you already have "GAMES" and "TRIALS" set up tell front document -- we need 2003 rows because we do 2000 repeats set row count of table 1 of sheet "TRIALS2" to 2003 repeat with rowNumber from 3 to 2003 -- copy value of one cell to another -- target for copy operation is cell A3, A4, A5...A2003 set value of cell ("A" & (rowNumber as text)) of table 1 of sheet "TRIALS2" to (value of cell "B67" of table 1 of sheet "GAMES") -- generate new random value in cell B67 set value of cell "B67" of table 1 of sheet "GAMES" to random number end repeat end tell end tell
Mar ’24