Jump to content

How to run multiple autoit without losing performance?


Recommended Posts

$start = True

HotKeySet("{NUMPAD1}","Press")
HotKeySet("{p}", "Terminate")

While 1
    Sleep(1000)
WEnd

Func Press()
    If $start Then
        $start = False
        While 1
            $coord = PixelSearch(2986, 284, 2986, 284, 0xFFE595,4)
            If IsArray($coord) Then
                Send("{SPACE}")
                MsgBox(0, "","Desktop")
                $start = True
                ExitLoop
            EndIf
        WEnd
    EndIf
EndFunc

Func Terminate()
    MsgBox(4096, "", "end")
    Exit 0
EndFunc

Since there is no way to search for more than one pixel in one program, I run several such programs.
But no matter if 10 or 3 programs are running, the pixel search becomes very bad as soon as more than one program is running.
I use pixel search to find certain frames in my video and cut them out. 60 frames per second.
Pixel search can handle that speed. 
But if run 2 or more programs it starts to run slower. I don't understand what the problem is.
My video is 3+ hours long and I need to check 27 pixels to find certain frames. Checking each pixel separately would be a living hell and a waste of time.
Maybe there is a way to run at least 3 or 5 programs at the same time.

Link to post
Share on other sites
26 minutes ago, petrovu4 said:

Since there is no way to search for more than one pixel in one program

False.  You can search as many pixels as you want into a single script.

PixelSearch can be quite slow with Win10 +.  You could consider using my screen scraping UDF (see my signature).

 

Link to post
Share on other sites
30 minutes ago, Nine said:

False.  You can search as many pixels as you want into a single script.

I tried similar scripts, but they didn't work.

HotKeySet("{NUMPAD2}","Press2")
HotKeySet("{NUMPAD1}","Press1")

Func Press1()
    While 1
        $coord = PixelSearch(2986, 284, 2986, 284, 0xFFE595,4)
        If IsArray($coord) Then
            Send("{SPACE}")
            MsgBox(0, "","1")
            ExitLoop
        EndIf
    WEnd
EndFunc
Func Press2()
    While 1
        $coord = PixelSearch(1186, 912, 1186, 912, 0x24E602,2)
        If IsArray($coord) Then
            Send("{SPACE}")
            MsgBox(0, "","2")
            ExitLoop
        EndIf
    WEnd
EndFunc

Then I read somewhere that autoit is not multi-threaded, so it can't run multiple loops simultaneously.
I need all colors to be checked simultaneously, not sequentially.
And I also can't find a way to run multiple loops at once, except through a key.

Even if you can run multiple cycles and I'm wrong. Then how do you run them? I haven't found a way to do something like

Press1() ; calls a function without waiting for the end
Press2() ; calls a function without waiting for the end
Press3() ; calls a function without waiting for the end
....

There is Call("fun") but it stops the code

 

Link to post
Share on other sites

I installed Windows 7, and I had ~100,000 there.
But after I downloaded something I got the same ~60 as on Windows 10.
Test code(NOT MY):

$t = TimerInit()
$n = 0
While TimerDiff($t) < 1000
    $n += 1
    pixelsearch(500, 500, 500, 500, 0)
WEnd
MsgBox(0,"",$n & " Repetitions done" & @CRLF)

That is, the program worked fine on 7, but after I downloaded something, some software, with new tests there was the same problem as on 10.
My point is that maybe the problem is not in the operating system at all, but in some program.
I have already made the video I need, but can someone not too lazy to experiment with removing something like this:
sCREN.png.9a98a86595205459d58cc349c1542afb.png

Here's everything I had when it worked correctly:

photo.jpg.7817f19898e244d6493af3a5f7bd77a8.jpg
Honestly I don't understand anything about this, but maybe the problem is some software that just conflicts with PixelSearch, or limits it

Edited by petrovu4
Link to post
Share on other sites

On Win7 with classic theme it should be fast, on Win7 with Aero (DWM.EXE) things are slow, as with win10.

I havent tried myself on Win10, but on win7 you could just open taskmanager and shut down DWM.EXE and pixel searches was fast again.

/edit

just read around and it seems that DWM is under services now, and can still be disabled (according to the web, havent tried myself)

But Win7 with classic theme is fast, i dont know if there is a classic theme for win10/11, i'm running unactivated windows so cant check, else try and disable dwm in sevices.

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...