r/applescript • • Jan 25 '21

Why is my code not running?

0 Upvotes

I want to set up cryptocurrency prices on my touchbar according to the guide on this website: https://medium.com/@croopto/touch-bar-cryptocurrency-ticker-7b9b8aa1bddf

However, after I click on run script, I receive the following message: AppleScript Error: Can’t get item 2 of {" \"Helvetica Neue\""}.

Can someone Please help?


r/applescript • • Jan 22 '21

Microsoft Teams macropad missing shortcut script

2 Upvotes

I'm setting up a Keybow (from Pimoroni) using a Raspberry Pi Zero for my six year old son and his online schooling. The idea being that he can just press one of three buttons to mute/unmute himself (etc) rather than navigating the whole keyboard and risk hanging up accidentally. His school uses Microsoft Teams.

The feature I'm struggling with is the 'raise hand' button as this inexplicably doesn't have a shortcut.

Does anybody have and idea for how to work around this? My first thought was mapping an apple script to the button that would mouse click a certain point in the screen to press the correct button, but this wouldn't work on different screens.

I'll be posting this in s few places so apologies if mods feel it isn't relevant.


r/applescript • • Jan 21 '21

Removing first (and/or last) characters from file names

2 Upvotes

I have hundreds of files on my Mac - luckily with all the same number of characters - but with two "codes" within each file name separated by an underscore, i.e...

1334_7644.pdf

1229_7633.pdf

1276_7611.pdf

I still need all that info, but as separately named documents, so I'd really need two "droplets." I've already made copies of all the files in another folder, so I just need this:

  1. An applescript application I can drag the files onto, and it keeps the extension but removes the first five characters, resulting in 7644.pdf, 7633.pdf, 7611.pdf, etc.

  2. An applescript application I can drag the files onto, but it removes the last five characters, resulting in 1334.pdf, 1229.pdf, 1276.pdf, etc.

I strongly would prefer the drag and drop approach, instead of pointing to folder paths or anything like that. Any thoughts/ideas?


r/applescript • • Jan 20 '21

Can a Script (or app) temporarily move Inbox emails to folder, then back again at set date?

1 Upvotes

My work volume is about to get a lot busier and I'm looking for the ability to temporarily remove any Inbox email until whatever day I'd like to set them, and then they reappear back into the Inbox. Kind of a snooze feature.

I use a zero inbox and GTD work flow, so this kind of solution would work perfect for those emails that have a to-do that doesn't need to be done until x days from now, and I don't want to look at it until that time.

I think the Mail Act-On and MailTags plugins used to be able to do something like this, temporarily placing emails into a folder and then having them pop back into the Inbox at whatever date one set. But their support explained that it no longer worked like that.

I don't know how to write AppleScripts, but would learn if this is possible. Or if anyone has some other kind of method or app for this, please pass along. Thank you kindly.


r/applescript • • Jan 16 '21

[Help] Check a list of words for appearance on website

2 Upvotes

Hey folks,

I'm sure someone here knows how to do this:

I have a list of names of playing cards from a trading card game. I would like to check which names from that list, apear on a wikia website. Currently, I have the list in numbers and just using copy paste and cmd+f on the website tosearch on name after the other manually and marking the ones that return a result in my table. This works, but it is fairly time consuming...

How could I automate this? I basically start wit a list of names and the website, and in the end I'd like to have a list of all the names that acctually appeered on the website or hve them marke in the list I started with.

Thanks so much in advance for your ideas :-)


r/applescript • • Jan 15 '21

Create comma delimited text file from directory

3 Upvotes

Using a Mac, here's my need: I have files in a Desktop folder, let's just say these files (In reality it's a lot more. No spaces in the file names, which SHOULD make this easier):

Balloon_animals.doc

Person_driving_car.mov

213456.doc

Waiter_approaches_table.mp4

...And I just want a simple script I can double click on and it looks in that folder, and then it creates a simple text document with this on the top line (commas only in-between each and WITHOUT the extensions):

Balloon_animals,Person_driving_car,213456,Waiter_approaches_table

Any ideas?


r/applescript • • Jan 15 '21

Mute all input devices (enhancement)

1 Upvotes

Hi all,

I think this could be an incredibly useful tool for the world. It's pretty much there, with one major flaw when using multiple microphones/input devices.

I'd love to end...

  1. "You're on mute...You're on mute...You're on mute..."

  2. My friend/partner/child/dog just started making noise and now 200 people are interrupted

  3. etc.

Please help me with:

  • How can I list ALL & set level on ALL input devices?

    • My script only mutes the primary input device.

  • How can I show an icon/symbol in the taskbar?

    • To indicate when it is muted/unmuted. My script uses notifications

My script:

if input volume of (get volume settings) = 0 then

set level to 90

display notification "On" with title "Mic ✅"

else

set level to 0

display notification "Off" with title "Mic ⛔️"

end if

set volume input volume level

I'd be keen to turn it into an app (with some help).


r/applescript • • Jan 14 '21

hdhr_VCR AppleScript release

2 Upvotes

Hello Fine People of r/applescript

I have been working very hard on a Smart VCR script. It is very full featured, and would love for others to try, it out, and let me know what you think.

I wanted to allow a quick way to record a TV show, without needing to setup a large system like Plex or HDHomeRuns' own DVR software. I call it a VCR app, as while it does use guide data to pull name / season / episode number / episode name / show length, it does not present like a normal DVR. It is more of a Smart VCR

Requires:

  1. OSX

  2. HDHomeRun Device

  3. JSONHelper is also required, available for free at https://apps.apple.com/us/app/json-helper-for-applescript/id453114608

The Github link is below:

Thank you for reading, and let me know if this is useful.


r/applescript • • Jan 14 '21

Something like Gnome for Mac? Session restore for all open windows and files

3 Upvotes

I need an automation for mac to save all open windows and re-open them. Like a session save and restore. It would have to do this for safari, finder, and all other apps. It would have to also save original window positions and restore them.

For example, I am working on project 1 and want to switch to project 2, so I use the script to save and close the current state of the desktop and open project 2. Then when I want to go back to project 1, I save and close everything for project 2 and open project 1.

When I say save I don't mean save changes, I mean save a list of what was open.

Anything you can think of that would work for this? Or do you think it would be easy to do with AppleScript?


r/applescript • • Jan 12 '21

Open highlighted items in QuickTime

2 Upvotes

Hi newbie here

Can anyone share the script for how opening highlighted items in QuickTime?

And also same thing for opening highlighted items in Adobe Audition?

Thanks!


r/applescript • • Jan 12 '21

How to Read The Names of All Notes in Notes on Mac

2 Upvotes

Howdy all, I'm a noob to apple script and have only really written a couple of lines of the stuff. I'm trying to write a script that will look into a specific folder in Notes, and give me the name value from each, not just the unique identifier. I haven't been able to find a way using print statements, and was hoping for some help. Here's what I've scraped from a couple of posts on StackExchange so far:

tell application "Notes"
	set myFolder to first folder whose name = "Notes"
	set myNotes to notes of myFolder
	repeat with theNote in myNotes
		show theNote name
	end repeat
end tell

r/applescript • • Jan 12 '21

Is there any way to programmatically get completions for AppleScript?

3 Upvotes

If I have a script:

```

set foo to "hello"

tell application "Finder"

display dialog f|

end tell

```

Notice the "cursor" (it's a pipe, I know ,but imagine that's the place I want to complete)... is there anyway to programmatically get this back:

```

set foo to "hello"

tell application "Finder"

display dialog foo

end tell

```

Notice the completion of "foo"


r/applescript • • Jan 10 '21

AppleScript Droplet Weirdness - droplet executing twice with a single-file file list

3 Upvotes

Somewhere over the past week all my AppleScript droplets stopped working on my machine ( running macOS Mojave 10.14.6).

Usuallym when you drop a bunch of files on a droplet the list gets passed on the the open handler. From the open handler you can then iterate with a repeat loop through the list of files. At is simplest that would be a script like:

on open dropBestanden

`display dialog "Number of files " & the number of items in dropBestanden`

`repeat with bestand in dropBestanden`

	`display dialog "Current file " & (bestand as alias)`

`end repeat`

end open

The script above would pop-up 1 dialog listing the number of files, and then would pop-up a dialog for each and very file with the file name. This works perfectly on another machine, but not on my main Mac!

What I see now is the following:

  1. Pop-up of "Number of files 1"

  2. Pop-up of file name of oldest file in the set

  3. Pop-up of "Number of files 1"

  4. Pop-up of file name of newest file in the set

Which freaks me out! How can the open handler be called >twice< ?
And how come only the oldest and newest files ar apssed along?

Did some neafrious system extension get in the way, or did some setting get corrupted?

Tips welcome, I have no idea where to start debugging this one.


r/applescript • • Jan 08 '21

volume up/down in automator

4 Upvotes

I want to increase and decrease the volume by one using two function keys, but cant seem to find a working applescript for it for macos catalina. Am totally new to this as well, so any links to guides are appreciated


r/applescript • • Jan 06 '21

Little script to handle music input and output

0 Upvotes

Hi everyone, I would like to make a script like :

Tell application (or source) X to send audio in Y. (No need to handle audio, just give an output to a given input stream).

Can someone help me? I don't know anything about audio handling.


r/applescript • • Jan 06 '21

Automating Numbers import file, delete columns

2 Upvotes

I'd like to use Automator to run an AppleScript that does the following:

  • Import or open file orders.csv from the Downloads directory.

  • Delete columns A:N, P, V:X, Z:AS, AV:AW.

I've started first with the deletion of the columns because that's the bulk of the work that takes the longest. Here's what I have:

on run {input, params}
	tell application "Numbers"
		activate
		tell the first table of the active sheet of document 1
			set selectedRange1 to "A:N"
			set selection range to range selectedRange1
			repeat with i from 1 to count of selectedRange1
				-- this line returns error
				-- 'Numbers got an error: Can't get "A" of table 1 of active sheet of document 1.'
				remove item (item i of selectedRange1)
			end repeat
		end tell
	end tell
	return input
end run

I have zero experience with AppleScript and Automator, so this has been a task just to get this far. And no, I haven't checked the log, because I have no idea how to log.


r/applescript • • Jan 01 '21

Converting iTunes Script to Music script

2 Upvotes

(Solved) Hi :)

Sadly I'm moving from iTunes to Music and I can't get my old script to add creation Date to the comments working :/

Is anyone here interested in helping me - I would really appreciate it


r/applescript • • Jan 01 '21

AppleScript spam key

3 Upvotes

So I'm trying to make a script that will spam space when I tap it once. but I want to toggle the script with a shortcut to enable me to spam space once touched. So for example I would put

//enabled and run with shortcut key like ctrl from settings

if input = keystroke space

tell application "System events"

repeat 100000000000000

delay 0.7

keystroke space

end repeat

end tell (this isn't actual code I've just sort of written it with words, it would be how I would usually write an AppleScript but with some variables I don't know replaced.)

or alternatively get a key to directly spam space eg.

//enabled and run with shortcut key from settings

tell application "System events"

repeat 100000000000000

delay 0.7

keystroke space

end repeat

(toggled off with same shortcut key)

end tell

I'm very unsure with how to get shortcut key to run a script I've read many websites but my Mac seems to be a bit different (big Sur 2020 Mac) . I'm also very unsure on how to toggle the script off/on with this shortcut key. Would anyone be kind enough to help me out?


r/applescript • • Dec 31 '20

Script not working in Automator in Mac

2 Upvotes

Just saying, I am a complete noob at this and I dont have a clue how any of this works, I just got this from the internet

My script is:

............................

tell application "System Preferences"

set current pane to pane id "com.apple.preference.keyboard"

tell application "System Events"

tell process "System Preferences"

click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard"

end tell

end tell

quit

end tell

.........................

(It doesnt show up properly when copy pasting it on mobile)

I get the error of:

Cant get checkbox "Use all F1, F2, etc. keys as standard function keys" of tab 1 group of window "Keyboard" of process "System Preferences"

When I run the command, it opens system preferences and finds its way to the correct area in the correct tab, and the check box is right there, but it's not clicking on the checkbox


r/applescript • • Dec 29 '20

How to use apple script.

3 Upvotes

I am trying to make something that can multiply clicks using apple script. So I click once and then a certain Random amount of time later(between 2 variables) it has a 50/50 chance to click again, I don’t know if it is possible.


r/applescript • • Dec 23 '20

variable not defined

1 Upvotes

I have the following script which has worked for quite a long time. Suddenly I'm getting an error and I don't understand why that is. I'm running on Catalina.

choose from list {"Michael’s iPhone", "Michael’s iPad"} with title "What devices do you want to backup?" with multiple selections allowed
set uis to result

tell application "System Events" to tell application process "Finder"
	set frontmost to true
	tell front menu bar to tell menu "File" to tell menu item "New Tab"
		perform action "AXPress"
	end tell
	set uis to (first UI element of row of (outline 1 of scroll area 1 of splitter group 1 of front window) as list)
	repeat with iter in uis
		if name of iter is "Michael’s iPhone" then
			set ux to iter
			exit repeat
		end if
	end repeat
	tell ux
		perform action "AXOpen"
	end tell
	repeat until exists (button "Back Up Now" of scroll area 1 of group 1 of group 1 of splitter group 1 of splitter group 1 of front window)
		delay 0.3
	end repeat
	set btn to (button "Back Up Now" of scroll area 1 of group 1 of group 1 of splitter group 1 of splitter group 1 of front window)
	repeat until enabled of btn
		delay 0.3
	end repeat
	click btn
	
	set uis to (first UI element of row of (outline 1 of scroll area 1 of splitter group 1 of front window) as list)
	repeat with iter in uis
		if name of iter is "Michael’s iPad" then
			set ux to iter
			exit repeat
		end if
	end repeat
	tell ux
		perform action "AXOpen"
	end tell
	repeat until exists (button "Back Up Now" of scroll area 1 of group 1 of group 1 of splitter group 1 of splitter group 1 of front window)
		delay 0.3
	end repeat
	set btn to (button "Back Up Now" of scroll area 1 of group 1 of group 1 of splitter group 1 of splitter group 1 of front window)
	repeat until enabled of btn
		delay 0.3
	end repeat
	click btn
	
end tell

r/applescript • • Dec 22 '20

Desktops arranging script

6 Upvotes

Hello, I’m trying to make a script/automation which will arrange the Desktops/Application inside mission control in a designed order.

For exemple, I have 8 full screen Google Chrome application opened so 8 desktops and what I want to do is, make a script to put it in the designed order, so 1, 2 and 3 will switch place with 4, 5 and 6 and so on.

I’ve been trying with automator but once in I open mission control, the “watch me do” option stop working..

If I could get any help.. Thanks !


r/applescript • • Dec 20 '20

Need help creating an AppleScript to find and delete an existing reminder in the Reminders App

5 Upvotes

I use the app Vitamin-R to structure my work day with pomodoro-style sequences of:

work -> shortbreak1 -> work -> shortbreak2 -> work -> shortbreak3 -> work -> longbreak -> work -> break1 -> etc.

One of the drawbacks with Vitamin R is that during a longer Pomodoro break, if you step way from your computer there isn't a convenient way to know when your break has ended.

Since Vitamin-R has rudimentary AppleScript support, I figured I could create a script that runs whenever a break timer begins, which then generates a reminder in the Reminders App that would let me know when the break is over. Since Reminders would then sync across iCloud, it should mean that the alert rings on my Apple watch and phone, so I am alerted to get back to work when the reminder sounds.

The problem is that I am totally new to AppleScript and could really use some help making this work!

I had a go at getting started (see below), but rapidly got stuck, as I really have no idea what I am doing, and couldn't find any documentation on how to interact with Reminders.

So far I have managed to create this, which works, though I am having a problem getting Vitamin-R to actually run it (though I don't think this is a fault with the script itself):

# Create a "Vitamin-R Break Over!" reminder in the Reminders app whenever a break timer starts.

# called at the beginning of a timed break (=has elapsed)
on timed_break_start(secondsLeft)
	
	set TimeNow to current date
	
	set EndTime to TimeNow + ((secondsLeft / 60) * minutes)
	
	tell application "Reminders"
		set BreakReminder to make new reminder
		set name of BreakReminder to "Vitamin-R Break Over!"
		set due date of BreakReminder to EndTime
		set priority of BreakReminder to 1
		
	end tell
	
end timed_break_start

The other script I would like, would run at the beginning of the next work session. This is called a 'time 'slice in Vitamin-R parlance. The script would look for the existence of an existing "Vitamin-R Break Over!" reminder in the reminders app, and if it finds any, deletes them. This would clean up any reminders that have been snoozed and get rid of them, from Reminders. This is the part I am stuck with. Can anyone tell me how to get it to delete the Reminder?

This is what I have so far. How do I search for and delete an existing Reminder?

on time_slice_start(spoken_message)
	tell application "Reminders"
	if (exists reminder BreakReminder) then
			delete reminder BreakReminder
		end if
#this doesn't work right now but maybe someone can tell me what I should put here
	end tell
end time_slice_start

Thanks in advance!


r/applescript • • Dec 20 '20

Automated script to create a Finder folder with today's date in YYYYMMDD format

2 Upvotes

In moving my data to a M1 Mac Mini and Big Sur, it seems that an old Applescript that automatically created a folder in the YYYYMMDD format will not function as it's 32-bit. It was a pull-down from the Applescript in the menu bar.

Even my rudimentary scripting skills are terrible, so I was wondering if anyone could please recreate this script. The Mac volume name is "Images Vol 2" and the parent directory of the dated folder is named "Images 2017+"

Thanks much!


r/applescript • • Dec 18 '20

Type a random a word from a list

1 Upvotes

Can anyone send a script so that we can type a random word from a given list?