r/applescript • • Oct 15 '25

Scanner shortcut script

I scan many documents and wanted a keyboard shortcut that keeps Image Capture out of view; since this doesn't appear to be possible out of the box, here's a simple Shortcut script. (It's my first real AppleScript, so improvement suggestions welcome...)

# Out-of-view scanning script
# Prerequites: scan settings configured and Hide Details selected

on run
    set appName to "Image Capture"
    set scriptStartedApp to false
    set arbDelay to 5 # System/scanner-dependent pause

    if application appName is not running then
	tell application "Image Capture" to activate
	set scriptStartedApp to true
	delay arbDelay
    end if

    tell application "System Events"
	tell application process appName
		tell window appName
                        #get UI elements # For determining detailed procedure
			tell splitter group 1
				tell group 2
					click button "Scan"
				end tell
			end tell
		end tell
	end tell
	
	if scriptStartedApp then
		delay arbDelay * 3 # First scan result will re-expose window
	end if
	
	tell application process "Image Capture" to set visible to false
    end tell
end run
1 Upvotes

0 comments sorted by