Jump to content

A way to make this pixelsearch faster?


lolp1
 Share

Recommended Posts

Is there a way to make this current code any faster? (Any faster at all, helps)

Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
HotKeySet("{INSERT}", "Aim")
HotKeySet("{esc}", "_Exit")

While 1
    Sleep(0)
    Wend

Func aim()
$searchcolor = 8716139
While 1
    $coord = PixelSearch(10, 10, 800, 580, $searchcolor)
    While IsArray($coord)
        MouseMove($coord[0], $coord[1], 0)
        MouseClick("Left")
        $coord = PixelSearch($coord[0] - 10, $coord[1] - 10, $coord[0] + 10, $coord[1] + 10, $searchcolor)
    WEnd
WEnd
Endfunc

Func _Exit()
    Exit
EndFunc
Link to comment
Share on other sites

Is there a way to make this current code any faster? (Any faster at all, helps)

Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
HotKeySet("{INSERT}", "Aim")
HotKeySet("{esc}", "_Exit")

While 1
    Sleep(0)
    Wend

Func aim()
$searchcolor = 8716139
While 1
    $coord = PixelSearch(10, 10, 800, 580, $searchcolor)
    While IsArray($coord)
        MouseMove($coord[0], $coord[1], 0)
        MouseClick("Left")
        $coord = PixelSearch($coord[0] - 10, $coord[1] - 10, $coord[0] + 10, $coord[1] + 10, $searchcolor)
    WEnd
WEnd
Endfunc

Func _Exit()
    Exit
EndFunc
Can you reduce the area you are seaching over? Maybe split into several smaller areas.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks for the tips, I'll see what I can do.

Can you reduce the area you are seaching over? Maybe split into several smaller areas.

The area is about as small as it can get. (I'll try to get it down any more possible) also, severeal smaller areas would be slower(I think..)

IsArray is surely more complicated testing of result after PixelSearch and if it's inside While then it can be important.

I'll test that, but I dont think it will make a differnce.

Link to comment
Share on other sites

pls report if you found any way of speeding it up, its also one of the problems i am stuck with... Maybe, is there a limit how fast autoit loops/runs? if so can that limit be disabled?

That comment has pretty much no truthful basis. Simple loops will run extremely fast, the problem is not AutoIt's limitations, it is the loops you create.

While 1
    $start = TimerInit()
    ConsoleWrite(TimerDiff($start) & @CRLF)
WEndoÝ÷ Ù§¶­jwr¢ì"[y©h¢ajج®éâW¬²ØZM6h¥/â±ç(Û(l©º×«jwm«wöÉèµëÞ;¬¶Ø^)Ûø­µ©±«&jYZ§¶íg­¡Ú-ç(º{b    hGz·¢²l­jG¨mh³x2¢êìr¸©µ«­¢+Ù=ÁÐ ÅÕ½Ðí5½ÕÍ
½½É5½ÅÕ½Ðì°À¤)=ÁÐ ÅÕ½ÐíA¥á±
½½É5½ÅÕ½Ðì°À¤)=ÁÐ ÅÕ½Ðí5½ÕÍ
±¥­±äÅÕ½Ðì°À¤(í=ÁÐ ÅÕ½Ðí5½ÕÍ
±¥­½Ý¹±äÅÕ½Ðì°À¤í9½Ð¹)!½Ñ-åMÐ ÅÕ½Ðíí%9MIQôÅÕ½Ðì°ÅÕ½Ðí¥´ÅÕ½Ðì¤)!½Ñ-åMÐ ÅÕ½ÐííÍôÅÕ½Ðì°ÅÕ½Ðí}á¥ÐÅÕ½Ðì¤()]¡¥±Ä(M±À ÄÀ¤íÍÕÍÑ¥±ÍÁ¥ÌÄÀµÌ)]¹()Õ¹¥´ ¤($ÀÌØíÍÉ¡½±½ÈôàÜÄØÄÌä(%]¡¥±Ä($$ÀÌØí½½ÉôA¥á±MÉ  ÄÀ°ÄÀ°àÀÀ°ÔàÀ°ÀÌØíÍÉ¡½±½È°ÄÀ¤ì¥¹ÉÍÑ¡Í¡Ùɥѥ½¸Ñ¼ÍÁÕÀѡͱ½ÝÍÐÁÉнѡÍÉ¥ÁÐ($%]¡¥±%ÍÉÉä ÀÌØí½½É¤($$%5½ÕÍ
±¥¬ ÅÕ½Ðí1ÐÅÕ½Ðì°ÀÌØí½½ÉlÁt°ÀÌØí½½ÉlÅt°Ä°À¤ì)ÕÍб¥­i¹ÍÕÍÑ($$$ÀÌØí½½ÉôA¥á±MÉ  ÀÌØí½½ÉlÁt´ÄÀ°ÀÌØí½½ÉlÅt´ÄÀ°ÀÌØí½½ÉlÁt¬ÄÀ°ÀÌØí½½ÉlÅt¬ÄÀ°ÀÌØíÍÉ¡½±½È¤($$$ì$½¸ÌäíÐÅÕ¥ÑÕ¹ÉÍѹݡÐÑ¡½ÙÝ¡¥±±½½À¥Ì½¥¹°¥Ì¥Ð¹ÍÍÉäüIµ½Ù¥¹¥ÐÝ¥±°Í¥¹¥¥¹Ñ±äÍÁÕÀÑ¡ÍÉ¥ÁÐ($$$ì%е½ÙÌÑ¡ÍÉ ÉÄÀÁ¥á±ÌѼѡ±Ð°¹ÄÀÁ¥á±Ì½Ý¸ Ñ¥µ¥Ð¥¹ÌÑ¡½±½Èü($%]¹(%]¹)¹Õ¹()Õ¹}á¥Ð ¤(á¥Ð)¹Õ¹
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...