How to do this in Automagic

Post your questions and help other users.

Moderator: Martin

robchoc
Posts: 81
Joined: 20 Jun 2018 12:38

How to do this in Automagic

Post by robchoc » 01 Nov 2018 12:36

In Tasker, I was able to create a screenshot of a cropped area, for example, a play button. It used good old autoinput, screen capture and crop to achieve this.
This would then be compared to another cropped screenshot to see if it is the same image.

This would be used in instances where you are running an app and if a certain button appeared it would be pressed.

Is there a way to replicate this in Automagic?

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: How to do this in Automagic

Post by digitalstone » 01 Nov 2018 13:36

The action called "Take Screenshot" is experimental but worth a try. You will have to save the file to storage though. Which you then can delete after the process if you will, or just leave it there so it'll be rewritten next time.
Then use action "Init Variable Image File" to store the image from a file information inside a variable.
Then use that variable inside action "Modify Image" that you place after that, where you can crop your screenshot.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to do this in Automagic

Post by Desmanto » 01 Nov 2018 15:21

It can be done as answered by digitalstone, but it will be very slow. You have to save the image file again at the last and compared it to the exisiting one. But you have to do it exactly right. So probably you want to run the flow once until you get the exact portion of the cropped size in variable {image_data}. Pass this to hash() and get the hash value. next time, you only need to check whether the next {image_data} has the same hash as the first one.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

robchoc
Posts: 81
Joined: 20 Jun 2018 12:38

Re: How to do this in Automagic

Post by robchoc » 01 Nov 2018 16:42

Could it run every 10 seconds and is it only Android 9 as that will decide if I have to use the Autoinput plugin instead as that works with Android 6.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to do this in Automagic

Post by Desmanto » 01 Nov 2018 16:55

Action Take screenshot already available since LP 5.0, it uses Media Projection API, will prompt something like "Automagic is starting to recording your screen ....". You can check don't show again for automagic (so no need to confirm again later). The new takeScreenshot() is available on CUI only for android pie. You can't use this before Pie. AFAIK, Automagic v1.36 completely eliminate the need of autoinput, since it covers everything autoinput can do.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

robchoc
Posts: 81
Joined: 20 Jun 2018 12:38

Re: How to do this in Automagic

Post by robchoc » 01 Nov 2018 20:46

I'm very close, the only problem I have is that each time I do the hash() I get a different number even if the 2 images are the same.

So h1 == h2 does not work as they will always be different numbers each time I run the flow.

[url=https://ibb.co/n1E5yL][img]https:/ ... .png[/img][/url]

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: How to do this in Automagic

Post by digitalstone » 01 Nov 2018 21:07

What happens when you generate and show hashtags multiple times for image1 and the same for image2 ?
Do they keep being the same for each image?
Sorry, just my 2 cents here.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

robchoc
Posts: 81
Joined: 20 Jun 2018 12:38

Re: How to do this in Automagic

Post by robchoc » 01 Nov 2018 21:31

When I do multiple hash for image1 they are the same.
Also when I do multiple hash for image2 they are the same.

But image1 hash is never the same as image2 hash.

Is a hash based on filename too? so if they are called different names but the same picture will this give a different hash?

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: How to do this in Automagic

Post by digitalstone » 01 Nov 2018 21:51

That should not be the case.
To get further in this troubleshooting you should limit as many factors as possible.
In this case i would take 1 picture, and make a copy of that file with a different filename to test the hashcodes out on those.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

robchoc
Posts: 81
Joined: 20 Jun 2018 12:38

Re: How to do this in Automagic

Post by robchoc » 01 Nov 2018 22:00

Just copied the image gave it a different name and got 2 different hashes.

Post Reply