Delta01 Posted January 29, 2008 Posted January 29, 2008 Hey, Well, I want to make an HP bar that records your character's current HP from the game and displays it in an autoit gui. (I can get the current HP from memory and have that working) What function would I use to make an HP bar, naturally it'd need to update quickly and be able to go up and down.. Thnx
danielkza Posted January 29, 2008 Posted January 29, 2008 The obvious answer would be a progressbar,you can even change the image of it.
BillLuvsU Posted January 29, 2008 Posted January 29, 2008 (edited) Edit: Nevermind previous post o_0. Use a progress bar, why would you use anything else? Why should that evan be a question? Unless your going to get all technical and make a custom AVI clip and have it look all fancy and waste a few hours on making this ridiculously overdone health bar, then yes, use a prgress bar. Edited January 29, 2008 by fear1313 [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw
Swift Posted January 29, 2008 Posted January 29, 2008 heres a simple progress setup...that may help you expandcollapse popup;Global Const $PBS_MARQUEE = 0x00000008; The progress bar moves like a marquee Global $i=0 ; Create GUI $Form1 = GUICreate("Progress Demo By CyberZeroCool", 401, 301, 341, 258) $Progress1 = GUICtrlCreateProgress(0, 0, 25, 297, BitOR($PBS_SMOOTH,$PBS_VERTICAL,$PBS_MARQUEE)) $Progress2 = GUICtrlCreateProgress(104, 0, 289, 25) $Progress3 = GUICtrlCreateProgress(104, 56, 289, 25, $PBS_MARQUEE) $Label1 = GUICtrlCreateLabel("-1 (NO STYLE)", 104, 32, 75, 17) $Label2 = GUICtrlCreateLabel("$PBS_MARQUEE", 104, 88, 91, 17) $Label3 = GUICtrlCreateLabel("$PBS_MARQUEE+$PBS_SMOOTH+$PBS_VERTICAL", 32, 280, 268, 17) $Progress4 = GUICtrlCreateProgress(32, 0, 25, 265, BitOR($PBS_VERTICAL,$PBS_MARQUEE)) $Progress5 = GUICtrlCreateProgress(104, 112, 289, 25, $PBS_SMOOTH) $Label4 = GUICtrlCreateLabel("$PBS_SMOOTH", 104, 144, 84, 17) $Progress6 = GUICtrlCreateProgress(104, 162, 289, 25, BitOR($PBS_SMOOTH,$PBS_MARQUEE)) $Label5 = GUICtrlCreateLabel("$PBS_MARQUEE+$PBS_SMOOTH", 104, 194, 177, 17) $Label6 = GUICtrlCreateLabel("$PBS_MARQUEE+$PBS_VERTICAL", 64, 248, 182, 17) $Progress7 = GUICtrlCreateProgress(64, 0, 25, 233, $PBS_VERTICAL) $Label7 = GUICtrlCreateLabel("$PBS_VERTICAL", 92, 220, 89, 17) GUISetState() AdlibEnable("Advance", 50) ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE Func Advance() $i=$i+1 GUICtrlSetData($Progress1, $i) GUICtrlSetData($Progress2, $i) GUICtrlSetData($Progress3, $i) GUICtrlSetData($Progress4, $i) GUICtrlSetData($Progress5, $i) GUICtrlSetData($Progress6, $i) GUICtrlSetData($Progress7, $i) If $i = 100 Then $i = 0 EndFunc
Delta01 Posted January 30, 2008 Author Posted January 30, 2008 Sorry for the gay question =) Is there anyway I can put a label on my progress bar without having it blink when the progress bar / label updates? ATM, I've tried GuiCtrlSetData to change the values on the label, but whenever the label or the bar updates it blinks
Delta01 Posted January 30, 2008 Author Posted January 30, 2008 Is it even possible to have a label over a progress bar without it blinking when it updates?
BrettF Posted January 30, 2008 Posted January 30, 2008 Is it even possible to have a label over a progress bar without it blinking when it updates?Make sure the Z ordering is correct. What is your code? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Delta01 Posted January 30, 2008 Author Posted January 30, 2008 My code is... GuiCreate("My HP tool", 300, 100) $HP = GuiCtrlCreateProgress(5, 20, 150, 30, $PBS_SMOOTH) $HpLabel = GuiCtrlCreateLabel("00000/00000", 45, 30, -1, 14, $GUI_ONTOP) GuiSetState() AdlibEnable("GetHp") WinSetOnTop("My HP tool", "", 1) Do Until GuiGetMsg() = $GUI_EVENT_CLOSE Func GetHP() ;Gets the current HP value $Val1 = $CurHP / $MaxHp $HpBarVal = $Val1*100 GuiCtrlSetData($HP, $HPBarVal) GuiCtrlSetData($HpLabel, $CurHp & "/" & $MaxHp) EndFunc Func _FindNewAddress(ByRef $Pointer, ByRef $OSet) ;Used for dynamic reading EndFunc The parts where it gets the HP value shouldn't really matter
seandisanti Posted January 30, 2008 Posted January 30, 2008 My code is... GuiCreate("My HP tool", 300, 100) $HP = GuiCtrlCreateProgress(5, 20, 150, 30, $PBS_SMOOTH) $HpLabel = GuiCtrlCreateLabel("00000/00000", 45, 30, -1, 14, $GUI_ONTOP) GuiSetState() AdlibEnable("GetHp") WinSetOnTop("My HP tool", "", 1) Do Until GuiGetMsg() = $GUI_EVENT_CLOSE Func GetHP() ;Gets the current HP value $Val1 = $CurHP / $MaxHp $HpBarVal = $Val1*100 GuiCtrlSetData($HP, $HPBarVal) GuiCtrlSetData($HpLabel, $CurHp & "/" & $MaxHp) EndFunc Func _FindNewAddress(ByRef $Pointer, ByRef $OSet) ;Used for dynamic reading EndFunc The parts where it gets the HP value shouldn't really matteranother thing that you could do, instead of a progress bar, is use an image of a color that is stretched depending on the value. you really wouldn't be adding a whole lot of code over the implementation with the progress bar, but would have a little bit more power to customize and make it look the way i think you want it to. all an HP bar would be is like a black rectangle with a border of whatever length, and then another image over it that is slightly smaller vertically, and about a hundred times narrower. say your background of the hp bar is 100x 20, then make another image that's 1x18 and sits right on top of it in a control that you resize based on calculations like $picwidth = $hp/$backgroundwidth*10000 so that when HP is maxed, the HP completely covers the width of the background, and moves down 1% every 1% of damage is taken. make sense? another thing to look at since you're grabbing the HP from memory, why not only update the bar when it changes? you'll eliminate a lot of your blinking, and reduce the resource need of your script, and throw a Sleep() into your loop, checking for change every 100 milliseconds or so will still keep it accurate but it will again reduce the overhead and make everything else run better
Delta01 Posted January 30, 2008 Author Posted January 30, 2008 another thing that you could do, instead of a progress bar, is use an image of a color that is stretched depending on the value. you really wouldn't be adding a whole lot of code over the implementation with the progress bar, but would have a little bit more power to customize and make it look the way i think you want it to. all an HP bar would be is like a black rectangle with a border of whatever length, and then another image over it that is slightly smaller vertically, and about a hundred times narrower. say your background of the hp bar is 100x 20, then make another image that's 1x18 and sits right on top of it in a control that you resize based on calculations like $picwidth = $hp/$backgroundwidth*10000 so that when HP is maxed, the HP completely covers the width of the background, and moves down 1% every 1% of damage is taken. make sense? another thing to look at since you're grabbing the HP from memory, why not only update the bar when it changes? you'll eliminate a lot of your blinking, and reduce the resource need of your script, and throw a Sleep() into your loop, checking for change every 100 milliseconds or so will still keep it accurate but it will again reduce the overhead and make everything else run betterAhhh, ok. That's a good idea, I'll see what I can do : )
Delta01 Posted January 30, 2008 Author Posted January 30, 2008 I tired that and no, it still flashes.
seandisanti Posted January 30, 2008 Posted January 30, 2008 (edited) I tired that and no, it still flashes.can i see your code for that attempt?***edit***P.S. did it atleast reduce system load while your script is running? Edited January 30, 2008 by cameronsdad
Linux Posted January 31, 2008 Posted January 31, 2008 (edited) Check this out: expandcollapse popup#include <guiconstants.au3> GuiCreate("My HP tool", 300, 100) XPStyleToggle(1) ; Use this if you running in a Windows XP machine $HP = GuiCtrlCreateProgress(5, 20, 150, 30, $PBS_SMOOTH) $HpLabel = GuiCtrlCreateLabel("00000/00000", 45, 30, -1, 14, $GUI_ONTOP) Global $HpValue = 0 GuiSetState() WinSetOnTop("My HP tool", "", 1) Do $HpValue += 2 $tol=255; $red=$tol-100-$hpValue; if ($hpValue<50) then $tol=150; $sec=Int($tol*($hpValue/100)); $color =$sec + 256 * $sec + 65536* $red GUICtrlSetData($Hp,$HpValue) GUICtrlSetColor($hp, $color) GuiCtrlSetData($HpLabel, $HpValue) If $hpValue >=100 then $hpValue = 0 Sleep(50) Until GuiGetMsg() = $GUI_EVENT_CLOSE Func XPStyleToggle($OnOff = 1) If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0 If $OnOff Then $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties") DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) Return 1 ElseIf IsArray($XS_n) Then DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0]) $XS_n = "" Return 1 EndIf Return 0 EndFunc ;==>XPStyleToggle, for changing progress bar colors Edited January 31, 2008 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now