Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 10:13

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



problem with my script

Discussion on problem with my script within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2008
Posts: 19
Received Thanks: 1
problem with my script

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 ***** 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
deathletum is offline  
Old 08/03/2013, 18:38   #2
 
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
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
KDeluxe is offline  
Thanks
1 User
Old 08/03/2013, 18:48   #3
 
elite*gold: 0
Join Date: Jan 2008
Posts: 19
Received Thanks: 1
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:



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.


deathletum is offline  
Old 08/03/2013, 19:25   #4
 
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
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
KDeluxe is offline  
Old 08/03/2013, 20:01   #5
 
elite*gold: 0
Join Date: Jan 2008
Posts: 19
Received Thanks: 1
that sounds complicated hehe i guess i got some reading to do
deathletum is offline  
Reply


Similar Threads Similar Threads
HP Script Problem
09/24/2011 - Metin2 Private Server - 2 Replies
Also hab nochn älteres Hp Script.. Und wollte mal fragen, was ich umstellen muss, damit das Kästchen nicht leer bleibt? http://h3.abload.de/img/catsueke.jpg Darunter ist dann noch ein 2. Wo was drin steht, wenn ich aber z.b das 1 Oben löschen will, lässt es sich nicht wirklich löschen, weil die Ränder immer da bleiben ect, oder der Platz bleibt frei blabla.. Was genau muss ich in der Index ändern das da ein Bild drin ist oder sonst was?
bot script problem - need help
07/31/2011 - SRO Private Server - 2 Replies
hello, at first sry for my english^^ my problem: i want to bot in asia minor. so i start bot in hotan. the bot walk the way perfect in hotan and teleport to sama. now he went out of the door and... stay at a random point on the road. i add a new scrit - same. stay at random place. whats the problem?! i walk point after point at the first script and a allways walking (no staying char) in the 2nd... pls help me
HP Script Problem help pls
04/22/2011 - Metin2 - 1 Replies
<?php $dbhost = "root"; $dbuser = "localhost"; $dbpass = "123456"; $mysql_db = "GreenHorneTz²"; ?> ich weis nciht ob das richtig ist aber hp geht nicht da steht >> Warning: mysql_connect() : php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt. in D:\xampp\htdocs\index.php on line 15
Problem VB 10 Patcher Script Problem
09/20/2010 - .NET Languages - 8 Replies
Hayho liebe Com. ich habe mal wieder einen ganz netten Patcher gescriptet, für einen metin2 P Server, da es nicht mein erster is, hab ich echt kp was da vorliegt, Hier der Script an sich: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEv entArgs) Handles...
[HOW-TO]Hp-Script+Admin-script (weekly-updatet) problem!
06/21/2010 - Metin2 Private Server - 11 Replies
hallo leute ich hab ein problem und zwar bei dem hp script von masterboss kommt der fehler : http://img541.imageshack.us/img541/8140/24955249. png und wenn ich dann die datei öffne und in die zeile gehe kommt: while($row = mysql_fetch_array($ergebnis)) kann mir jmd helfen?



All times are GMT +1. The time now is 10:13.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.