scripting - Autohotkey How can I do multiple imageSearches using a function parameter -


i trying use imagesearch buy items item shop in game. there 8 slots therefore need loop 8 times. there 4-5 different items need buy if appear.

this function use buying:

marketfunc(item) {     loop, 8     {         imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, item         if !errorlevel         {             outy = %outputvary%             outy += 119             mousemove, %outputvarx%, %outy%             sleep, 250             click             sleep, 750             mouseclick, left,  797,  456             sleep, 750             mouseclick, left,  687,  473             sleep, 100         }         sleep, 250     } } 

i've been calling function this:

marketfunc(chip.png) sleep, 500 marketfunc(ticket.png) sleep, 500 marketfunc(scroll.png) sleep, 500 marketfunc(masterscroll.png) sleep, 500 marketfunc(otheritemhere.png) 

i know can without function this:

loop, 8 {     imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, ticket.png     if !errorlevel     {         outy = %outputvary%         outy += 119         mousemove, %outputvarx%, %outy%         sleep, 250         click         sleep, 750         mouseclick, left,  797,  456         sleep, 750         mouseclick, left,  687,  473         sleep, 100      }     sleep, 250      imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, chip.png     if !errorlevel     {         outy = %outputvary%         outy += 119         mousemove, %outputvarx%, %outy%         sleep, 250         click         sleep, 750         mouseclick, left,  797,  456         sleep, 750         mouseclick, left,  687,  473         sleep, 100      }     sleep, 250      imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, scroll.png     if !errorlevel     {         outy = %outputvary%         outy += 119         mousemove, %outputvarx%, %outy%         sleep, 250         click         sleep, 750         mouseclick, left,  797,  456         sleep, 750         mouseclick, left,  687,  473         sleep, 100      }     sleep, 250      imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, masterscroll.png     if !errorlevel     {         outy = %outputvary%         outy += 119         mousemove, %outputvarx%, %outy%         sleep, 250         click         sleep, 750         mouseclick, left,  797,  456         sleep, 750         mouseclick, left,  687,  473         sleep, 100      }     sleep, 250      imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, otheritemhere.png     if !errorlevel     {         outy = %outputvary%         outy += 119         mousemove, %outputvarx%, %outy%         sleep, 250         click         sleep, 750         mouseclick, left,  797,  456         sleep, 750         mouseclick, left,  687,  473         sleep, 100      }     sleep, 250 } 

but don't looks of it, , feels hard code-y.

any appriciated.

nevermind got work.

    marketfunc("chip.png")     marketfunc("ticket.png")     marketfunc("basicscroll.png")     marketfunc("heroicscroll.png")   marketfunc(item) {     loop, 8     {         imagesearch, outputvarx, outputvary, 0, 0, %a_screenwidth%, %a_screenheight%, %item%         if !errorlevel         {             outy = %outputvary%             outy += 119             mousemove, %outputvarx%, %outy%             sleep, 250 ;           click             sleep, 750 ;           mouseclick, left,  797,  456             sleep, 750 ;           mouseclick, left,  687,  473             sleep, 100          }         sleep, 250      } } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -