Ideas to trigger Continuity Camera (Import from iPhone)

I thought I'd ask for ideas on a better solution. Right now I'm thinking I have to have KM simulate mouse clicks.

I want to initiate Continuity Camera from Finder so I can take photos from my iPhone that get dropped directly into a specific folder. Any ideas on if it can be scripted without having to rely on mouse clicks?

Thanks

When I try to trigger Continuity Camera from an AppleScript ( using simulated keystrokes ) the camera activates, and I'm able to take a photo on my iPhone, but it never shows up on my Mac. When I do the same keystrokes using the actual keyboard, it works, and the photo shows up on my Mac. Any ideas how I can debug why the photo does not show up when using the script, or any ideas on a better approach to use Continuity Camera? Thanks

tell application "Finder" to activate

delay 7

-- deselect any selections
tell application "System Events" to keystroke "a" using { command down , option down }

delay 0.5

-- Alfred action to open the 'right click' context menu in Finder
tell application "System Events" to keystroke "r" using { command down , shift down }

delay 2.5

-- selects 'Import from phone' menu item
tell application "System Events" to keystroke "i"

delay 2.5

-- 'Enter' to select submenu
tell application "System Events" to key code 76

delay 2.5

-- 'Enter' to select 'Take Photo'
tell application "System Events" to key code 76

I'm working with this AppleScript to put an image from iPhone X into a folder in the Finder @woof...

tell application "System Events"
	tell application process "Finder"
		set _selection to value of attribute "AXFocusedUIElement" --focused element (selected element)
		tell _selection to perform action "AXShowMenu" --contextual menu
	end tell
	delay 0.2
	keystroke "Importieren" --type to select contextual menu item
	key code 124
	keystroke return --select it by hitting return
end tell 

since I am using a german macOS, please change "Importieren" to Import or according to your macOS.

Here is an example that it really works :wink:

https://cl.ly/9ecc94fd2a95

Since it's a little fast, here in slow motion :nerd_face:

2018_12_05%20Support%20%25filltop%25

1 Like

Thank you! I ended up having to insert a couple of 'delay' statements to make it work on my system.

tell application "System Events"
    tell application process "Finder"
        set _selection to value of attribute "AXFocusedUIElement" --focused element (selected element)
        tell _selection to perform action "AXShowMenu" --contextual menu
    end tell
    delay 2
    keystroke "Import" --type to select contextual menu item
    key code 124
    delay 1
    keystroke return --select it by hitting return
end tell
1 Like

I'm glad if I could help @woof.
If you want the picture directly on your desktop, I changed the AppleScript a little bit.
just move the mouse cursor to a free space on the Finder desktop and open the macro.

iPhone X Import.kmmacros (2,7 KB)
08)X%20Import

https://cl.ly/4c8b21a8a4a9

Thanks, I made a minor improvement that just 'deselects' anything in the finder window because as you know if a file is selected, the Import from iPhone menu items are disabled.

	tell application "System Events"
	tell application process "Finder"
		keystroke "a" using {command down, option down}
		delay 0.2
		set _selection to value of attribute "AXFocusedUIElement" --focused element (selected element)
		tell _selection to perform action "AXShowMenu" --contextual menu
	end tell
	delay 1
	keystroke "Import" --type to select contextual menu item
	key code 124
	delay 1
	keystroke return --select it by hitting return
end tell
1 Like

Thanks to your question here in the forum @woof I thought again about the function "Continuity Camera".
Unfortunately this function is not available in all apps. Then I am always on the Mac via Ethernet in the Internet.

In the macro I implemented the following:

  • the front app is minimized
  • the Finder is activated
  • Wifi activated
  • the image is imported with the "Continuity Camera" function
  • The system returns to the last app.
  • Wifi is disabled & Ethernet enabled

The Hazel rules copy the image to a Finder folder (may require later access) and renames the image (Video below).
It is then passed to the Yoink app and allows me to access and paste this image at any time.

Continuity Camera.kmmacros (53,8 KB)

In this example video I use a macro to insert an image into the Snagit app:

https://cl.ly/eb706850930a

This works nicely for me… (on Big Sur)