Jump to content

Would this be Possible in AutoIt?


Recommended Posts

Would it be possible to track the bar below from 100% to 0% or from 0% to 100% and then execute a command upon bar = 0% or 100%?

If so how would i go about it?

Posted Image

Is the progress bar in some application that you didn't create?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Actually nvm, i'm going to try another method. It seems the Script cant pick up this bar's color value when im in game-windowed mode, its pulling the co-ords from the desktop rather than the gaming client even though the gaming client is active when its running. I know quite a few people here arent willing to help make game bots which is why im trying my best to do it myself so no one else can use the script. Problem is i dont have the time to play the game as much as id like to so i'm trying to make a bot so i can get into the higher levels and participate in the Guilds vs Guilds area of the game, without a bot to help me level i doubt i'd get to the levels required for this part of game. I barely have time to sleep let alone play MMO's but i love playing them for PVP value.

Still if anyone is willing to help pm me, if not i understand, i'll just soldier on till i get a working bot script.

Edited by Ginseng
Link to comment
Share on other sites

OK so it's a game, chances are you can't read any data from the progress control but you can check the co-ordinates of the progress bar to see what colour they are using PixelGetColor()

I don't know what values you are interested in but you could check 10 positions along the progress bar to know you have 10,20,30,40,50,60,70,80,90,100% or more even. Maybe find out what 10% range you are in then do some smaller pixelGetColour() operations to work out a more accurate measure. Maybe there is a better way this is just an idea.

Edit: Just re-read your post and you say you cant read the colour value while the game is running but maybe you can use the GDIPlus screen capture to grab the image and then interogate that capture

Edited by ChrisL
Link to comment
Share on other sites

OK so it's a game, chances are you can't read any data from the progress control but you can check the co-ordinates of the progress bar to see what colour they are using PixelGetColor()

I don't know what values you are interested in but you could check 10 positions along the progress bar to know you have 10,20,30,40,50,60,70,80,90,100% or more even. Maybe find out what 10% range you are in then do some smaller pixelGetColour() operations to work out a more accurate measure. Maybe there is a better way this is just an idea.

Edit: Just re-read your post and you say you cant read the colour value while the game is running but maybe you can use the GDIPlus screen capture to grab the image and then interogate that capture

Its not that it cant read it, its just when i use the AutoIt Window Info tool its giving me the co-ords of the 1% - 0% of the HP Bar but when i check the color its different.

I suppose i'll try the GDIPlus screen capture and try that, yet another thing to learn :D

Thanks for the advice.

Link to comment
Share on other sites

Funnily enough I was messing around with this code earlier most of it is from Randall. It only works on a BMP but if you were to screen capture the progress bar and save it as a BMP then you could load the values in to an array to find out what your progress bar was doing

$szPicFile = "bar1su7.bmp";-----> PUT THE NAME AND LOCATION OF THE BITMAP HERE

#include <GDIPlus.au3>
#include <array.au3>
 
$dll = _GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ($szPicFile)
$imgwidth = _GDIPlus_ImageGetWidth ($hImage)
$imgheight = _GDIPlus_ImageGetHeight ($hImage)
_GDIPlus_ShutDown ()


$Step = 1; this is the accuracy of the BMP read 1 reads every pixel 5 reads every 5th pixel
$nofpixels = ($imgwidth) * ($imgheight)
;--------------


;-initialise Array
Global $imgarray[$imgheight/$step][$imgwidth/$step]

;-open image
;Const $GWL_HINSTANCE = -6
;Const $IMAGE_BITMAP = 0
;Const $LR_LOADFROMFILE = 0x0010

Dim $hInst, $hBmp, $hMemDC, $hwnd

Opt("WinWaitDelay",1)
AutoItWinSetTitle("qqqqqq")
$hwnd = WinGetHandle("qqqqqq")

$hInst = DllCall("user32.dll","int","GetWindowLong","hWnd",$hwnd, "int",$GWL_HINSTANCE)
$hInst = $hInst[0]

$hBmp = DllCall("user32.dll","hwnd","LoadImage","hwnd",$hInst,"str",$szPicFile,"int",$IMAGE_BITMAP, _
        "int",0,"int",0,"int",$LR_LOADFROMFILE)
$hBmp = $hBmp[0]

$hMemDC = DllCall("gdi32.dll", "int", "CreateCompatibleDC", "int", 0)
$hMemDC = $hMemDC[0]

DllCall("gdi32.dll", "hwnd", "SelectObject", "int", $hMemDC, "hwnd", $hBmp)
;-------------------------------------

$setStr= ""

;-get pixels and populate array
ProgressOn("Progress Meter", "Copying Pixels into array"); start progress bar

For  $x = 0 To Round($imgheight) -1 Step $Step

    For  $y = 0 To Round($imgwidth)-1 Step $Step

       ;get pixel colour
        $ret = DLLCall("gdi32.dll","int","GetPixel","int",$hMemDC,"int",$y,"int",$x);x and y of pixel
        $ret = Hex( $ret[0], 6)
        $ret =  StringRight($ret,2) & StringMid($ret,3,2) & StringLeft($ret,2)
        
       ;stick it in the array
        $imgarray[$x/$step][$y/$step] = $ret

        $str = Round((($y+1)+($x*$imgwidth))/1000) & " of " & Round($nofpixels/1000) & " thousands"
        If $Str <> $SetStr then 
            $SetStr = $Str
            ProgressSet(   ((($y+1)+($x*$imgwidth))/$nofpixels) * 100,$SetStr)
        EndIf
        
    Next
Next


ProgressSet(100 , "Done")
ProgressOff()

_ArrayDisplay($imgarray)

;-close image
DllCall("gdi32.dll", "int", "DeleteDC", "hwnd", $hMemDC)
DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hBmp)

Edit: cleaned it up a bit

bar1su7.bmp

Edited by ChrisL
Link to comment
Share on other sites

It's the RGB colour values of each pixel so you could pick the middle row which is the middle of the progressbar, the other thing is this was converted from your PNG to a BMP which maybe giving false readings, you really need to do it with a straight capture

Link to comment
Share on other sites

Crossing Fingers at the moment i just tried something, i played the game in full screen mode, took a screenshot of the game with monster bar at full and then another with monster bar empty and then tried the script below and it seems to be working.

The script attacks when i apply the screenshot of full hp as my desktop. When i change screenshots and use the one with the empty HP Bar the script cycles through. So its obviously picking up the color change in full screen mode, i'm going to try again now in windowed mode as my coding is different now to when i previously tried lets hope.

Global $Paused
HotKeySet("{PGUP}", "_Terminate")
HotKeySet("{PAUSE}", "TogglePause")
ToolTip('Script - is Running', 0, 0)

Sleep(1000)
While 1
    ToolTip('Script - is Targetting Monster', 0, 0)
    Sleep(300)
    Send("{TAB}")
    Sleep(300)
    ToolTip('Script - is Attacking Monster', 0, 0)
    Send("3")
    Sleep(300)
    Do
        PixelGetColor(542, 25)
    Until PixelGetColor(542, 25) = 0x293029
    ToolTip('Script - is Picking Up Loot', 0, 0)
    Sleep(200)
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
    Send("{SPACE}")
WEnd

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc  ;==>TogglePause

Func _Terminate()
    Exit
EndFunc  ;==>_Terminate
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...