Question

Hey guys, Now I was wondering how I can make my scan go ever faster, it takes around 6-7 seconds for the image to be found and clicked on.

    Func Prison()
       $prison = _ImageSearch("Admit1.BMP",0,$x,$y,50)
       $prison1 = _ImageSearch("Admit2.BMP",0,$x1,$y1,50)
       $prison2 = _ImageSearch("Admit3.BMP",0,$x2,$y2,50)
             If $prison = 1 Then
             MouseClick("left", $x, $y)
               sleep(2000)
                  send("{ENTER}")
               sleep(3000)
                  send("{NUMPAD2}")
               sleep(1000)
                  Send("{ENTER}")
               sleep(1000)
                  If WinActive("Sidan på www.xxxxxx.nu säger:", "Du har inte råd!") Then
                     sleep(1000)
                     MouseClick("left", 326, 346)
                     sleep(1000)
                     MouseClick("left", 446, 273)
                     sleep(1000)
                     MouseClick("left", 477, 326)
                     sleep(600)
                     send("{8}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(600)
                     MouseClick("left", 666, 326)
                     sleep(1000)
                     send("{NUMPAD2}")
                     sleep(1000)
                  EndIf
             ElseIf $prison1 = 1 Then
             MouseClick("left", $x1, $y1)
               sleep(2000)
                  send("{ENTER}")
               sleep(3000)
                  send("{NUMPAD2}")
               sleep(1000)
                  Send("{ENTER}")
               sleep(1000)
                  If WinActive("Sidan på www.xxxxxx.nu säger:", "Du har inte råd!") Then
                     sleep(1000)
                     MouseClick("left", 326, 346)
                     sleep(1000)
                     MouseClick("left", 446, 273)
                     sleep(1000)
                     MouseClick("left", 477, 326)
                     sleep(600)
                     send("{8}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(600)
                     MouseClick("left", 666, 326)
                     sleep(1000)
                     send("{NUMPAD2}")
                     sleep(1000)
                  EndIf
             ElseIf $prison2 = 1 Then
             MouseClick("left", $x2, $y2)
               sleep(2000)
                  send("{ENTER}")
               sleep(3000)
                  send("{NUMPAD2}")
               sleep(1000)
                  Send("{ENTER}")
               sleep(1000)
                  If WinActive("Sidan på www.xxxxxx.nu säger:", "Du har inte råd!") Then
                     sleep(1000)
                     MouseClick("left", 326, 346)
                     sleep(1000)
                     MouseClick("left", 446, 273)
                     sleep(1000)
                     MouseClick("left", 477, 326)
                     sleep(600)
                     send("{8}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(200)
                     send("{0}")
                     sleep(600)
                     MouseClick("left", 666, 326)
                     sleep(1000)
                     send("{NUMPAD2}")
                     sleep(1000)
                  EndIf
               EndIf
    EndFunc

Was it helpful?

Solution

Make sure you are using smallest possible picture and try to avoid variations. I guess your script is slow because your search targets are moving/changing. Thats probably the reason why it doesn't find it at once. Thats ehy you use variation? In order to speed up image detection, you should use smaller search area. You can do that by using

$result = _ImageSearchArea("recycle2.bmp",1,0,0,200,200,$x1,$y1,0)

In this example it will search a square 200x200 on the top left corner of the screen.

You can also consider using PixelSearch, its much quicker and you can also narrow the search area.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top