Amh.p Posted November 17, 2006 Share Posted November 17, 2006 Hi here i am agen I have a question how can i create a working function the error message tolt me "not explained variable" contains this code So i search for it and i see it need a function I am a bit confused can enyone explain the func - endfunc code to me ? I have alredy look into the examples but it diddent really help $Color = "0xD60010";The Hexadecimal Value Of The Color To Seach For. While 1; Initiate A never ending loop Sleep(1000) $Pos = PixelSearch(0+50, 0+50, 588, 384, $Color, 10, 3);Calls PixelSearch Function If IsArray($Pos) Then;Validates whether or not the search Turned Up a result If $y = $Pos[0] =>314 then * 2 EndIf If $y = $Pos[0] <=314 Then / 2 EndIf If $x = $Pos[1] =>314 Then * 2 EndIf If $x = $Pos[1] <=314 Then / 2 EndIf MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks EndIf WEnd If $y = $Pos[0] =>314 then * 2 EndIf If $y = $Pos[0] <=314 Then / 2 EndIf If $x = $Pos[1] =>314 Then * 2 EndIf If $x = $Pos[1] <=314 Then / 2 EndIf MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks EndIf This piece of code must be in a Function i belive I hope enyone have eny sugestions for me or can explain me the func code it be cool Link to comment Share on other sites More sharing options...
GaryFrost Posted November 17, 2006 Share Posted November 17, 2006 (edited) Being you have them on 1 line if then statements you don't need the endif i.e. Change: If $y = $Pos[0] =>314 then * 2 EndIf If $y = $Pos[0] <=314 Then / 2 EndIf If $x = $Pos[1] =>314 Then * 2 EndIf If $x = $Pos[1] <=314 Then / 2 EndIf oÝ÷ Ù:ºÚ"µÍY ÌÍÞHH ÌÍÔÜÖÌHIÝÌÌM[ Y ÌÍÞHH ÌÍÔÜÖÌH ÏLÌM[ÈY ÌÍÞH ÌÍÔÜÖÌWHIÝÌÌM[ Y ÌÍÞH ÌÍÔÜÖÌWH ÏLÌM[ÈoÝ÷ Ø̪¹ë-â³ZµªÞ¶¬z'쵫^éí²êi¢Ç¡Úì¢z-)àjÇÚ«q©ízY@ëa{+.¦,zÚ,zÝ7ë&§wMúÅú+{¦¦WºÚ"µÍY ÌÍÞHH ÌÍÔÜÖÌHIÝÌÌM[ ÌÍÞH HY ÌÍÞHH ÌÍÔÜÖÌH ÏLÌM[ ÌÍÞHÏHY ÌÍÞH ÌÍÔÜÖÌWHIÝÌÌM[ ÌÍÞ HY ÌÍÞH ÌÍÔÜÖÌWH ÏLÌM[ ÌÍÞÏH Edited November 17, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Amh.p Posted November 18, 2006 Author Share Posted November 18, 2006 This is what i made of itand yes your right you made me think ! thanks But i stil have a problem it gives still a error If $Pos[0] =>314 then $y = $pos[0]*2If ÊRRORError: in expression. (line 7)but it wants to work but bevore it works it gives the error message$Color = "0xD60010";The Hexadecimal Value Of The Color To Seach For. While 1; Initiate A never ending loop Sleep(1000) $Pos = PixelSearch(0+50, 0+50, 588, 384, $Color, 10, 3);Calls PixelSearch Function If IsArray($Pos) Then;Validates whether or not the search Turned Up a result If $Pos[0] =>314 then $y = $Pos[0] * 2 If $Pos[0] <=314 Then $y = $Pos[0] / 2 If $Pos[1] =>314 Then $x = $Pos[1] * 2 If $Pos[1] <=314 Then $x = $Pos[1] / 2 MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks EndIf WEndOhh and i try to make it reed a coordinat and * 2 or / 2 depents on if its higher then 314 or lowerOhh and thanks for the help it made me really think I hope we have a solution for this problem also Link to comment Share on other sites More sharing options...
Amh.p Posted November 18, 2006 Author Share Posted November 18, 2006 This is beter i think but stil the same Error $Color = "0xD60010";The Hexadecimal Value Of The Color To Seach For. While 1; Initiate A never ending loop Sleep(1000) $Pos = PixelSearch(0+50, 0+50, 588, 384, $Color, 10, 3);Calls PixelSearch Function If IsArray($Pos) Then;Validates whether or not the search Turned Up a result If $Pos[0] > 315 then $Pos[0] * 2 = $y If $Pos[0] < 314 Then $Pos[0] / 2 = $y If $Pos[1] > 315 Then $Pos[1] * 2 = $x If $Pos[1] < 314 Then $Pos[1] / 2 = $x MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks MouseClick("right", $y, $x, 1, 0); Moves the Mouse To the Coordinates Of the Pixel and Left Clicks EndIf WEnd Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2006 Share Posted November 18, 2006 You need to learn how to use assignments If $Pos[0] > 315 then $y = $Pos[0] * 2 If $Pos[0] < 314 Then $y = $Pos[0] / 2 If $Pos[1] > 315 Then $x = $Pos[1] * 2 If $Pos[1] < 314 Then $x = $Pos[1] / 2 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Amh.p Posted November 18, 2006 Author Share Posted November 18, 2006 Yes i need to learn alot but i want to learn so dhat wil come alright I have tried the code's but wen i put it as the first time it says Error: variable used without declared but if i turn them arount it gives a other error hmm I'll ceep trying but if you find the key let me know please! Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2006 Share Posted November 18, 2006 Yes i need to learn alot but i want to learn so dhat wil come alright I have tried the code's but wen i put it as the first time it saysError: variable used without declared but if i turn them arount it gives a other errorhmm I'll ceep trying but if you find the key let me know please!above the while loop declare the variables $y and $x SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
tresa Posted November 18, 2006 Share Posted November 18, 2006 This is what i made of it and yes your right you made me think ! thanks But i stil have a problem it gives still a error If $Pos[0] =>314 then $y = $pos[0]*2 If ÊRROR Error: in expression. (line 7) but it wants to work but bevore it works it gives the error message ..... Ohh and i try to make it reed a coordinat and * 2 or / 2 depents on if its higher then 314 or lower Ohh and thanks for the help it made me really think I hope we have a solution for this problem also change the line If $Pos[0] =>314 then $y = $pos[0]*2 to If $Pos[0] >=314 then $y = $pos[0]*2 Also do it in the line: If $Pos[0] =>314 then $x = $pos[0]*2 BTW your test includes 314 twice : What do you want if the value equals 314 exactly *2 or /2 or nothing? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 18, 2006 Moderators Share Posted November 18, 2006 change the line If $Pos[0] =>314 then $y = $pos[0]*2 to If $Pos[0] >=314 then $y = $pos[0]*2 Also do it in the line: If $Pos[0] =>314 then $x = $pos[0]*2 BTW your test includes 314 twice : What do you want if the value equals 314 exactly *2 or /2 or nothing?It might be used twice... however... they are 2 totally different scenerious... one is for the array element [0] and the other is for the array element [1] Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2006 Share Posted November 18, 2006 I believe I already answered the how(s) to fix it. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Amh.p Posted November 18, 2006 Author Share Posted November 18, 2006 Yes I got it working Thanks !! alot you all are really a great help 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