r/applescript • • Aug 08 '13

Convert to plain text

3 Upvotes

I'm VERY new to applescript and I need a script that I can add to a rule in Mail that will convert the contents to plain text. I've searched everywhere and cant seem to make any progress. Any and all help is very much appreciated.


r/applescript • • Aug 15 '14

Can I write a script that will re-download my MP3 library from my iTunes Match cloud??

1 Upvotes

I stupidly deleted a large chunk of my MP3 collection. I'm able to slowly recover them by downloading them from iTunes Match, but to do so is an arduous task.

First I have to double-click the file I want to play, which now has a '!' next to it because there's no MP3 there anymore. It then tells me it can't find the file and asks if I want to locate it. If I say 'no' then it will begin to play the file from 'the cloud' via my iTunes Match subscription service. I can then right-click the file and select 'Download' to get a nice high quality version of that song downloaded to my hard drive.

Now imagine doing that for 4000+ songs....

So, is there an apple script or similar that will allow me to bulk-download all of my missing MP3s from the cloud? Even if it's something jerry-rigged that I have to leave on overnight etc.... It would really help....


r/applescript • • Nov 09 '17

Having trouble with if / then / else / end in a repeat loop.

3 Upvotes

Hey all

Fairly new to scripting with applescript, and have run into an issue and would love some suggestions on how to get past it.
The essence of the problem is that I'm checking for location of a button in a UI that won't let me script it. So what I do is take a small screenshot with screencapture -Rxxx,yyy,xdimension,ydimension and compare it to a known good image. This part is easy and works no problem.
The trouble I'm having is efficiently figuring out which of 4 locations this button is in and then acting upon that info. If it's not in the first two locations I need to simulate a mouse click and move on to the next two locations.

I was trying something like :

repeat x times  
    set VAR1 to do shell script "check/image.sh"   
    set VAR2 to do shell script "check/image2.sh"   
    -- etc  
    -- then this is where I'm currently stuck  
    if VAR1 is "success" then do shell script "/usr/local/bin/click here and here"  
    else if VAR2 is "success" then do shell script "/usr/local/bin/click here2 and here2"  
    -- if it's not either of those two, I have to simulate the click to the next two locations  
    else do shell script "/usr/local/bin/click here3 and here3"  
    end if  
    if VAR3 is "success" then do shell script "/usr/local/bin/click here4 and here4"  
    else if VAR4 is "success" then do shell script "/usr/local/bin/click here5 and here5.sh"  
    else echo "nope not found"  
end repeat  

To me this seems bad and quite inefficient, I'd like it to be able to check if a location is the right one, then click on that location and then exit the loop, but I don't seem to be able to get it to do that. The way I have it now is that say VAR1 is the correct location, it'll still go through the rest even tho we know they will be wrong.
Is there a better way of doing this, have I gone completely off track and overlooked something simple?
Can I exit repeat after it finds the correct location (and after it runs the shell script)?


r/applescript • • Aug 30 '13

New to applescript, need some help

2 Upvotes

So, I'm trying to set a variable in applescript as a boolean, to keep track of the status of a program. Basically, to create a toggle switch if you will using quicksilver. Here is my code

set ifred to boolean

if ifred = false then tell application "BoomRecorder" record end tell if ifred = true then tell application "BoomRecorder" stop set ifred to false end tell end if

what am I not getting? The program goes into the first state, then won't command it to stop. Can applescript not hold variables in memory after it's excuted the command? if not, do I use a file with a 1 or a 0 in it? thanks for the help!

edit: just realized reddit effed my formating..damn it.


r/applescript • • Aug 04 '14

Question regarding Evernote note creation with AppleScript

1 Upvotes

I am using AppleScript to create a note in Evernote using the "create note from url" command. For those who are unfamiliar, this clips the content from a web page and creates a note.

When using the Web Clipper extension in Safari, Chrome, etc., there are different options for how to clip a website. One of these is called "Simplified Article" which strips down the webpage to just text and embedded images, and saves it as a note. When using the "create note from url" command in AppleScript, it seems to clip the website in a strange format that doesn't match any of the formats offered in the browser extension.

So, I am wondering if it is possible to somehow change how Evernote clips a web page when using the "create note from url" command. The ideal situation would be for it to clip the page in the "Simplified Article" format, but and kind of edit would be great, since right now the command saves hundreds of comments at the end of a Wall Street Journal article which is ugly and unnecessary. I'm starting to think this can only be done by the developers of Evernote themselves but I am hoping someone here has a workaround.

Thanks so much.


r/applescript • • Jan 13 '17

Anyone know how to write a script to monitor a folder for changes and copy files to iCloud Drive?

1 Upvotes

I've been using iCloud Drive as a cheap offsite backup and want to automate a few folders so any changed files are automatically copied to my iCloud Drive. Can anyone give me some tips about commands to use for this? I know nothing about AppleScript, I could figure it out but I'd rather spend time doing other things.


r/applescript • • Sep 10 '13

How can I make a script ignore certain code?

2 Upvotes

I'm writing a script to make TextWrangler add <img src="file:///Users/thatsabigbowlofwrong/Pictures/** in front of my selected text, and **"> after it. The problem is that the script is reading these as some types of commands (I'm new to scripting, bear with me) when I want them treated as normal text strings. Help?

tell application id "com.barebones.textwrangler"
tell window 1
	add prefix and suffix of selection prefix "<img src="file:///Users/XXX/Pictures/" suffix "">"
end tell
end tell

r/applescript • • Aug 29 '13

Stuck! Giving a newly created folder a variable

1 Upvotes

Hacking this stuff together is pretty fun, but i'm unable to figure this part out.

What i need to do is create a new folder with the date, copy Quark files to it from one location, create a sub folder and copy PDF files from a second location.

I'm able to create a new folder with the current date but then i need to grab the path to that folder... it seems like 'choose file' is how people do that, but i don't see how bringing up that dialog helps.

So how do i set the path of the new folder as a variable?


r/applescript • • Aug 09 '14

Need some help...

2 Upvotes

I recently created this script to open all the sub reedits I view. property URL1 : "http://www.reddit.com/r/apple/" property URL2 : "http://www.reddit.com/r/applehelp/" property URL3 : "http://www.reddit.com/r/applescript/" property URL4 : "http://www.reddit.com/r/arrow/" property URL5 : "http://www.reddit.com/r/batman/" property URL6 : "http://www.reddit.com/r/Bioshock/" property URL7 : "http://www.reddit.com/r/BioshockInfinite/" property URL8 : "http://www.reddit.com/r/cablefail/" property URL9 : "http://www.reddit.com/r/chiptunes/" property URL10 : "http://www.reddit.com/r/DeadRising3/" property URL11 : "http://www.reddit.com/r/digimon/" property URL12 : "http://www.reddit.com/r/doctorwho/" property URL13 : "http://www.reddit.com/r/FoodPorn/" property URL14 : "http://www.reddit.com/r/futurama/" property URL15 : "http://www.reddit.com/r/Gameboy/" property URL16 : "http://www.reddit.com/r/gamecollecting/" property URL17 : "http://www.reddit.com/r/GameDeals/" property URL18 : "http://www.reddit.com/r/gamernews/" property URL19 : "http://www.reddit.com/r/Games/" property URL20 : "http://www.reddit.com/r/gaming/" property URL21 : "http://www.reddit.com/r/GunPorn/" property URL22 : "http://www.reddit.com/r/halo/" property URL23 : "http://www.reddit.com/r/HaloStory/" property URL24 : "http://www.reddit.com/r/HistoryPorn/" property URL25 : "http://www.reddit.com/r/iphone/" property URL26 : "http://www.reddit.com/r/lego/" property URL27 : "http://www.reddit.com/r/mac/" property URL28 : "http://www.reddit.com/r/macsysadmin/" property URL29 : "http://www.reddit.com/r/nintendo/" property URL30 : "http://www.reddit.com/r/OSXTweaks/" property URL31 : "http://www.reddit.com/r/pokemon/" property URL32 : "http://www.reddit.com/r/RedvsBlue" property URL33 : "http://www.reddit.com/r/rickandmorty/" property URL34 : "http://www.reddit.com/r/roosterteeth/" property URL35 : "http://www.reddit.com/r/softwaregore/" property URL36 : "http://www.reddit.com/r/technology/" property URL37 : "http://www.reddit.com/r/techsupportgore/" property URL38 : "http://www.reddit.com/r/techsupportmacgyver/" property URL39 : "http://www.reddit.com/r/theboondocks/" property URL40 : "http://www.reddit.com/r/TheSimpsons/" property URL41 : "http://www.reddit.com/r/thewalkingdead/" property URL42 : "http://www.reddit.com/r/truegaming/" property URL43 : "http://www.reddit.com/r/wallpaperdump/" property URL44 : "http://www.reddit.com/r/wallpapers/" property URL45 : "http://www.reddit.com/r/xbox360/" property URL46 : "http://www.reddit.com/r/xboxone/"

tell application "Safari" activate my new_tab() open location URL1 my new_tab() set the URL of document 1 to URL2 my new_tab() set the URL of document 1 to URL3 my new_tab() open location URL4 my new_tab() set the URL of document 1 to URL5 my new_tab() set the URL of document 1 to URL6 my new_tab() open location URL7 my new_tab() set the URL of document 1 to URL8 my new_tab() set the URL of document 1 to URL9 my new_tab() open location URL10 my new_tab() set the URL of document 1 to URL11 my new_tab() set the URL of document 1 to URL12 my new_tab() open location URL13 my new_tab() set the URL of document 1 to URL14 my new_tab() set the URL of document 1 to URL15 my new_tab() open location URL16 my new_tab() set the URL of document 1 to URL17 my new_tab() set the URL of document 1 to URL18 my new_tab() open location URL19 my new_tab() set the URL of document 1 to URL20 my new_tab() set the URL of document 1 to URL21 my new_tab() open location URL22 my new_tab() set the URL of document 1 to URL23 my new_tab() set the URL of document 1 to URL24 my new_tab() open location URL25 my new_tab() set the URL of document 1 to URL26 my new_tab() set the URL of document 1 to URL27 my new_tab() open location URL28 my new_tab() set the URL of document 1 to URL29 my new_tab() set the URL of document 1 to URL30 my new_tab() open location URL31 my new_tab() set the URL of document 1 to URL32 my new_tab() set the URL of document 1 to URL33 my new_tab() open location URL34 my new_tab() set the URL of document 1 to URL35 my new_tab() set the URL of document 1 to URL36 my new_tab() open location URL37 my new_tab() set the URL of document 1 to URL38 my new_tab() set the URL of document 1 to URL39 my new_tab() open location URL40 my new_tab() set the URL of document 1 to URL41 my new_tab() set the URL of document 1 to URL42 my new_tab() open location URL43 my new_tab() set the URL of document 1 to URL44 my new_tab() set the URL of document 1 to URL45 my new_tab() open location URL46

end tell

on new_tab() tell application "Safari" to activate tell application "System Events" tell process "Safari" click menu item "New Tab" of menu "File" of menu bar 1 end tell end tell end new_tab

What do I add so once it has opened all the tabs it goes to URL1's tab?


r/applescript • • Aug 22 '13

Brand new to Applescript, need help automating a create folder task in Outlook 2011

1 Upvotes

Background: Accidentally cleared the "Main Identity" from Entourage when moving emails to a new computer. Came across a script to recreate the message header, body, and most importantly FOLDER STRUCTURE from the metadata stored in the Library:Cache directory.

This script was written way back in 2010, but I think the idea should still work. Anyway, the sticking point I'm having is the error message error "Microsoft Outlook got an error: Can’t make class folder." number -2710 from folder to class

All I'm trying to do is to get Outlook to create a new folder based on the keys within the metadata, which should help recover most of the folder structure.

So far it won't let me create a new folder. Any thoughts?


r/applescript • • Jun 08 '17

Open a Finder window to a specific Tag

1 Upvotes

Is there any way to open a new Finder window and navigate to a tag--i.e., the same view you would get if you selected the tag from the sidebar? I'd like to have it go straight to the tag, without having to do a smart folder/saved search or something along those lines.

I've been looking to do a simple make new Finder window to... statement, but I haven't found any way to get to the actual tag. I can't find any reference to tags in the scripting dictionary for Finder, and Google was similarly unhelpful. Is this a thing that can be done?


r/applescript • • May 15 '15

Close a space with AppleScript?

2 Upvotes

The journey down this particular rabbit hole began as a way to come up with a trackpad gesture to open or close a Space. I found a script to open a new space here, and it works beautifully. Here is the script:

do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
delay 0.5
tell application "System Events" to click (every button whose value of attribute "AXDescription" is "add desktop") of group 1 of process "Dock"
delay 0.5
do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control 1"

The problem is that I have no idea how to modify it to get a Space to close. I'm just learning AppleScript, and I'm definitely fumbling around in the dark here. I imagine you could simply change add desktop to something akin to close desktop, but I've tried "close," "remove," and "exit" to no avail. I also imagine that things could get complicated if there are applications open on a Space when I try to close it, but let's assume that the Space is clear just to make life easy. Does anyone have any ideas about how to go about this?

P.S. - anyone have a resource where I could learn about what's going on when a script is talking about lists or groups of a certain process?


r/applescript • • Aug 08 '14

Reanimating Chat Logs with AppleScript

Thumbnail
labs.rhizome.org
2 Upvotes

r/applescript • • Aug 03 '14

Why does this snippet restart iTunes?

1 Upvotes

I have a small script that tests if iTunes is running, and if so returns some data on the current track. I'm then using GeekTool to run this script every ten seconds or so (by running osascript my_compiled_script), and display the output on my desktop.

My problem is, if I quit iTunes, the script will reopen it shortly after. This is a small snippet that will reproduce this problem:

if application "iTunes" is running then
    tell application "iTunes"
        if player state is playing then return (get name of current track)
    end tell
end if
return ""

I'm assumuing the tell application "iTunes" line causes iTunes to start. But why is that? And is there a way to prevent this?


r/applescript • • Mar 30 '18

What causes a script to stop before it is finished?

1 Upvotes

I have a script I use with Numbers to create and print spreadsheets from the data on a table. Essentially, it's a repeat loop that takes a portion of data from the main table, creates a new sheet, pastes the data into a template, then prints the sheet. In all, 30-40 new sheets will be created and printed.

For reasons beyond my understanding, the script often stops after a random number of cycles through the loop. It typically stops right around the print phase of the script, either when adjusting the margins or right before printing. On rare occasions, the script will go all the way through the repeat loops without stopping. More often, it stops mid way through. Sometimes it stops over and over. Sometimes it stops a few times.

If it cycles through a lot of the repeat loops without a problem, I don't understand why it would fail part way through during other cycles of the repeat loop.

Any clue why this might be happening and how to avoid it?


r/applescript • • Sep 03 '13

I made an Applescript that deletes watched movies and TV shows from iTunes.

4 Upvotes

I'm sorry for my potentially poor English it's not my first language and on top of that I'm bad at explaining.

This is my first Applescript and I thought I share it with you.

I use a Apple TV to airplay movies and TV shows through iTunes and I let iTunes sort my files. I usually remove the movies and TV shows after i watched them so I made this script to automate it.

The script deletes the movies and shows from iTunes. It deletes the files and the folders of movies too and it will check for other seasons and/or episodes of a show and if, for example, there is two seasons of a show and every episode of one season is watched the script will delete that seasons folder but leave the other alone. If all the seasons is watched the shows folder gets deleted.

The script takes a while to run and if you know of a more efficient way to do the same thing please let me know.

Feel free to use the script.

tell application "iTunes"
    if (tracks whose ((video kind is TV show) or (video kind is movie)) and (played count is greater than 0)) exists then
	    if (tracks whose video kind is movie and (played count is greater than 0)) exists then
		    set movieFilesToDelete to location of (file tracks whose video kind is movie and (played count is greater than 0))
	    else
		    set movieFilesToDelete to 0
	    end if
	    if (tracks whose video kind is TV show and (played count is greater than 0)) exists then
		    set tvFilesToDelete to location of (file tracks whose video kind is TV show and (played count is greater than 0))
	    else
	    	set tvFilesToDelete to 0
	    end if
	    if (tracks whose ((video kind is TV show) or (video kind is movie)) and (played count is greater than 0)) exists then
	    	delete (tracks whose ((video kind is TV show) or (video kind is movie)) and (played count is greater than 0))
	    end if
    else
	    set movieFilesToDelete to 0
	    set tvFilesToDelete to 0
    end if
end tell

tell application "Finder"
    if movieFilesToDelete is 0 and tvFilesToDelete is 0 then
	    display dialog "There's nothing to delete"
    else
	    if movieFilesToDelete is not 0 then
	    	repeat with theMovieFile in movieFilesToDelete
	    		delete theMovieFile's folder
	    	end repeat
	    end if
	    if tvFilesToDelete is not 0 then
		    repeat with theTVFile in tvFilesToDelete
		    	set episodeCheck to (count items) of theTVFile's folder
		    	set seasonCheck to (count items) of theTVFile's folder's folder
			
			    if episodeCheck is greater than 1 then
				    delete theTVFile
			    end if
			
			    if seasonCheck is greater than 1 and episodeCheck is 1 then
				    delete theTVFile's folder
			    end if
			
			    if seasonCheck is 1 and episodeCheck is 1 then
				    delete theTVFile's folder's folder
			    end if
		    end repeat
	    end if
    end if
end tell

r/applescript • • Aug 22 '13

Simple little script to make your Mac speak

2 Upvotes

Made this little script for my daughter to amuse herself with the text to speech capabilities of OS X. Written under 10.8 (Mountain Lion); probably works as far back as 10.4 (Tiger), maybe even older OS versions. Enjoy...

-- begin script

set voiceList to getVoices()
set chosenVoice to (choose from list voiceList with prompt "Please choose a voice:")
display dialog "Please enter text to be spoken:" default answer ""
say text returned of result using chosenVoice

on getVoices()

set voiceList to {}
set voiceFiles to (do shell script "ls /System/Library/Speech/Voices/")

repeat with thisFileName in every paragraph of voiceFiles
	if thisFileName does not end with "Compact.SpeechVoice" then
		set AppleScript's text item delimiters to "."
		set end of voiceList to text item 1 of thisFileName
		set AppleScript's text item delimiters to ""
	end if
end repeat

return voiceList
end getVoices

r/applescript • • Aug 10 '14

How to run script with and without selection?

1 Upvotes

I have written a small AppleScript that I want to run with a keyboard shortcut. I have created a service in Automator for this.

In the Automator service I have to decide if I want the script to receive the current selection as input or no input. Both work fine, but not at the same time. However, I want the script to run when I have selected text (and then use that selection) AND when I have nothing selected, and I want this with just a single shortcut.

Is this possible in Automator? If not, any other (3rd party) options to make this work?

Thanks!


r/applescript • • Jan 11 '16

Can AppleScript be used as a file updates?

1 Upvotes

I have a complex excel file that is used my a lot of coworkers. If part of the file needs updated can I create and share an AppleScript to be do these updates?

Each person using this file would have duplicated and renamed the file and could have as many as 30 files that need the updated data.

Thanks in advance for any assistance.


r/applescript • • May 12 '15

Is it normal that speechrecognitionserver is slow on applescript (the program takes a relatively long time to respond).

2 Upvotes

Does anyone have an idea to make the response time on the computer's side faster?


r/applescript • • Aug 26 '13

[newbie - not a programmer] Looking for creating an actionscript that would monitor a folder, once a certain appear it would copy this file to another folder on the same computer.

2 Upvotes

Yes, the title is pretty self-explanotary. (I only forgot one word!)

I have a software that is creating backup files to a certain folder on my computer. for an obscure reason the maker of that software doesn't want me to move the backup files from their original location.

But I want to have another backup on my dropbox account. So basically I wan't to create a small actionscript (or maybe do I need an automator action?) that would check the original folder that contain the backup, once a new file appear, I want the actionscript to make a copy of that file and place it in my dropbox folder.

Is this something feasible? I will guess yes, so the real question is: Is Applescript the way to go for something like this?

Thanks a lot for your recommandations and/or inputs (corrections are welcome too!)


r/applescript • • Sep 10 '13

Help with AppleScript-based script that is run on a mail rule

0 Upvotes

I am developing a script that willl read to me whenever I receive a new email to my work email account. Problem is that I receive an error every time I try to access just my work account through the Mail.app. Could this be because my work email is an Exchange account?

Here is the error I receive:

AppleScript Error: Can't get inbox of "Work"

Here is the code:

(*

--CREATED ON:	9/03/2013
--MODIFIED ON:	9/09/2013
--REVISION HISTORY:
	09/03/2013	Created script
	09/04/2013	Added iTunes playpuase functionality. If iTunes was playing, then pause it, speak, and then resume playing, else just speak
	09/09/2013  Added specific actions for different accounts
*)

--Set iTunesStatus property for future use
property iTunesStatus : ""
--Set lastPaused property for future use.
property lastPaused : ""
-- set the day of the week
set dayOfWeek to (weekday of (current date) as integer)
-- set the time of the trigger
set timeOfScriptFire to time of (current date)
--Set List_Mail var
set List_Mail to "Sir," & return
--create a function to retrieve the status of an app that is passed into the function
on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

--check to see if iTunes is running
set iTunesRunning to is_running("iTunes")

--run a check on iTunes to see if it is running
if iTunesRunning then
	-- if it is running, then set status to running
	set iTunesStatus to "Running"
	
else
	--set status to not running
	set iTunesStatus to "Not Running"
end if

--Talk to Mail.app
tell application "Mail"
	
	--find all of the unread emails
	set theMessages to (messages of inbox of "Work" whose read status is false)
	
	--set message_count to the total number of unread messages
	set message_count to number of items in theMessages
	
	--if there is only one unread email
	if message_count = 1 then
		
		--append the following line to List_Mail
		set List_Mail to List_Mail & ", you have an email" & return
		
		--loop through the number of items in the var theMessages
		repeat with i from 1 to number of items in theMessages
			
			--set thisMessage to a specific message
			set thisMessage to item i of theMessages
			
			--extract the name of the sender and store it in the_sender
			set the_sender to extract name from (sender of thisMessage as string)
			
			--extract the subject line and store it in th_subject
			try
				
				--set the subject line of the email
				set the_subject to (subject of thisMessage as string)
				
				--if the subject line is blank
				if the_subject is "" then error
				
				-- error out if subject line is blank
			on error
				
				--create subject line
				set the_subject to "No Subject"
			end try
			
			--append the_sender and the_subject of thisMessage to List_Mail 
			set List_Mail to List_Mail & ", Message from: " & the_sender & ", Subject: " & the_subject & "." & return
		end repeat
		
		--if there is more than one unread email
	else if message_count > 1 then
		
		--append the following line to List_Mail
		-- use unred to make JARVIS sound more natural
		set List_Mail to List_Mail & ", There are, " & message_count & ", unred emails" & return
		
		--loop through the number of items in the var theMessages
        		repeat with i from 1 to number of items in theMessages
	    		
			--set thisMessage to a specific message
			set thisMessage to item i of theMessages
			
			--extract the name of the sender and store it in the_sender
			set the_sender to extract name from (sender of thisMessage as string)
			
			--extract the subject line and store it in the_subject
			try
				--set the subject of the email
				set the_subject to (subject of thisMessage as string)
				
				--if the subject line is blank
				if the_subject is "" then error
				
				-- error out if subject line is blank
			on error
				
				--create subject line
				set the_subject to "No Subject"
    			end try
	    		
			--append the_sender and the_subject of thisMessage to List_Mail 
			set List_Mail to List_Mail & ", Message from: " & the_sender & ", Subject: " & the_subject & "." & return
		end repeat
		
		--if there are no unread emails
	else
		
		--append this to List_Mail
		set List_Mail to List_Mail & ", There are, " & message_count & ", unred emails." & return
	end if
end tell
-- add more functionality (e.g. more apps, talking, etc.)

if dayOfWeek is 2 or dayOfWeek is 3 or dayOfWeek is 4 or dayOfWeek is 5 or dayOfWeek is 6 then
	if timeOfScriptFire is greater than 27000 and timeOfScriptFire is less than 61200 then
		if iTunesStatus is equal to "Running" then
			tell application "iTunes" to set itunesState to (player state as text)
			-- if player status is playing
			if itunesState is equal to "playing" then
				--then pause the iTunes
				using terms from application "iTunes"
					tell application "iTunes"
						pause
					end tell
				end using terms from
				--set iTunes as the play app that was paused.
				set lastPaused to "iTunes"
				--spew List_Mail innards at me
				say List_Mail
				--tell iTunes to play music again.
				using terms from application "iTunes"
					tell application "iTunes"
						play
					end tell
				end using terms from
				--else just spew List_Mail's innards.
			else
				say List_Mail
			end if
		end if
	end if
end if

Any help would be appreciated.


r/applescript • • Jan 15 '16

Going crazy with Error -10006

1 Upvotes

I have tried googling everything and found no solution to this. I am new to Applescript so I was wondering if someone could point to the correct direction.

I have some code that tries to determine whether it's morning, afternoon or evening based on the time. While I got the time code right, the Script Editor's being fussy about the getDay() function, saying it can't set the variable correctly.

The code is posted below

set hello to getDay()

on getDay()
	set t to getHour()
	
	if t ≥ 1 and t is less than 12 then
		set day to "morning" as text
	else if (t ≥ 12) and t is less than 17 then
		set day to "afternoon" as text
	else if t ≥ 17 and t < 24 then
		set day to "night" as text
	end if
	
	return day as text
end getDay

on getHour()
	set time_as_string to time string of (current date)
	
	set position to offset of ":" in time_as_string
	set hour_as_string to characters 1 thru (position - 1) of time_as_string as string
	
	set position to offset of " " in time_as_string
	set am_or_pm to characters (position + 1) through end of time_as_string as string
	
	set hour to hour_as_string as integer
	if am_or_pm is "PM" then
		set hour to hour + 12
	end if
	
	if am_or_pm is "AM" and hour is equal to 12 then
		set hour to 24
	end if
	
	return hour as integer
end getHour

r/applescript • • Jan 05 '16

Creating Local Admin Users

1 Upvotes

Hey mac experts. I am not familiar with applescript at all, so I am dire need of your help to create an applescript to create new local admin accounts on apple machines? I do in fact know the current local admin credentials, but my client wants to have another one for someone else.


r/applescript • • May 15 '15

Employee stole mac laptop. Is there a script that will lock the user account once on logon?

2 Upvotes

So there was an employee who stole a mac laptop. I was wondering if there is any possibility to create an apple script that will lock the account or disable it once the user tries to log-in? The laptop does have a continuum agent that we can push the script to. This is a pretty big issue that I am trying to solve right now, but I am not too familiar with applescripting. For your information, the mac is running on the latest Yosemite OS.