Page 1 of 2

How to do this in Automagic

Posted: 01 Nov 2018 12:36
by robchoc
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?

Re: How to do this in Automagic

Posted: 01 Nov 2018 13:36
by digitalstone
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.

Re: How to do this in Automagic

Posted: 01 Nov 2018 15:21
by Desmanto
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.

Re: How to do this in Automagic

Posted: 01 Nov 2018 16:42
by robchoc
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.

Re: How to do this in Automagic

Posted: 01 Nov 2018 16:55
by Desmanto
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.

Re: How to do this in Automagic

Posted: 01 Nov 2018 20:46
by robchoc
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]

Re: How to do this in Automagic

Posted: 01 Nov 2018 21:07
by digitalstone
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.

Re: How to do this in Automagic

Posted: 01 Nov 2018 21:31
by robchoc
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?

Re: How to do this in Automagic

Posted: 01 Nov 2018 21:51
by digitalstone
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.

Re: How to do this in Automagic

Posted: 01 Nov 2018 22:00
by robchoc
Just copied the image gave it a different name and got 2 different hashes.