Posts: 36
Threads: 12
Joined: Dec 2018
Is it possible to scan for multiple images at once (maybe by use of threading) and priorize certain images over others?
If so, could someone please help me with a little example? I only know how to use basic beginner code.
If it doesnt work with LibreAutomate, does it work with QM?
Posts: 12,073
Threads: 140
Joined: Dec 2002
In the "Find image..." tool capture an image and click More -> Add to array. Then capture more images. It will create code like this.
var w = wnd.find(1, "name", "class");
IFImage[] image = {
@"image:",
@"image:",
};
var im = uiimage.find(1, w, image);
im.MouseMove();
uiimage.find does not use multiple threads. Probably it would not make much faster. The slow part usually is getting screen pixels.
Posts: 36
Threads: 12
Joined: Dec 2018
Thank you! I will try that.
Your answer brings me to an idea. Would it be possible to automatically take a screenshot (in the background) and get the pixels from there with threads?
Maybe the screenshot could be scraped by each thread then. Would this be faster?
Posts: 12,073
Threads: 140
Joined: Dec 2002
Usually the slowest part is taking a screenshot (aka "screen pixels"). But the "find" part can be slower if there are many images in the array; then multiple threads could make faster. I tested it, but it does not work, because uiimage.find locks the bitmap and other threads can't access it.
Posts: 36
Threads: 12
Joined: Dec 2018
02-11-2023, 10:34 AM
(This post was last modified: 02-11-2023, 10:36 AM by Remotehorst23.)
Thank you for testing it! Do you think it would be possible to save copies of the screenshot for each thread? If i loose one or two seconds for this to gain 8 or 16 times faster scan time this would make scanning so much faster. I imagine a tool that automatically makes screenshots, copies them for each thread and updates or replaces them after all threads finished one scan loop.
Maybe it would be possible to even have 2 scans for each thread and they are fast enough to notice if something changed after a few seconds? It would be so awesome if this works!
Edit: No pressure. Its just an idea. Im not a Programmer but i know that programming with threads is not that easy.
Posts: 12,073
Threads: 140
Joined: Dec 2002
Possible, but not thread-safe, and not the fastest way.
In next program/library version uiimage.find can search in multiple threads. Use flag IFFlags.Parallel. Can by 2-3 times faster when there are many images.
Posts: 36
Threads: 12
Joined: Dec 2018
Thats cool! Im really curious how this behaves when i use it. Thank you!