Jump to content

Multi PixelSearch loop?


Glyph
 Share

Recommended Posts

$8=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '8', 'Value not found' ))
$9=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '9', 'Value not found' ))
$10=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '10', 'Value not found' ))
$11=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '11', 'Value not found' ))
$12=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '12', 'Value not found' ))
$13=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '13', 'Value not found' ))
$14=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '14', 'Value not found' ))
$15=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '15', 'Value not found' ))
$game=(IniRead( @ScriptDir & '\Settings.ini', 'Game', '16', 'Value not found!!' ))
$a=@DesktopHeight /2
$b=@DesktopWidth /2
HotKeySet ( "^+e" , "Quit" );Control+shift+e = QuitQ
AutoItSetOption ( "PixelCoordMode",0 );search area of active wiundow

Func Quit()
exit
endfunc


while1
case $coord = PixelSearch($a +20, $b +20, $a -20, $b -20, $8, 10)
If Not @error Then
    MouseClick($coord[0], $coord[1])
EndIf
wend

while1
$coord = PixelSearch($a +20, $b +20, $a -20, $b -20, $9, 10)
If Not @error Then
    MouseClick($coord[0], $coord[1])
EndIf
wend

How would i go about doing soemthing like this?

tolle indicium

Link to comment
Share on other sites

Put them both in the same loop?

While 1
    $coord = PixelSearch($a +20, $b +20, $a -20, $b -20, $8, 10)
    If Not @error Then
        MouseClick($coord[0], $coord[1])
    EndIf
    $coord2 = PixelSearch($a +20, $b +20, $a -20, $b -20, $9, 10)
    If Not @error Then
        MouseClick($coord2[0], $coord2[1])
    EndIf
WEndoÝ÷ Ù.§Zªê-   «ªê-{az·­«H­é¨½çN¯*.r¥te»azf®¶­sdgVæ24öæR µVÅ6V&6¤VæDgVæ0 ¤gVæ25Gvò µVÅ6V&6 ¤VæDgVæ0 ¤gVæ2FÆ$æFÆW" 4öæR 5Gvò¤VæDgVæ0 ¤FÆ$Væ&ÆRgV÷C´FÆ$æFÆW"gV÷C²

Edit: Typo.

Edited by mikehunt114
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

Lets say i did the adlib and i needed/wanted a "AutoItSetOption ( "PixelCoordMode",0 )"

should i add that to every finction or just add it to the top of the script?

In almost all cases you should just set the options at the beginning of your script.

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

You should only need to set it at the top of the script if you don't plan on changing the mode somewhere else in the script.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

CODE
$8=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '8', 'Value not found' ))
$9=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '9', 'Value not found' ))
$10=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '10', 'Value not found' ))
$11=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '11', 'Value not found' ))
$12=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '12', 'Value not found' ))
$13=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '13', 'Value not found' ))
$14=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '14', 'Value not found' ))
$15=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '15', 'Value not found' ))
$game=(IniRead( @ScriptDir & '\Settings.ini', 'Game', '16', 'Value not found!!' ))
$a=@DesktopHeight /2
$b=@DesktopWidth /2
HotKeySet ( "^+e" , "Quit" );Control+shift+e = QuitQ
AutoItSetOption ( "PixelCoordMode",0 );search area of active wiundow

Func Quit()
exit
endfunc

Func AdlibHandler()
    Char1()
    Char2()
    Char3()
    Char4()
    Char5()
    Char6()
    Char7()
    Char8()
    
AdlibEnable("AdlibHandler")
Func Char1()
PixelSearch($a +20, $b +20, $a -20, $b -20, $8, 10)
If Not @error Then
    MouseClick($a, $B)
EndFunc

Func Char2()
PixelSearch($a +20, $b +20, $a -20, $b -20, $9, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc

Func Char3()
PixelSearch($a +20, $b +20, $a -20, $b -20, $10, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc

Func Char4()
PixelSearch($a +20, $b +20, $a -20, $b -20, $11, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc

Func Char5()
PixelSearch($a +20, $b +20, $a -20, $b -20, $12, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc

Func Char6()
PixelSearch($a +20, $b +20, $a -20, $b -20, $13, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc

Func Char7()
PixelSearch($a +20, $b +20, $a -20, $b -20, $14, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc

Func Char8()
PixelSearch($a +20, $b +20, $a -20, $b -20, $15, 10)
If Not @error Then
MouseClick($a, $B)
EndFunc
AdlibDisable("AdlibHandler")

Im getting an error..., any idea as to why?

" C:\Documents and Settings\Login\Desktop\test\test.au3 (30) : ==> "Func" statement has no matching "EndFunc".:

Func Char1()

Edited by backstabbed

tolle indicium

Link to comment
Share on other sites

Im getting an error..., any idea as to why?

" C:\Documents and Settings\Login\Desktop\test\test.au3 (30) : ==> "Func" statement has no matching "EndFunc".:

Func Char1()

You didn't EndFunc your AdlibHandler().

Edit: Btw, your script probably won't do what is intended the way it is written right now. You have it AdlibEnabling and then immediately after you are AdlibDisabling it.

Edited by mikehunt114
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

CODE
$8=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '8', 'Value not found' ))
$9=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '9', 'Value not found' ))
$10=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '10', 'Value not found' ))
$11=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '11', 'Value not found' ))
$12=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '12', 'Value not found' ))
$13=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '13', 'Value not found' ))
$14=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '14', 'Value not found' ))
$15=(IniRead( @ScriptDir & '\Settings.ini', 'HexCode', '15', 'Value not found' ))
$game=(IniRead( @ScriptDir & '\Settings.ini', 'Game', '16', 'Value not found!!' ))
$a=@DesktopHeight /2
$b=@DesktopWidth /2
HotKeySet ( "^+e" , "Quit" );Control+shift+e = QuitQ
AutoItSetOption ( "PixelCoordMode",0 );search area of active wiundow

Func Quit()
exit
endfunc

Func AdlibHandler()
    Char1()
    Char2()
    Char3()
    Char4()
    Char5()
    Char6()
    Char7()
    Char8()
EndFunc
AdlibEnable("AdlibHandler")
Func Char1()
PixelSearch($a +20, $b +20, $a -20, $b -20, $8, 10)
If Not @error Then
    MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif

EndFunc

Func Char2()
PixelSearch($a +20, $b +20, $a -20, $b -20, $9, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Func Char3()
PixelSearch($a +20, $b +20, $a -20, $b -20, $10, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Func Char4()
PixelSearch($a +20, $b +20, $a -20, $b -20, $11, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Func Char5()
PixelSearch($a +20, $b +20, $a -20, $b -20, $12, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Func Char6()
PixelSearch($a +20, $b +20, $a -20, $b -20, $13, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Func Char7()
PixelSearch($a +20, $b +20, $a -20, $b -20, $14, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Func Char8()
PixelSearch($a +20, $b +20, $a -20, $b -20, $15, 10)
If Not @error Then
MsgBox(0,"hey","I FREKAIN FOUND IT!")
endif
EndFunc

Just runs and exits in like a split second... when there is white all over the screen!,

Also anyway to loop this, so it doesnt exit?

Edited by backstabbed

tolle indicium

Link to comment
Share on other sites

*points to his above post*

I'm psychic.....or psycho, one of the two.

Simply add a neverending loop after your AdlibEnable.

While 1
    sleep(100)
WEnd
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

You need to narrow your problem down then. Ask yourself what part of your script could be malfunctioning, and test it. Some things to think about with PixelSearch are:

Am I searching for the right color?

Am I searching the correct area?

Is PixelSearch returning correctly?

etc etc

My guess is you are not searching the correct area, or your color codes aren't matching. You are aware that you are searching a 40x40 pixel box in the center of your screen?

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

-sigh-, im not trying to get free code here, i beleive it or not.. have been trying to narrow it down... thing is.. im not the best AUtoit Scripter out tehre my knowledge isnt the greatest in this subject.... To me it exits without seeing the color, yes the color codes are fine, area is correct and i am aware it is a 40x40 area.....

tolle indicium

Link to comment
Share on other sites

You need to debug your code. You have to do some more work in order to get help. Try using ConsoleWrite or MsgBox's which compare the color codes read from your INI file, to those that are returned by PixelSearch. That's about all the advice I can give you.

Assuming you addedthe While loop I posted a couple msgs back, your code looks pretty solid. Work through and learn it now, once you understand how everything is working, I'm quite positive it will be very easy for you to pinpoint the error.

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...