Skip to content

Commit

Permalink
Added the scripts that automate the generation of screenshots for Mac…
Browse files Browse the repository at this point in the history
…AppStore (#280)
  • Loading branch information
mikekazakov committed May 13, 2024
1 parent 61e01ec commit c390b72
Show file tree
Hide file tree
Showing 7 changed files with 342 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generating screenshots for Mac App Store

## Prerequisites
- Make sure GraphicsMagick is installed (brew install graphicsmagick)
- Make sure all NC's windows are closed, but the app is running
- Ensure NC's settings are close to defaults

## Running
- Using Terminal.app run each of `./screenshotN.sh`
- Close all NC windows after taking each screenshot
- Files will be located in the same directory with AppleScripts
127 changes: 127 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/screenshot1.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
on isRetina()
set physical to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution:/{print $2}'")
set logical to (do shell script "system_profiler SPDisplaysDataType | awk '/UI Looks like:/{print $4}'")
if physical is equal to logical then
return false
else
return true
end if
end isRetina

on moveFocusToDesktop()
tell application "Finder"
close every window
activate
end tell
end moveFocusToDesktop

tell application "System Events"
tell application "Nimble Commander" to close every window
tell application "Nimble Commander" to activate

keystroke "n" using {command down} --> ⌘N - make new window
delay 0.2

set position of first window of application process "Nimble Commander" to {100, 100}
set size of first window of application process "Nimble Commander" to {1220, 740}

key code 122 --> F1
delay 0.2
keystroke "1" --> 1
delay 0.2
keystroke "w" using {option down, command down} --> ⌥⌘W
delay 0.2
keystroke "l" using {option down, command down} --> ⌥⌘V
delay 0.2
keystroke "t" using {command down} --> ⌘T
delay 0.2
keystroke "o" using {shift down, command down} --> ⇧⌘O
delay 0.2
keystroke "t" using {command down} --> ⌘T
delay 0.2
keystroke tab using {control down} --> ^tab
delay 0.2
keystroke tab using {control down} --> ^tab
delay 0.2
keystroke "g" using {shift down, command down} --> ⇧⌘G
delay 0.2
keystroke "/Applications/Xcode_15_1_0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
delay 0.2
keystroke return
delay 0.2
keystroke "3" using {control down} --> ^3
delay 0.2
keystroke "_ctype"
delay 0.2
key code 53 --> Esc
delay 0.2
key code 126 --> Up
key code 126 --> Up
key code 126 --> Up
key code 126 --> Up
key code 126 --> Up
key code 126 --> Up
delay 0.2

keystroke tab --> tab
delay 0.2
keystroke "w" using {option down, command down} --> ⌥⌘W
delay 0.2
keystroke "d" using {shift down, command down} --> ⇧⌘D
delay 0.2
keystroke "t" using {command down} --> ⌘T
delay 0.2
keystroke "g" using {shift down, command down} --> ⇧⌘G
delay 0.2
keystroke "/System/Library"
delay 0.2
keystroke return
delay 0.2
keystroke "1" using {control down} --> ^1
delay 0.2
keystroke "CacheDelete"
delay 0.2
key code 53 --> Esc
delay 0.2
key code 125 using {shift down} --> ⇧Down
key code 125 using {shift down} --> ⇧Down
key code 125 using {shift down} --> ⇧Down
key code 125 using {shift down} --> ⇧Down
key code 125 using {shift down} --> ⇧Down
key code 125 using {shift down} --> ⇧Down
key code 125 using {shift down} --> ⇧Down
delay 0.2
key code 126 --> Up
key code 126 --> Up
key code 126 --> Up
delay 0.2
keystroke return using {option down, shift down} --> ⌥⇧Return
delay 1.0

keystroke tab --> tab
delay 0.2

keystroke "h" using {option down, command down} --> ⌥⌘H - hide other windows
delay 0.2
end tell

set ScreenshotName to "Screenshot-1"
set ScreenshotOffset to "+30+30"
if isRetina() then
set ScreenshotName to ScreenshotName & "@2x"
set ScreenshotOffset to "+60+60"
end if

set ScreenshotWithoutShadows to ScreenshotName & "_without_shadows.png"
set ScreenshotWithShadows to ScreenshotName & "_with_shadows.png"
set ScreenshotFinal to ScreenshotName & ".png"
tell application "Nimble Commander" to set windowID to id of window 1
do shell script "screencapture -x -o -tpng -l " & windowID & " " & ScreenshotWithoutShadows
moveFocusToDesktop()

do shell script "screencapture -x -R70,70,1280,800 -tpng " & ScreenshotWithShadows

do shell script "gm composite -geometry " & ScreenshotOffset & " " & ScreenshotWithoutShadows & " " & ScreenshotWithShadows & " " & ScreenshotFinal

do shell script "rm " & ScreenshotWithoutShadows
do shell script "rm " & ScreenshotWithShadows
2 changes: 2 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/screenshot1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
osascript screenshot1.scpt
96 changes: 96 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/screenshot2.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
--> NB! Requires:
--> Settings -> Panel -> Behaviour -> Ignore directories when selecting by mask = OFF
--> Settings -> Panel -> Quick Search -> Where to search = Anywhere

on isRetina()
set physical to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution:/{print $2}'")
set logical to (do shell script "system_profiler SPDisplaysDataType | awk '/UI Looks like:/{print $4}'")
if physical is equal to logical then
return false
else
return true
end if
end isRetina

on moveFocusToDesktop()
tell application "Finder"
close every window
activate
end tell
delay 0.2
end moveFocusToDesktop

tell application "System Events"
tell application "Nimble Commander" to close every window
tell application "Nimble Commander" to activate

keystroke "n" using {command down} --> ⌘N - make new window
delay 0.2

set position of first window of application process "Nimble Commander" to {100, 100}
set size of first window of application process "Nimble Commander" to {1220, 740}

keystroke "h" using {option down, command down} --> ⌥⌘H - hide other windows
delay 0.2

key code 120 --> F2
delay 0.2
keystroke "1" --> 1
delay 0.2
keystroke "w" using {option down, command down} --> ⌥⌘W
delay 0.2
keystroke "g" using {shift down, command down} --> ⇧⌘G
delay 0.2
keystroke "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources"
delay 0.2
keystroke return
delay 0.2
keystroke "3" using {control down} --> ^3
keystroke "uni"
delay 0.2
key code 119 --> End
keystroke tab

keystroke "w" using {option down, command down} --> ⌥⌘W
delay 0.2

keystroke "2" using {control down} --> ^2

keystroke "g" using {shift down, command down} --> ⇧⌘G
delay 0.2
keystroke "/System/Library/CoreServices"
delay 0.2
keystroke return
delay 0.2

keystroke "=" using {command down} --> ⌘=
delay 0.2
keystroke "*.bundle"
delay 0.2
keystroke return
delay 0.2
keystroke return using {option down, shift down} --> ⌥⇧Return
delay 1.0
keystroke "=" using {command down} --> ⌘=
delay 0.2
keystroke "*.bundle"
delay 0.5
end tell

set ScreenshotName to "Screenshot-2"
set ScreenshotOffset to "+30+30"
if isRetina() then
set ScreenshotName to ScreenshotName & "@2x"
set ScreenshotOffset to "+60+60"
end if

set ScreenshotWithoutShadows to ScreenshotName & "_without_shadows.png"
set ScreenshotWithShadows to ScreenshotName & "_with_shadows.png"
set ScreenshotFinal to ScreenshotName & ".png"
tell application "Nimble Commander" to set windowID to id of window 1
do shell script "screencapture -x -o -tpng -l " & windowID & " " & ScreenshotWithoutShadows
moveFocusToDesktop()
do shell script "screencapture -x -R70,70,1280,800 -tpng " & ScreenshotWithShadows
do shell script "gm composite -geometry " & ScreenshotOffset & " " & ScreenshotWithoutShadows & " " & ScreenshotWithShadows & " " & ScreenshotFinal
do shell script "rm " & ScreenshotWithoutShadows
do shell script "rm " & ScreenshotWithShadows
2 changes: 2 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/screenshot2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
osascript screenshot2.scpt
102 changes: 102 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/screenshot3.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
on isRetina()
set physical to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution:/{print $2}'")
set logical to (do shell script "system_profiler SPDisplaysDataType | awk '/UI Looks like:/{print $4}'")
if physical is equal to logical then
return false
else
return true
end if
end isRetina

on moveFocusToDesktop()
tell application "Finder"
close every window
activate
end tell
delay 0.2
end moveFocusToDesktop

tell application "System Events"
tell application "Nimble Commander" to close every window
tell application "Nimble Commander" to activate

keystroke "n" using {command down} --> ⌘N - make new window
delay 0.2

set position of first window of application process "Nimble Commander" to {100, 100}
set size of first window of application process "Nimble Commander" to {1220, 740}

keystroke "h" using {option down, command down} --> ⌥⌘H - hide other windows
delay 0.2

key code 120 --> F2
delay 0.2
keystroke "1" --> 1
delay 0.2
keystroke "w" using {option down, command down} --> ⌥⌘W
delay 0.2

keystroke "g" using {shift down, command down} --> ⇧⌘G
delay 0.2
keystroke "/Applications/Xcode_15_1_0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
delay 0.2
keystroke return
delay 0.2
keystroke "u" using {option down, command down} --> ⌥⌘U
delay 0.2
keystroke "3" using {control down} --> ^3
delay 0.2

keystroke tab
delay 0.2
keystroke "w" using {option down, command down} --> ⌥⌘W
delay 0.2
keystroke "h" using {shift down, command down} --> ⇧⌘H
delay 0.2
keystroke "2" using {control down} --> ^2
delay 0.2
keystroke "g" using {shift down, command down} --> ⇧⌘G
delay 0.2
keystroke "/Applications/Xcode_15_1_0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
delay 0.2
keystroke return
delay 0.2

keystroke "f" using {command down} --> ⌘F
delay 0.5
tell application "Nimble Commander"
repeat with aWindow in windows
set bounds of aWindow to {100, 100, 900, 700}
exit repeat
end repeat
end tell
delay 0.2

keystroke "*"
delay 0.2
keystroke "t" using {control down} --> ^t
delay 0.2
keystroke "malloc"
delay 0.2
keystroke return
delay 0.7

end tell

set ScreenshotName to "Screenshot-3"
set ScreenshotOffset to "+30+30"
if isRetina() then
set ScreenshotName to ScreenshotName & "@2x"
set ScreenshotOffset to "+60+60"
end if

set ScreenshotWithoutShadows to ScreenshotName & "_without_shadows.png"
set ScreenshotWithShadows to ScreenshotName & "_with_shadows.png"
set ScreenshotFinal to ScreenshotName & ".png"
tell application "Nimble Commander" to set windowID to id of window 1
do shell script "screencapture -x -o -tpng -l " & windowID & " " & ScreenshotWithoutShadows
moveFocusToDesktop()
do shell script "screencapture -x -R70,70,1280,800 -tpng " & ScreenshotWithShadows
do shell script "gm composite -geometry " & ScreenshotOffset & " " & ScreenshotWithoutShadows & " " & ScreenshotWithShadows & " " & ScreenshotFinal
do shell script "rm " & ScreenshotWithoutShadows
do shell script "rm " & ScreenshotWithShadows
2 changes: 2 additions & 0 deletions Docs/ScreenshotsAutomation/MacAppStore/screenshot3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
osascript screenshot3.scpt

0 comments on commit c390b72

Please sign in to comment.