Disciples Posted July 28, 2009 Share Posted July 28, 2009 $coord = PixelSearch( 0, 0, 0, 0, 0x6B0967) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick ("left") If @error Then $coord = PixelSearch( 0, 0, 0, 0, 0x663340) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick ("left") If @error Then $coord = PixelSearch( 0, 0, 0, 0, 0xffff93 ) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick ("left") If @error Then $coord = PixelSearch( 0, 0, 0, 0, 0x4C4C00) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick ("left") If @error Then $coord = PixelSearch( 0, 0, 0, 0, 0x9f772B ) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick ("left") $coord = PixelSearch( 0, 0, 0, 0, 0xBfBf99 ) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick ("left") If @error Then Msgbox(0, "Monster Not Found") EndIf First time doing a pixelsearch. It keeps saying "Line 38 EndIf Error: "If" statement has no matching EndIf" That isn't my whole script, but that is the part that is having errors. Everything else in the script is like comments etc. Do you need an EndIf after each one of my If statements? Or am I just doing the whole thing wrong. Thanks Link to comment Share on other sites More sharing options...
Valuater Posted July 28, 2009 Share Posted July 28, 2009 (edited) Actually to answer your question, If can be used many ways #1 If $Value = 10 Then MsgBox() #2 If Value = 10 Then MsgBox() EndIf #3 If $Value = 10 Then MsgBox ElseIf $Value = 5 Then MsgBox() EndIf #3 can have multiple ElseIf tests Another approach... _Search() Func _Search() $Colors = StringSplit("0x6B0967,0x663340,0xffff93,0x4C4C00,0x9f772B,0xBfBf99", ",") For $x = 1 To $Colors[0] $coord = PixelSearch(0, 0, 0, 0, $Colors[$x]) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick("left") Return EndIf Next MsgBox(0, "word", "Monster Not Found", 5) EndFunc ;==>_Search 8) Edited July 28, 2009 by Valuater Link to comment Share on other sites More sharing options...
Disciples Posted July 28, 2009 Author Share Posted July 28, 2009 Another approach... _Search() Func _Search() $Colors = StringSplit("0x6B0967,0x663340,0xffff93,0x4C4C00,0x9f772B,0xBfBf99", ",") For $x = 1 To $Colors[0] $coord = PixelSearch(0, 0, 0, 0, $Colors[$x]) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick("left") Return EndIf Next MsgBox(0, "word", "Monster Not Found", 5) EndFunc ;==>_Search 8) Wow, thanks man! I am still a noob at autoit, so just trying to find some ways on doing it >_< But now it doesn't seem to work with my HotKeySet("{f3}","start") HotKeySet("{f4}","stop") HotKeySet("{f5}","_Exit") Global $ON = False While 1 While $ON = True xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WEnd WEnd Func start() $ON = True EndFunc Func stop() $ON = False EndFunc Func _Exit() $ON = False Exit Endfunc It says line 23 Func_Search() Error: "While" statement has no matchin "Wend" statement. Link to comment Share on other sites More sharing options...
Valuater Posted July 28, 2009 Share Posted July 28, 2009 Maybe... expandcollapse popupHotKeySet("{F3}", "_Start") HotKeySet("{F4}", "_Stop") HotKeySet("{F5}", "_Exit") Global $ON = False While 1 If $ON = True Then _Search() Sleep(50) WEnd Func _Start() $ON = True EndFunc ;==>_Start Func _Stop() $ON = False EndFunc ;==>_Stop Func _Exit() $ON = False Exit EndFunc ;==>_Exit Func _Search() $Colors = StringSplit("0x6B0967,0x663340,0xffff93,0x4C4C00,0x9f772B,0xBfBf99", ",") For $x = 1 To $Colors[0] $coord = PixelSearch(0, 0, 0, 0, $Colors[$x]) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick("left") Return EndIf Next MsgBox(0, "word", "Monster Not Found", 5) EndFunc ;==>_Search 8) Link to comment Share on other sites More sharing options...
Disciples Posted July 28, 2009 Author Share Posted July 28, 2009 Maybe... expandcollapse popupHotKeySet("{F3}", "_Start") HotKeySet("{F4}", "_Stop") HotKeySet("{F5}", "_Exit") Global $ON = False While 1 If $ON = True Then _Search() Sleep(50) WEnd Func _Start() $ON = True EndFunc ;==>_Start Func _Stop() $ON = False EndFunc ;==>_Stop Func _Exit() $ON = False Exit EndFunc ;==>_Exit Func _Search() $Colors = StringSplit("0x6B0967,0x663340,0xffff93,0x4C4C00,0x9f772B,0xBfBf99", ",") For $x = 1 To $Colors[0] $coord = PixelSearch(0, 0, 0, 0, $Colors[$x]) ;searches for monster, if not found keeps searchin If Not @error Then MouseClick("left") Return EndIf Next MsgBox(0, "word", "Monster Not Found", 5) EndFunc ;==>_Search 8) kk that's working. Thanks But now just one more thing. Is the mouseclick thing right? Like if it is found it will mouseclick? Because it seems to be always not found, then I think it mouseclicks after that, but that may just be it starting over. Link to comment Share on other sites More sharing options...
Valuater Posted July 28, 2009 Share Posted July 28, 2009 #1 I would use Option ( mouse soordinates mode ) and ( Color coodinates mode ) to make sure it is using the correct GUI ... See help #2 "Normally, you would want the mouse to click at the location of the color MouseClick( "Left", X Location, Y Location) #3 Think of the PixelSearch as a box. PixelSearch(Left side, Top, Right side, Bottom Look at the demo at the bottom of the help file page 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now