problem with my script

08/03/2013 18:22 deathletum#1
alright i scripted this thing and im having problems with it.
the first script runes fine and Loops infinitely like i want it to. so basicly i built my next script around the same code and this one just keeps clicking the same spot over and over and never moves the mouse.

i would like to get the problem fixed and cant seem to figure out whats wrong with it. So looking for any help i can get. would also be cool if i could merge both the codes into one. but they are for 2 different characters.
its keeping track of a health bar and then when it gets below it heals.

Code:
#RequireAdmin
WinActivate("Ashen Empires")
WinWaitActive("Ashen Empires")

While 1
   $aPixel = PixelSearch(394, 29, 423, 45, 0xC60000)
   If IsArray($aPixel) = False Then
	  WinActivate("Ashen Empires")
	  WinWaitActive("Ashen Empires")
	  MouseMove(418,290)
	  MouseClick("left")
   EndIf
	  sleep(10)
WEnd



and this is code 2 that fucks up:

Code:
#RequireAdmin
WinActivate("Ashen Empires")
WinWaitActive("Ashen Empires")

While 1
   $aPixel = PixelSearch(555, 808, 573, 817, 0xEF4A4A)
   If IsArray($aPixel) = False Then
	  Local $coords = PixelSearch(773, 421, 870, 528, 0x391010, 75)
	  MouseMove($coords[0], $coords[1])
	  MouseClick("left")
   EndIf
	  Sleep(10)
WEnd
08/03/2013 18:38 KDeluxe#2
Code:
$szWindowName = "Ashen Empires"

While Sleep(10)
    If WinExists($szWindowName) Then
        If Not WinActive($szWindowName) Then 
            WinActivate($szWindowName)
            ContinueLoop
        EndIf
        
        $aPixel = PixelSearch(394, 29, 423, 45, 0xC60000) ; I think you should use PixelGetColor()
        If IsArray($aPixel) Then MouseClick("left", 418, 290)
        
        $aPixel = PixelSearch(555, 808, 573, 817, 0xEF4A4A)
        If IsArray($aPixel) Then
            $aCoords = PixelSearch(773, 421, 870, 528, 0x391010, 75)
            If IsArray($aCoords) Then MouseClick("left", $aCoords[0], $aCoords[1])
        EndIf
    EndIf
WEnd
08/03/2013 18:48 deathletum#3
Quote:
Originally Posted by KDeluxe View Post
Code:
$szWindowName = "Ashen Empires"

While Sleep(10)
    If WinExists($szWindowName) Then
        If Not WinActive($szWindowName) Then 
            WinActivate($szWindowName)
            ContinueLoop
        EndIf
        
        $aPixel = PixelSearch(394, 29, 423, 45, 0xC60000) ; I think you should use PixelGetColor()
        If IsArray($aPixel) Then MouseClick("left", 418, 290)
        
        $aPixel = PixelSearch(555, 808, 573, 817, 0xEF4A4A)
        If IsArray($aPixel) Then
            $aCoords = PixelSearch(773, 421, 870, 528, 0x391010, 75)
            If IsArray($aCoords) Then MouseClick("left", $aCoords[0], $aCoords[1])
        EndIf
    EndIf
WEnd

this is some interesting code but mouse is still constantly clicking for no reason. ill explain how i programmed it.
this is the game screen:

[Only registered and activated users can see links. Click Here To Register...]

i told it too search a certain area or the red health bar and when the is no more red in that the location i told it the program should execute heal.

not sure if there is a better way of doing it but thats the only way i could find.

at first i was hoping to track numbers but didint find out how.


[Only registered and activated users can see links. Click Here To Register...]
08/03/2013 19:25 KDeluxe#4
You should use PixelGetColor() with the "hWnd" parameter. That allows you to use client specific coordinates.

Code:
$szWindowName = "Ashen Empires"
$dwHealthColor = 0xC60000

While Sleep(10)
    $hWnd = WinGetHandle($szWindowName)
    If Not @error Then
        $nWindowSize = WinGetClientSize($hWnd)
        If $nWindowSize[0] <> 0 And $nWindowSize[1] <> 0 Then ; the size will be 0 if the window is minimized
            $dwColor = PixelGetColor($nWindowSize[0] / 2, 50, $hWnd) ;the health bar is centered in the game
            If $dwColor <> $dwHealthColor Then
                ControlSend($hWnd, "", "", "{F3}") ;use potion
            EndIf
        EndIf
    EndIf
WEnd
08/03/2013 20:01 deathletum#5
that sounds complicated hehe i guess i got some reading to do :)