Skip to content

Commit 239a0ad

Browse files
committed
all updated.
1 parent b86514e commit 239a0ad

File tree

12 files changed

+218
-1
lines changed

12 files changed

+218
-1
lines changed

.DS_Store

6 KB
Binary file not shown.

Bartender/.DS_Store

6 KB
Binary file not shown.

Bartender/DisplaysLaptopOnly.scpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- DisplaysLaptopOnly.scpt
2+
--
3+
-- A simple script to return `TRUE` when laptop screen is the only one.
4+
-- Useful with Bartender Profiles
5+
--
6+
-- Copyright Anthony Arblaster 2023
7+
-- MIT Licence
8+
-- Web: https://github.com/aarblaster/UsefulAppleScripts
9+
--
10+
-- Version 1.0
11+
--
12+
13+
tell application "System Events"
14+
set monitorCount to count of desktops
15+
if monitorCount > 1 then
16+
return false
17+
else
18+
tell application "Finder"
19+
set monitorSize to bounds of window of desktop
20+
end tell
21+
if monitorSize = {0, 0, 1512, 982} then
22+
return true
23+
else
24+
return false
25+
end if
26+
end if
27+
end tell

Bartender/DisplaysNotLaptop.scpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- DisplaysNotLaptop.scpt
2+
--
3+
-- A simple script to return `TRUE` when laptop screen is **NOT** the only one.
4+
-- Useful with Bartender Profiles
5+
--
6+
-- Copyright Anthony Arblaster 2023
7+
-- MIT Licence
8+
-- Web: https://github.com/aarblaster/UsefulAppleScripts
9+
--
10+
-- Version 1.0
11+
--
12+
13+
tell application "System Events"
14+
set monitorCount to count of desktops
15+
if monitorCount > 1 then
16+
return true
17+
else
18+
tell application "Finder"
19+
set monitorSize to bounds of window of desktop
20+
end tell
21+
if monitorSize = {0, 0, 1512, 982} then
22+
return false
23+
else
24+
return true
25+
end if
26+
end if
27+
end tell

Bunch/.DS_Store

6 KB
Binary file not shown.

Bunch/GetKMVar.scpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- GetKMVAR.scpt
2+
--
3+
-- A simple script get the variable from KM.
4+
-- A building block really.
5+
--
6+
-- Copyright Anthony Arblaster 2023
7+
-- MIT Licence
8+
-- Web: https://github.com/aarblaster/UsefulAppleScripts
9+
--
10+
-- Version 1.0
11+
--
12+
13+
-- Get the value of a KeyboardMaestro variable.
14+
-- Make it available to the AppleScript.
15+
16+
-- set the name of the KM variable to get.
17+
set myKMVar to "ScriptVar"
18+
19+
-- Get the value from KM.
20+
tell application "Keyboard Maestro Engine"
21+
set myASVar to getvariable myKMVar
22+
end tell

Bunch/QuitXcodeBunch.scpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- QuitXcodeBunch.scpt
2+
--
3+
-- Quit Xcode, stopping running tasks.
4+
--
5+
-- Copyright Anthony Arblaster 2023
6+
-- MIT Licence
7+
-- Web: https://github.com/aarblaster/UsefulAppleScripts
8+
--
9+
-- Version 1.0
10+
--
11+
12+
tell application "Xcode"
13+
stop workspace document 1
14+
end tell
15+
delay 3
16+
tell application "Xcode"
17+
quit
18+
end tell

Email/.DS_Store

6 KB
Binary file not shown.

Email/EmailHi.scpt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--
2+
-- EmailHi.scpt
3+
--
4+
-- Get the fist name of people in the email ‘To’ field.
5+
-- With variants for Mail.app and MS Outlook.
6+
--
7+
-- Copyright Anthony Arblaster 2023
8+
-- MIT Licence
9+
-- Web: https://github.com/aarblaster/UsefulAppleScripts
10+
--
11+
-- Version 3.0
12+
--
13+
14+
-- The Outlook variation
15+
-- Note this only works if using a seperate window.
16+
-- It will not work if you're replying in the main app.
17+
if application "Microsoft Outlook" is the frontmost application then
18+
tell application "System Events"
19+
tell process "Microsoft Outlook"
20+
tell text field 1 of scroll area 1 of splitter group 1 of front window
21+
get count of static text
22+
if result is 1 then
23+
set theToRecipient to (value of static text 1)
24+
return word 1 of theToRecipient
25+
else if result is 2 then
26+
set the1stToRecipient to (value of static text 1)
27+
set the2ndToRecipient to (value of static text 2)
28+
return word 1 of the1stToRecipient & " and " & word 1 of the2ndToRecipient
29+
else if result is greater than 2 then
30+
return "all"
31+
end if
32+
end tell
33+
end tell
34+
end tell
35+
36+
else
37+
-- the Mail.app variation
38+
tell application "System Events"
39+
tell process "Mail"
40+
tell text field "To:" of window 1
41+
if UI element 1 exists then
42+
set theToRecipient to (value of UI element 1)
43+
if ((count words of theToRecipient) is greater than 0) and (theToRecipient does not contain ",") then
44+
return word 1 of theToRecipient
45+
else if ((count words of theToRecipient) is greater than 0) and (theToRecipient contains ",") then
46+
return word 2 of theToRecipient
47+
end if
48+
end if
49+
end tell
50+
end tell
51+
end tell
52+
end if

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
# UsefulAppleScripts
2-
A collection of Useful Applescripts
2+
A collection of Useful Applescripts to make MacOS life better.
3+
4+
## About
5+
Some of these specifically integrate with other software and others manipulate the OS.
6+
These are mostly created by cobbling together bits and pieces from other scripts and finding the thing that works best for my use case.
7+
8+
## Directory
9+
### BarTender
10+
* `DisplaysLaptopOnly.scpt` determines if the monitor connected is a laptop display. This allows [Bartender](https://www.macbartender.com) to know if a smaller display is detected. This interacts with Bartender's new profile feature.
11+
* `DisplaysNotLaptop.scpt` very similar to `DisplaysLaptopOnly.scpt` but it determines if a monitor that is **not** the laptop is conected. Similarly, works with Bartender Profiles.
12+
13+
### Bunch
14+
* I use `QuitXcodeBunch` with [Bunch.app](https://bunchapp.co), from the excellent [@ttscoff](https://github.com/ttscoff), to close Xcode when leaving my Code bunch. It makes sure to stop any running tasks so that Xcode quits properly.
15+
* `GetKMVar` is a simple script to get the variable from inside [Keyboard Maestro](https://keyboardmaestro.com) and make it available to an applescript. It works in conjunction with other scripts as more of a building block.
16+
17+
### Email
18+
* `EmailHi.scpt` is heavily inspired by [David Sparks' blog](https://www.macsparky.com/blog/2020/09/updates-and-improvements-to-the-salutation-applescript-for-apple-mail/) and was influenced heavily by various posts I read on the [Automators forums](https://www.macsparky.com/blog/2020/09/updates-and-improvements-to-the-salutation-applescript-for-apple-mail/) and the [Mac Power Users Forums](https://talk.macpowerusers.com).
19+
My version of the script includes both MS Outlook and Mail.app variations as I work in both pieces of software and wanted the ability to get first names in both applications. I trigger it with Keyboard Maestro text entry because I try to keep all the applescript triggers there. But you could also use text expander...
20+
21+
22+
### URLs
23+
* `SafariToFirefox.scpt` opens the frontmost safari tab in firefox. Personally I trigger this with [Keyboard Maestro](https://keyboardmaestro.com)
24+
25+
## Thanks
26+
I'm not really amazing at any of this coding business, and I have only been able to work out these automations because of the excellent communities and software that others have made. I hope you find these useful.
27+
28+
If you do find them useful – give me a shout. I'd love to hear about that.

0 commit comments

Comments
 (0)