Remote Camera trigger

Post your questions and help other users.

Moderator: Martin

Post Reply
eldron
Posts: 45
Joined: 27 Apr 2015 08:21

Remote Camera trigger

Post by eldron » 04 Jul 2016 19:31

Hi,
I have created a flow to use my smartwatch to take a picture with my phone.
I want to use the standard camera app and not the automagic "take picture" action, as I want to be able to set the focus and camera mode first.
So all I want automagic to do is to click the camera button to take the picture. I tried the control ui click(coordinates) action, but it does not work. I even double checked the coordinates on a screenshot (using photoshop). The flow executes, but it does nothing. I´m using a galaxy s4 and the stock camera app can also use the volume buttons to take a picture. So eventually I managed to get it to work by creating a flow that sets the default input method to automagic, follow by a control ui sendkey(25) and then it sets the input method back to the normal keyboard. But this solution only works on a rooted phone, so I can´t use it on a different phone that´s not rooted.
The solution works, but I was wondering if there isn´t a more elegant way of doing this? And I don´t really understand why the click command doesn´t do the trick...?

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Remote Camera trigger

Post by MURTUMA » 05 Jul 2016 03:14

Depending on how the target app's ui has been made the Control ui action may or may not work. If it doesn't work, there's not much you can do without root.

One workaround for rooted device is execute root command action: "input tap <x> <y>".

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Remote Camera trigger

Post by Bushmills » 05 Jul 2016 08:04

Check whether your camera app offers shortcuts to various actions, by creating an Automagic action "Shortcut", them looking at the list of apps whether your camera app is among those.

eldron
Posts: 45
Joined: 27 Apr 2015 08:21

Re: Remote Camera trigger

Post by eldron » 05 Jul 2016 12:00

Thanks for your replies,
@Murtuma: I tried your idea, but it also doesn´t work. I double checked the coordinates with the developer tool overlay and even swapped the x and y coordinates to make sure.
@bushmills
Tried your idea as well, but the stock camera app is not even listed in the shortcuts list. Was worth a try though.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Remote Camera trigger

Post by Martin » 05 Jul 2016 13:28

Unfortunately I don't have an S4 anymore but the stock camera app on an S5 seems to not provide the required information for control UI to press buttons (Show overlay control->INFO in Control UI shows no green areas at all in the camera app).
Your solution to simulate keyboard input is probably the best one.

eldron
Posts: 45
Joined: 27 Apr 2015 08:21

Re: Remote Camera trigger

Post by eldron » 05 Jul 2016 14:36

@Martin
I also tried the "show overlay" and it doesn´t show anything on the S4 camera app either.
Just for my understanding - I always thought that the control ui click command simulates a mouse click? But wouldn´t it then have to work in any app?
I´ll try it with a mouse when I get back from work to see what happens ;-)

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Remote Camera trigger

Post by Martin » 07 Jul 2016 18:57

Technically it's not simulating a mouse click or touch on the display. Each regular control element like a button or a text field supports some high level commands like 'click', 'longclick' or 'setText' which are meant to be used by apps designed to help people with disabilities.
Automagic can query the supported commands for each control and the bounding rectangle on screen using the accessibility service. This is more or less the information that's provided when the overlay control is used.
When a script in action Control UI is executed, Automagic tries to find the control element at the given coordinate (or by the contained text). Automagic then executes the desired high level command, but it does not actually simulate a touch on coordinate X/Y.
Apps that use the regular control elements provided by the official Android API usually work quite good since the high level commands are directly built-in to those controls.
Apps like games (or the Samsung camera app) can also decide to use their own home grown control elements that don't support the high level commands. Automagic therefore can not show any information for such controls or execute any command.
Android N seems to allow accessibility services to simulate touch gestures. So it might be possible that I can extend Control UI to take advantage of the new features and make clicks also work in the Samsung camera app.

User avatar
mbirth
Posts: 80
Joined: 17 Mar 2016 00:02
Location: Berlin, Germany
Contact:

Re: Remote Camera trigger

Post by mbirth » 11 Jul 2016 22:30

Just FYI: Simulating an ENTER keypress could work, too. At least that's what my remote bluetooth trigger does.
BlackBerry KEY2, Android 8.1.0

Post Reply