Canon TR7500 series printer/scanner shell script to execute the scan so I could use Termius (a terminal app for iPhone) on an iPhone to log in to my mac via ssh and type "scan" to start scanning.

Sorry not a lot of explanation on this version
   scan -setup
Is what I would do on my phone if I went to the printer and turned it on.
Often it's not set up correctly when the scan app comes on, so this should set it up at 300dpi and TIFF
It also uses python to drag the active scan window to the right so the paper can be aligned on the edge closest to the control panel which is only needed for A4 size.

   scan -c color
   scan -c bw
Set color or black & white mode.
   scan document-20200524-page-1
results in this file:
   scan document-20200524-page-1.tiff
or if that file already exists:
   scan document-20200524-page-1 1.tiff


#!/bin/sh
args=$@
interval=2
timeout=120

if [ "$args" == "-h" ]; then
	echo " -c colour or bw to change colour mode"
	echo " -setup moves scanbox over to right for A4"
	exit 0
elif [ "$args" == "-setup" ]; then
	activatescanner=`osascript -e 'tell application "Canon TR7500 series" to activate'`
	sleep 1
	activatescanner=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to keystroke "3" using {command down}'`
	sleep 1
	overview=true
	i=0
	while $overview; do
		sleep $interval
		i=`expr $i + $interval`
		btn=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return name of button 2 of window "Scanner"'`
		if [ "$btn" == "Cancel" ]; then
			printf "Scanning Overview... $i\r"
		elif [ "$btn" == "" ]; then
			printf "Starting Scanner... $i\r"
		else
			echo "Overview Scanned in about $i seconds."
			overview=false
		fi
		if [ $i -gt $timeout ]; then
			echo "Took over $timeout seconds. Is something wrong?"
			overview=false
			exit 1
		fi
	done
fi

scanmode=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return value of pop up button 1 of scroll area 1 of window "Scanner"'`
scankind=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return value of pop up button 2 of scroll area 1 of window "Scanner"'`
resolution=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return value of pop up button 3 of scroll area 1 of window "Scanner"'`
customsz=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return value of checkbox 1 of scroll area 1 of window "Scanner"'`

if [ "$scanmode" != "Flatbed" ]; then
	click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click of pop up button 1 of scroll area 1 of window "Scanner"
tell application "System Events" to tell process "Canon TR7500 series" to click menu item "Flatbed" of menu 1 of pop up button 1 of scroll area 1 of window "Scanner"'`
	echo "Waiting for Overview Scan"
	overview=true
	i=0
	while $overview; do
		sleep $interval
		i=`expr $i + $interval`
		btn=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return name of button 2 of window "Scanner"'`
		if [ "$btn" == "Cancel" ]; then
			printf "Scanning Overview... $i\r"
		else
			echo "Overview Scanned in approximately $i seconds."
			overview=false
		fi
		if [ $i -gt $timeout ]; then
			echo "Took over $timeout seconds. Is something wrong?"
			overview=false
			exit 1
		fi
	done
fi
if [ "$resolution" != "300" ]; then
	click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click of pop up button 3 of scroll area 1 of window "Scanner"
tell application "System Events" to tell process "Canon TR7500 series" to click menu item "300" of menu 1 of pop up button 3 of scroll area 1 of window "Scanner"'`
fi
if [ "$customsz" == "1" ]; then
	click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click checkbox 1 of scroll area 1 of window "Scanner"'`
fi

if [ "$args" == "-c" ]; then
	echo "passing -c requires value colour or bw"
	exit 1
elif [ "$args" == "-c colour" ]; then
	if [ "$scankind" != "Colour" ]; then
		click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click of pop up button 2 of scroll area 1 of window "Scanner"
tell application "System Events" to tell process "Canon TR7500 series" to click menu item "Colour" of menu 1 of pop up button 2 of scroll area 1 of window "Scanner"'`
	fi
	echo "Next scans will be Colour"
	exit 0
elif [ "$args" == "-c color" ]; then
	if [ "$scankind" != "Colour" ]; then
		click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click of pop up button 2 of scroll area 1 of window "Scanner"
tell application "System Events" to tell process "Canon TR7500 series" to click menu item "Colour" of menu 1 of pop up button 2 of scroll area 1 of window "Scanner"'`
	fi
	echo "Next scans will be Colour"
	exit 0
elif [ "$args" == "-c bw" ]; then
	if [ "$scankind" != "Black & White" ]; then
		click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click of pop up button 2 of scroll area 1 of window "Scanner"
tell application "System Events" to tell process "Canon TR7500 series" to click menu item "Black & White" of menu 1 of pop up button 2 of scroll area 1 of window "Scanner"'`
	fi
	echo "Next scans will be Black and White"
	exit 0
elif [ "$args" == "-setup" ]; then
	sawidth=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return (item 1 of (size of scroll area 1 of window "Scanner" as list)) as string'`
	saheight=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return (item 2 of (size of scroll area 1 of window "Scanner" as list)) as string'`
	winx=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return (item 1 of (position of window "Scanner" as list)) as string'`
	winy=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return (item 2 of (position of window "Scanner" as list)) as string'`
	winw=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return (item 1 of (size of window "Scanner" as list)) as string'`
	winh=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return (item 2 of (size of window "Scanner" as list)) as string'`

	midwinx=$(( $winx + ($winw - $sawidth) / 2))
	midwiny=$(( $winy + $winh / 2))
	dragx=100
	midwinxfinal=$(( $midwinx + $dragx ))
	activatescanner=`osascript -e 'tell application "Canon TR7500 series" to activate'`
	python <<HEREDOC
#!/usr/bin/python
import sys
import time
from Quartz.CoreGraphics import * # imports all of the top-level symbols in the module
def mouseEvent(type, posx, posy):
 theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
 CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
 mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclickdn(posx,posy):
 mouseEvent(kCGEventLeftMouseDown, posx,posy);
def mouseclickup(posx,posy):
 mouseEvent(kCGEventLeftMouseUp, posx,posy);
def mousedrag(posx,posy):
 mouseEvent(kCGEventLeftMouseDragged, posx,posy);
ourEvent = CGEventCreate(None); 
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
mouseclickdn($midwinx, $midwiny);
mousedrag($midwinxfinal, $midwiny);
mouseclickup($midwinxfinal, $midwiny);
time.sleep(1);
mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
HEREDOC
	echo "Ready to scan in $scankind"
	exit 0
else
	setname=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to set focused of text field 1 of scroll area 1 of window "Scanner" to true'`
	setname=`osascript -e "tell application \"System Events\" to tell process \"Canon TR7500 series\" to set value of text field 1 of scroll area 1 of window \"Scanner\" to \"$args\""`
	setname1=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to confirm text field 1 of scroll area 1 of window "Scanner"'`
	setname1=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to set focused of text field 1 of scroll area 1 of window "Scanner" to false'`
fi

format=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return value of pop up button 6 of scroll area 1 of window "Scanner"'`
if [ "$format" != "TIFF" ]; then
	click=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click of pop up button 6 of scroll area 1 of window "Scanner"
tell application "System Events" to tell process "Canon TR7500 series" to click menu item "TIFF" of menu 1 of pop up button 6 of scroll area 1 of window "Scanner"'`
fi


scanpath=~/Pictures
extension=".tiff"
scanning=true
i=0
btn=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return name of button 3 of window "Scanner"'`
if [ "$btn" == "Scan" ]; then
	btn=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to click button "Scan" of window "Scanner"'`
else
	echo "Not ready to Scan, 'Scan' button shows '$btn'. Check scanner and try again."
	exit 1
fi

while $scanning; do
	sleep $interval
	i=`expr $i + $interval`
	btn=`osascript -e 'tell application "System Events" to tell process "Canon TR7500 series" to return name of button 3 of window "Scanner"'`
	if [ "$btn" == "Cancel" ]; then
		printf "Scanning in $scankind... $i\r"
	else
		echo "Scanned in approximately $i seconds."
		scanning=false
	fi
	if [ $i -gt $timeout ]; then
		echo "Took over $timeout seconds. Is something wrong?"
		scanning=false
		exit 1
	fi
done


-- previous scanner page