CleanScreenCapture-version 1.1.2

v1.1.2:

v.1.0.0:

# Hide Desktop Icon
do shell script "defaults write com.apple.finder CreateDesktop -bool false;killall Finder"

# Auto Hide & Show MenuBar
tell application "System Preferences" to reveal the ¬
	anchor named "main" of ¬
	pane id "com.apple.preference.general"

tell application "System Events" to tell ¬
	process "System Preferences" to tell ¬
	window "general" to tell ¬
	checkbox "Automatically hide and show the menu bar
" to ¬
	perform action "AXPress"

quit application "System Preferences"

Chinese is my System Language,so I'm not gonna share my macro as exported files.
You may try this script in your own macro to make it work.

the only potential problem is “Automatically hide and show the menu bar”,which is translated by google from “自动隐藏和显示菜单栏”

Shift + Control + 3 as hotkey trigger

the standalone AppleScript code, you can use it in KM、BTT、BetterAndBetter and so on.

# 初始状态:显示桌面图标、显示菜单栏、隐藏程序坞(Dock)
 
# 隐藏桌面图标
do shell script "defaults write com.apple.finder CreateDesktop -bool false;killall Finder"
 
# 自动隐藏和显示菜单栏
tell application "System Preferences" to reveal the ¬
        anchor named "main" of ¬
        pane id "com.apple.preference.general"
 
tell application "System Events" to tell ¬
        process "System Preferences" to tell ¬
        window "通用" to tell ¬
        checkbox "自动隐藏和显示菜单栏" to ¬
        perform action "AXPress"
 
quit application "System Preferences"
 
delay 0.2
 
# 调用系统快捷键 Shift + Command + 3截取全屏# 1 想区域截图请把key code 20 改为21(对应键盘上的4)或22(对应键盘上的5)
# 2 想把截图截取到剪贴板,请在花括号内增加【control down,】
# 上述1、2可以混用,请自由发挥
tell application "System Events"
        keystroke (key code 20 using {shift down, command down})
end tell
 
# 延迟10秒,可自行更改
delay 10
 
# 显示桌面图标
do shell script "defaults write com.apple.finder CreateDesktop -bool true;killall Finder"
 
# 自动隐藏和显示菜单栏
tell application "System Preferences" to reveal the ¬
        anchor named "main" of ¬
        pane id "com.apple.preference.general"
 
tell application "System Events" to tell ¬
        process "System Preferences" to tell ¬
        window "通用" to tell ¬
        checkbox "自动隐藏和显示菜单栏" to ¬
        perform action "AXPress"
 
quit application "System Preferences"
1 Like

Hi @suliveevil, since I avoid working with too many shortcuts, I have here again a possibility with a script.
The screenshot also includes date and time.
It's not from me, but here from the forum.

Screenshot Desktop Script with Hide Items.kmmacros (3,1 KB)
Screenshot%20Desktop%20Script%20with%20Hide%20Items

2019_01_06%20Support%20

1 Like

Thanks for sharing.
This macro is really awesome ! It takes far less time to work, great shell script.

I'm glad to use

do shell script "chflags -h hidden ~/Desktop/*"

rather than

defaults write com.apple.finder CreateDesktop -bool false;killall Finder

My macro is a little bit radical,which will hide your desktop and menubar(菜单栏) ,and it assume you set MenuBar Not AutoHide and the Dock AutoHide already.

Since I'm not very good with AppleScript, thanks all alone @Tom.

Thanks to KM you can very well merge single scripts to a macro and then you have to hide the docks and the menu bar too :wink:
The script to hide the menu bar is partly in a german macOS. Maybe there is someone here who can summarize this.

Screenshot Desktop Script with Hide Items.kmmacros (6,2 KB)
Screenshot%20Desktop%20Script%20with%20Hide%20Items

2019_01_07%20Support%20

1 Like

I merged my improvement with your code.
Now it is a full function AppleScript, just bind it to any trigger you want and run this AppleScript.
It will hide GUI scripting process, meanwhile you can do other things.

-- Clean ScreenCapture v1.1.0 - German
-- assume your default setting:Show Desktop Icon、MenuBar, AutoHideDock

-- Hide Desktop Icon
do shell script "chflags -h hidden ~/Desktop/*"

-- Toggle AutoHide MenuBar
tell application "System Preferences" to reveal the ¬
	anchor named "main" of ¬
	pane id "com.apple.preference.general"
tell application "System Events" to tell ¬
	process "System Preferences" to tell ¬
	window "Allgemein" to tell ¬
	checkbox "Menüleiste automatisch ein- und ausblenden" to ¬
	perform action "AXPress"
delay 0.2

-- use System Keyboard Shotcut:Shift + Command + 3
-- 1 Area screenshot,change key code 20 to 21(on Device it is 4) or 22(on Device it is 5)
-- 2 Capture Screenshot to Clipboard,add 【control down,】 in curly braces

tell application "System Events"
	keystroke (key code 20 using {shift down, command down})
end tell

-- delay 10 seconds,you can change that at your wish
delay 10

-- Show Desktop Icon
do shell script "chflags -h nohidden ~/Desktop/*"

-- Toggle AutoHide MenuBar
tell application "System Preferences" to reveal the ¬
	anchor named "main" of ¬
	pane id "com.apple.preference.general"
tell application "System Events" to tell ¬
	process "System Preferences" to tell ¬
	window "Allgemein" to tell ¬
	checkbox "Menüleiste automatisch ein- und ausblenden" to ¬
	perform action "AXPress"
quit application "System Preferences"
1 Like

if your everyday Dock is not AutoHide, you can add the code at the begin and end

tell application "System Events" to tell dock preferences to set autohide to not autohide

simplified from your

tell application "System Events"
	tell dock preferences to set autohide to not autohide
end tell
1 Like

Thank you so much for this great improvement :+1:
It works very well for me. Since I like to use the visible clipboard of the Yoink app for my screenshots, I changed the AppleScript a little bit.

2019_01_08%20Support%20

Wow, nice done !:clap:

This is how I use it: I created 6 macros to capture screen, because there are 6 system keyboard shortcuts.
A little bit silly silly but easy to remember simple to use:

Capture to file:
Shift+Control+3 to trigger macro in which keystroke system keyboard shortcut Shift+Command+3
Shift+Control+4 to trigger macro in which keystroke system keyboard shortcut Shift+Command+4
Shift+Control+5 to trigger macro in which keystroke system keyboard shortcut Shift+Command+5

Capture to Clipboard:
Shift+Control+Option+3 to trigger macro in which keystroke system keyboard shortcut Shift+Command+Option+3
Shift+Control+Option+4 to trigger macro in which keystroke system keyboard shortcut Shift+Command+Option+4
Shift+Control+Option+3 to trigger macro in which keystroke system keyboard shortcut Shift+Command+Option+5

If you wanna capture screen only with the frontmost app, you may try this:

-- System Keyboard Shortcut: Option+Command+H, Hide all apps but the frontmost app
tell application "System Events" to key code 4 using {option down, command down}
1 Like

v1.1.2

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

-- 截图增强v1.1.2
-- 默认用户初始状态:显示桌面图标、显示菜单栏、自动隐藏程序坞(Dock)
-- update: 添加注释(序号)

-- 1. 隐藏其他所有app
-- tell application "System Events"
-- keystroke (key code UInt16(4) using {option down, command down})
-- end tell

-- 2. 隐藏桌面图标
do shell script "chflags -h hidden ~/Desktop/*"

-- 3. 自动隐藏和显示菜单栏
tell application "System Preferences" to reveal the ¬
	anchor named "main" of ¬
	pane id "com.apple.preference.general"
tell application "System Events" to tell ¬
	process "System Preferences" to tell ¬
	window "通用" to tell ¬
	checkbox "自动隐藏和显示菜单栏" to ¬
	perform action "AXPress"
delay 0.2

-- 4. 调用系统快捷键 Shift + Command + 3截取全屏,下述1、2可以混用,请自由发挥
-- 4.1 想区域截图请把key code 20 改为21(对应键盘上的4)或22(对应键盘上的5)
-- 4.2 想把截图截取到剪贴板,请在花括号内增加【control down,】

tell application "System Events"
	keystroke (key code 20 using {shift down, command down})
end tell

-- 延迟10秒,可自行更改
delay 10

-- 5. 显示桌面图标
do shell script "chflags -h nohidden ~/Desktop/*"

-- 6. 自动隐藏和显示菜单栏
tell application "System Preferences" to reveal the ¬
	anchor named "main" of ¬
	pane id "com.apple.preference.general"
tell application "System Events" to tell ¬
	process "System Preferences" to tell ¬
	window "通用" to tell ¬
	checkbox "自动隐藏和显示菜单栏" to ¬
	perform action "AXPress"
quit application "System Preferences"
1 Like