|
You last visited: Today at 00:20
Advertisement
Autoit pixelsearch hp and mp
Discussion on Autoit pixelsearch hp and mp within the AutoIt forum part of the Coders Den category.
12/07/2019, 04:37
|
#1
|
elite*gold: 0
Join Date: Mar 2012
Posts: 87
Received Thanks: 14
|
Autoit pixelsearch hp and mp
Hi all, i am seeking for help with autoit. I want a script that will pixelsearch my character ingame hp and mp then convert to a separate autoit gui progress bar. I been searching autoit forum but cannot find any clue how to do it.
|
|
|
12/07/2019, 18:17
|
#2
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
|
Quote:
Originally Posted by johnmicel
Hi all, i am seeking for help with autoit. I want a script that will pixelsearch my character ingame hp and mp then convert to a separate autoit gui progress bar. I been searching autoit forum but cannot find any clue how to do it.
|
Hi, in fact is really simple to do, u need some math, here is a full example for u to DIY.
Compile this script to use the pixelSearch example below
Game HP bar Example:
(This code is for the example code to work (DON'T READ IT LOOKS BAD), the code used for the search is the one below, but you can use some of it for your separated gui HP/MP bar)
Code:
#include <GDIPlus.au3>
#include <Misc.au3>
$hGui = GUICreate("game",300,300)
GUISetState(@sw_show,$hGui)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics(300,300,$hGraphic)
$hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBrush = _GDIPlus_BrushCreateSolid()
$hPen = _GDIPlus_PenCreate(0xFF000000,2)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(50, 15, 225, 25)
$hpValue = 100
_GDIPlus_StringFormatSetAlign ( $hFormat, 1 )
;_GDIPlus_GraphicsTranslateTransform($hBackbuffer,0,100)
$hpValue = 1232
$mpValue = 2221
$maxHP = 1232
$maxMP = 2221
While Sleep(15)
if GUIGetMsg() == -3 Then
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBackBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_FontDispose($hFont)
_GDIPlus_Shutdown()
Exit 0
EndIf
render()
if(_IsPressed("01")) Then
$hpValue -= 1
EndIf
if(_IsPressed("02")) Then
$mpValue -= 1
EndIf
WEnd
Func render()
_GDIPlus_GraphicsTranslateTransform($hBackbuffer,0,70)
_GDIPlus_GraphicsClear($hBackbuffer,0xFFFFFFFF)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF000000)
_GDIPlus_GraphicsDrawString($hBackBuffer,"HP",15,15,"arial",12)
_GDIPlus_BrushSetSolidColor($hBrush,0xFFFF0000)
_GDIPlus_GraphicsFillRect($hBackBuffer,50,12,225 * ($hpValue/$maxHP),25,$hBrush)
_GDIPlus_GraphicsDrawRect($hBackBuffer,50,12,226,25,$hPen)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF000000)
_GDIPlus_GraphicsDrawStringEx($hBackBuffer,$hpValue, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsTranslateTransform($hBackbuffer,0,50)
_GDIPlus_GraphicsDrawString($hBackBuffer,"MP",15,15,"arial",12)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF0000FF)
_GDIPlus_GraphicsFillRect($hBackBuffer,50,12,225 * ($mpValue/$maxMP),25,$hBrush)
_GDIPlus_GraphicsDrawRect($hBackBuffer,50,12,226,25,$hPen)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF000000)
_GDIPlus_GraphicsDrawStringEx($hBackBuffer,$mpValue, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawString($hBackBuffer,"[LEFT CLICK] Decrease HP",15,80)
_GDIPlus_GraphicsDrawString($hBackBuffer,"[RIGHT CLICK] Decrease MP",15,100)
_GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap,0,0)
_GDIPlus_GraphicsResetTransform($hBackBuffer)
EndFunc
PixelSearch HP tracker example:
Execute the game.exe (compiled script from above), and run this script
Code:
AutoItSetOption("PixelCoordMode",2) ;relative to client window
$hwnd = WinGetHandle("game")
$maxHP = 1232
$xOffset = 50; bar left X value equals to sx
$ex = 275 ;bar end X value, right most x position
$barSize = $ex - $xOffset
$barBackColor = 0xFFFFFF
;currentSize -> size in pixels of current HP bar, is the bar that is decreased every time you loose some hp
;barSize -> size in pixels of the whole HP bar, is equal to currentSize bar when HP is full, constant value
;hpValue -> numeric value of current HP
;maxHP -> numeric value of maxium ammount of HP
;barBackColor -> color of the bar that is behind the HP bar
;FORMULA
;currentSize = barSize * ($hpValue/$maxHP)
;$maxHP * (currentSize/barSize) = $hpValue
$hpValue = "Unknown"
While Sleep(15)
if Not WinExists("game") Then ExitLoop
if Not WinActive($hwnd) Then ContinueLoop
;82 and 105 are y coordinates of search area, use autoitwindow info
$search = PixelSearch($xOffset,82,$ex,105,$barBackColor ,0,1,$hwnd)
If Not @error Then
$currentSize = $search[0]
;because is a pixel search, currentSize is an integer, then HP value may have some error
$hpValue = $maxHP * (($currentSize - $xOffset)/$barSize)
EndIf
ToolTip($hpValue,0,0)
WEnd
Image of code comments to know what all that means
A tip, use autoitwindow info with these options to help you find the correct
search area position
|
|
|
12/08/2019, 22:49
|
#3
|
elite*gold: 0
Join Date: Mar 2012
Posts: 87
Received Thanks: 14
|
Quote:
Originally Posted by elmarcia
Hi, in fact is really simple to do, u need some math, here is a full example for u to DIY.
Compile this script to use the pixelSearch example below
Game HP bar Example:
(This code is for the example code to work (DON'T READ IT LOOKS BAD), the code used for the search is the one below, but you can use some of it for your separated gui HP/MP bar)
Code:
#include <GDIPlus.au3>
#include <Misc.au3>
$hGui = GUICreate("game",300,300)
GUISetState(@sw_show,$hGui)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics(300,300,$hGraphic)
$hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBrush = _GDIPlus_BrushCreateSolid()
$hPen = _GDIPlus_PenCreate(0xFF000000,2)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(50, 15, 225, 25)
$hpValue = 100
_GDIPlus_StringFormatSetAlign ( $hFormat, 1 )
;_GDIPlus_GraphicsTranslateTransform($hBackbuffer,0,100)
$hpValue = 1232
$mpValue = 2221
$maxHP = 1232
$maxMP = 2221
While Sleep(15)
if GUIGetMsg() == -3 Then
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBackBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_FontDispose($hFont)
_GDIPlus_Shutdown()
Exit 0
EndIf
render()
if(_IsPressed("01")) Then
$hpValue -= 1
EndIf
if(_IsPressed("02")) Then
$mpValue -= 1
EndIf
WEnd
Func render()
_GDIPlus_GraphicsTranslateTransform($hBackbuffer,0,70)
_GDIPlus_GraphicsClear($hBackbuffer,0xFFFFFFFF)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF000000)
_GDIPlus_GraphicsDrawString($hBackBuffer,"HP",15,15,"arial",12)
_GDIPlus_BrushSetSolidColor($hBrush,0xFFFF0000)
_GDIPlus_GraphicsFillRect($hBackBuffer,50,12,225 * ($hpValue/$maxHP),25,$hBrush)
_GDIPlus_GraphicsDrawRect($hBackBuffer,50,12,226,25,$hPen)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF000000)
_GDIPlus_GraphicsDrawStringEx($hBackBuffer,$hpValue, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsTranslateTransform($hBackbuffer,0,50)
_GDIPlus_GraphicsDrawString($hBackBuffer,"MP",15,15,"arial",12)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF0000FF)
_GDIPlus_GraphicsFillRect($hBackBuffer,50,12,225 * ($mpValue/$maxMP),25,$hBrush)
_GDIPlus_GraphicsDrawRect($hBackBuffer,50,12,226,25,$hPen)
_GDIPlus_BrushSetSolidColor($hBrush,0xFF000000)
_GDIPlus_GraphicsDrawStringEx($hBackBuffer,$mpValue, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawString($hBackBuffer,"[LEFT CLICK] Decrease HP",15,80)
_GDIPlus_GraphicsDrawString($hBackBuffer,"[RIGHT CLICK] Decrease MP",15,100)
_GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap,0,0)
_GDIPlus_GraphicsResetTransform($hBackBuffer)
EndFunc
PixelSearch HP tracker example:
Execute the game.exe (compiled script from above), and run this script
Code:
AutoItSetOption("PixelCoordMode",2) ;relative to client window
$hwnd = WinGetHandle("game")
$maxHP = 1232
$xOffset = 50; bar left X value equals to sx
$ex = 275 ;bar end X value, right most x position
$barSize = $ex - $xOffset
$barBackColor = 0xFFFFFF
;currentSize -> size in pixels of current HP bar, is the bar that is decreased every time you loose some hp
;barSize -> size in pixels of the whole HP bar, is equal to currentSize bar when HP is full, constant value
;hpValue -> numeric value of current HP
;maxHP -> numeric value of maxium ammount of HP
;barBackColor -> color of the bar that is behind the HP bar
;FORMULA
;currentSize = barSize * ($hpValue/$maxHP)
;$maxHP * (currentSize/barSize) = $hpValue
$hpValue = "Unknown"
While Sleep(15)
if Not WinExists("game") Then ExitLoop
if Not WinActive($hwnd) Then ContinueLoop
;82 and 105 are y coordinates of search area, use autoitwindow info
$search = PixelSearch($xOffset,82,$ex,105,$barBackColor ,0,1,$hwnd)
If Not @error Then
$currentSize = $search[0]
;because is a pixel search, currentSize is an integer, then HP value may have some error
$hpValue = $maxHP * (($currentSize - $xOffset)/$barSize)
EndIf
ToolTip($hpValue,0,0)
WEnd
Image of code comments to know what all that means
A tip, use autoitwindow info with these options to help you find the correct
search area position
|
Tyvm for the generous reply, i will test this later. I am just new to autoit and it is fun. By the way i will going to use this script to cabal online. Another problem i am facing so far now is imagesearch it seems not to worked in the game. Imagesearch script is working in my desktop but when i use winactivate command it activate cabal window but not searching any image.
P.S. thanks button pressed 
|
|
|
 |
Similar Threads
|
Frage: Autoit Pixelsearch
06/23/2010 - AutoIt - 15 Replies
so ich hab da mal ne Frage bezüglich autoit und PixelSearch:
Wie krieg ich es hin dass Autoit nach bestimmten Pixeln sucht dann mit der Maus zu den Pixeln geht und dann darauf klickt.
Ich weiß dass man um die Pixel rauszufinden bzw freezen muss, aber welche Werte soll ich WOHIN tuhen? >.<
Könnte pls eina sich die Mühe machen und mia pls erklähren wie des mit dem Pixelsearch und der Maus dahin bewegen geht und wo ich die Werte dann eintragen soll. (Am besten den script reinposten und...
|
hilfe für autoit gesucht in sachen pixelsearch
12/01/2008 - Metin2 - 4 Replies
hi, ich wollte mich mal dranmachen und für den eigenbedarf ein tool scripten mit autoit, dass die lockmobs funktion und 1 hit attack auschaltet sobald in gelber bzw. lila punkt auf der minimap erscheint. Leider hab ich aber nicht den blassesten schimmer wie ich das mit der pixelerkennung machen soll. Vll kann mir da jemand helfen:rolleyes:
THX im vorraus an alle
|
autoit Pixelsearch?
10/24/2008 - Guild Wars - 7 Replies
Hy ich versuche mir auch einmal nen Bot zu machen, bin aber eher ein Anfänger. Deswegen brauche ich ma Hilfe!!
Mir geht es jetzt darum dass der Bot rauslaufen soll bzw. dass er etwas schreibt sobald er eine bestimmte Farbe in einem feld erkennt! (das er was schreiben soll habe ich geschrieben um erstma nur das zu kappieren. Wenn ich das hinkriege das er dann halt eienen Pixel erkennt, weiß ich den rest selber^^)
das habe ich geschrieben:
sleep (2000)
send ("v")
send...
|
[AutoIt] Problem mit PixelSearch.
08/19/2007 - General Coding - 3 Replies
Moin moin.
Ich hatte die Idee, dass man mit AutoIt ein PickIt Programm fuer D2 schreiben koennte. Hier erstmal der Code..
Soweit, so gut.. hm. Meine Idee dahinter war es, dass ich ein Script einfach nach der Farbe des Unique Tags in D2 (#958166) suchen und dann einen Mausklick auf das/die entsprechenden Pixel ausfuehren lasse..
Problem: Zurzeit funktioniert daran nichts, ausser die Terminate Funktion. Vielleicht kann mir ja jemand auch diesmal weiterhelfen ;>
|
All times are GMT +1. The time now is 00:20.
|
|