Sign in to follow this  
Followers 0
Amh.p

Creating a Func

11 posts in this topic

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 ;)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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.

 

Share this post


Link to post
Share on other sites

This is what i made of it

and yes your right you made me think !

thanks ;)

But i stil have a problem :evil: 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

$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
WEnd

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 :lmao: it made me really think

I hope we have a solution for this problem also :mad:

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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!

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.

 

Share this post


Link to post
Share on other sites

This is what i made of it

and yes your right you made me think !

thanks ;)

But i stil have a problem :evil: 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 :lmao: it made me really think

I hope we have a solution for this problem also :mad:

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?

Share this post


Link to post
Share on other sites

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]

[center]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.[/center]

Share this post


Link to post
Share on other sites

Yes I got it working Thanks !! alot ;)

you all are really a great help :lmao:

Share this post


Link to post
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
Sign in to follow this  
Followers 0