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?
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
tellapplication "Finder" toactivate
delay 7
-- deselect any selections tellapplication "System Events" tokeystroke "a" using { command down , option down }
delay 0.5
-- Alfred action to open the 'right click' context menu in Finder tellapplication "System Events" tokeystroke "r" using { command down , shift down }
delay 2.5
-- selects 'Import from phone' menu item tellapplication "System Events" tokeystroke "i"
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.
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
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.
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
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.