IF Colordetection

01/30/2010 15:10 Alucard#1
I have the coordinates of an specific Pixel and the color of it.

Now i need help on how to work with it!

I want to make a script, that presses a key, looks if the color in that pixel is corect and if the color is corect it presses another key. if the color is wrong it presses the first key again.

and then i need a detection, that waits until the color of that specific pixel is changed and then it should start another script, where it presses another key and waits some time and then starts in the beginning with the first key again.

can somebody write me code that does something like that?
01/30/2010 16:03 AutoItDude#2
Code:
Global $KEY[2]=["A","B"]
Global $COLOR=0
Global $X=0,$Y=0

While 1
     LearnBasics()
WEnd

Func LearnBasics()
  Send($KEY[0])
  If PixelGetColor($X,$Y)=$COLOR Then
    Send($KEY[1])
    Return 1
  Else
    Return 0
  Endif
EndFunc
this should do the trick. learn basics.
01/30/2010 16:05 .nAno#3
sth. like this? :P
PHP Code:
Do
Send "{key}" ) ;ControlSend might be more comfortable

If PixelGetColor (*parameters*) = *your_PixelThen
Send 
"{anotherKey}" )
Else
Send "{key}" )
EndIf

Until PixelGetColor (*parameters*) = *your_2ndPixel*
Run (*parameters*) ;ShellExecute probably works better ;) 
edit: sry, he was faster^^
01/30/2010 16:18 Alucard#4
wow nice thanks, now i can continue messing up my scripts :D
01/31/2010 17:56 ax5#5
Hehehe good luck :)
02/01/2010 11:43 Alucard#6
Quote:
#include <GUIConstantsEx.au3>
GUICreate("AutoIT", 335, 100)
GUISetState(@SW_SHOW)

If WinExists("ZENSIERT") Then
WinActivate("ZENSIERT")
WinWaitActive("ZENSIERT")
EndIf

While 1
fight()
WEnd


Func fight()
If PixelGetColor (560, 70) = 0xFFFFFF Then
Send("1")
Else
While Send("3")
Sleep (500)
Send("2")
Sleep (1500)
WEnd
EndIf
EndFunc
Thats my Code till now, only Problem with it, it is spamming the Keys. That is a Problem, becaus "2" is to sit down and recover and if u press it again he will stand up and stop recovering. I need the "2" only pressed once after the Pixelcolor doesn`t match.

Any suggestions for a command to insert?



das ist mein script bis jetzt. es funktioniert noch nicht wirklich gut.

"1" ist zum Angreifen
"2" ist zum Hinsetzen
"3" ist zum Loot aufsammeln

das einzige Problem am jetzigen Script ist, dass er die Tasten spammt. Was bei "1" und "3" nicht wirklich das Problem ist, dort schadet es nicht, wenn der Befehl mehrfach gesendet wird, allerdings bei "2" wird es zum Problem, da er automatisch wieder aufsteht, wenn die Taste erneut gedrückt wird.

Hat jemand eine Ahnung, welchen Befehl ich einfügen muss, damit die 2 nur einmal gesendet wird?
02/01/2010 15:59 .nAno#7
was isn daran so schwer? o0

warum guckste dir nicht einfach mal die Else Anweisung in meinem Beispiel an? :P
02/01/2010 17:34 Alucard#8
Quote:
Originally Posted by .nAno View Post
was isn daran so schwer? o0

warum guckste dir nicht einfach mal die Else Anweisung in meinem Beispiel an? :P
ich verstehe nicht wozu das "Run (*parameters*) da ist?!?
02/01/2010 17:52 Alucard#9
Code:
Func fight()     
	If PixelGetColor (560, 70) = 0xFFFFFF Then             
		Send("1")             
	Else
		While 	
			$zahl = 0
			Do
			$zahl = $zahl + 1
				Send("3")
				Sleep (1000)
				Send("2")
				Sleep (2000)
			Until $zahl = 1
		WEnd
	EndIf 
EndFunc
Kriege

"Line 79 ....

Error: Error in expression."


was ist falsch?
02/01/2010 18:29 Xereon#10
"Error in expression" ist schon etwas seltsam, da du überhaupt keine hast -.-

Code:
While ;<- Hier fehlt eine Condition
02/01/2010 19:38 Alucard#11
ja gut, aber mit der variablen so funktioniert das auch nicht, kann irgendjemand den code berichtigen, so dass es funktioniert?
02/01/2010 19:44 AutoItDude#12
Quote:
Originally Posted by Alucard View Post
Thats my Code till now, only Problem with it, it is spamming the Keys. That is a Problem, becaus "2" is to sit down and recover and if u press it again he will stand up and stop recovering. I need the "2" only pressed once after the Pixelcolor doesn`t match.

Any suggestions for a command to insert?



das ist mein script bis jetzt. es funktioniert noch nicht wirklich gut.

"1" ist zum Angreifen
"2" ist zum Hinsetzen
"3" ist zum Loot aufsammeln

das einzige Problem am jetzigen Script ist, dass er die Tasten spammt. Was bei "1" und "3" nicht wirklich das Problem ist, dort schadet es nicht, wenn der Befehl mehrfach gesendet wird, allerdings bei "2" wird es zum Problem, da er automatisch wieder aufsteht, wenn die Taste erneut gedrückt wird.

Hat jemand eine Ahnung, welchen Befehl ich einfügen muss, damit die 2 nur einmal gesendet wird?
use memory functions, instead of pixel checking/searching to determine if you standing up or sitting. search for the bit value (0/1) in memory, get address, use it.
02/01/2010 20:01 Alucard#13
Quote:
Originally Posted by AutoItDude View Post
use memory functions, instead of pixel checking/searching to determine if you standing up or sitting. search for the bit value (0/1) in memory, get address, use it.
when i get u the adress, can u write me the code i need? i am new to autoit as u can see :)

4bit

061C3188

0 is standing
1 is sitting
02/01/2010 20:09 Xereon#14
Quote:
Originally Posted by Alucard View Post
ja gut, aber mit der variablen so funktioniert das auch nicht, kann irgendjemand den code berichtigen, so dass es funktioniert?
Wie wäre es mit literalen Konstanten wie zB 1,4,8,4,true usw?
02/01/2010 20:17 Alucard#15
Quote:
Originally Posted by Xereon View Post
Wie wäre es mit literalen Konstanten wie zB 1,4,8,4,true usw?
ich versteh nur bahnhof O_o