Sign in to follow this  
Followers 0
jonathan2133

Help! Noob Making A Gui

8 posts in this topic

#1 ·  Posted (edited)

my initial program got help, thanks guys!

I have more help i need with making a gui below, see my next post...

Edited by jonathan2133

Share this post


Link to post
Share on other sites



Your label was overlapping with the input box making it impossible to click it, so I changed the length.

After you enter a number in the box, you have to hit enter for the slider to update. Also: If you drag the slider, the input box's value doesn't change until you let go.

#include <GUIConstants.au3>

GUICreate("Prog1",190,110)
$HPHeal = 80
$MPMed = 65

; lable for Heal%
GuiCtrlCreateLabel("HP needed to trigger heal %", 10, 10, 140, 20)
$HPinput = GuiCtrlCreateInput($HPHeal, 150, 8, 20, 20)
;Slider1 - used for $HPHeal
$HPHeal = GUICtrlCreateSlider (5,30,170,20)
GUICtrlSetLimit(1,0,100); change min/max value
GuiCtrlSetData($HPHeal, 80)

; lable for MP%
GuiCtrlCreateLabel("MP needed b4 Meditate %", 10, 60, 140, 20)
$MPinput = GuiCtrlCreateInput($MPMed, 150, 58, 20, 20)
;Slider2 - used for $MPMed
$MPMed = GUICtrlCreateSlider (5,80,170,20)
GUICtrlSetLimit(1,0,100); change min/max value
GuiCtrlSetData($MPMed, 65)

; GUI MESSAGE LOOP
GuiSetState()
While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        MsgBox(0x1000,"Info", "HP % is " & GuiCtrlRead($HPInput))
        MsgBox(0x1000,"Info", "MP % is " & GuiCtrlRead($MPInput))
        Exit
    ElseIf $msg = $HPheal Then;slider was moved, so update input box's value
        GuiCtrlSetData( $HPinput, GuiCtrlRead($HPHeal) )
    ElseIf $msg = $MPMed Then ;slider was moved, so update input box's value
        GuiCtrlSetData( $MPinput, GuiCtrlRead($MPMed) )
    ElseIf $msg > 0 Then;check if slider's value matches what is in the input box; update if needed
        If GuiCtrlRead($HPinput) <> GuiCtrlRead($HPHeal) Then GuiCtrlSetData($HPHeal, GuiCtrlRead($HPinput) )
        If GuiCtrlRead($MPinput) <> GuiCtrlRead($MPMed) Then GuiCtrlSetData($MPMed, GuiCtrlRead($MPinput) )
    EndIf
    
WEnd

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This should make it top most and also added a bit of code that updates the inputs if the slider is used

#include <GUIConstants.au3>

GUICreate("Prog1", 190, 110,-1,-1,-1,$WS_EX_TOPMOST)
$HPHeal = 80
$MPMed = 65

; lable for Heal%
GUICtrlCreateLabel("HP needed to trigger heal %", 10, 10, 140, 20)
$HPinput = GUICtrlCreateInput($HPHeal, 150, 8, 20, 20)
;Slider1 - used for $HPHeal
$HPHeal = GUICtrlCreateSlider(5, 30, 170, 20)
GUICtrlSetLimit(1, 0, 100); change min/max value
GUICtrlSetData($HPHeal, 80)
$tmp_HPHeal = 80

; lable for MP%
GUICtrlCreateLabel("MP needed b4 Meditate %", 10, 60, 140, 20)
$MPinput = GUICtrlCreateInput($MPMed, 150, 58, 20, 20)
;Slider2 - used for $MPMed
$MPMed = GUICtrlCreateSlider(5, 80, 170, 20)
GUICtrlSetLimit(1, 0, 100); change min/max value
GUICtrlSetData($MPMed, 65)
$tmp_MPMed = 65

; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            MsgBox(0x1000, "Info", "HP % is " & GUICtrlRead($HPinput))
            MsgBox(0x1000, "Info", "MP % is " & GUICtrlRead($MPinput))
            Exit
        Case $msg = $HPHeal;slider was moved, so update input box's value
            GUICtrlSetData($HPinput, GUICtrlRead($HPHeal))
        Case $msg = $MPMed;slider was moved, so update input box's value
            GUICtrlSetData($MPinput, GUICtrlRead($MPMed))
        Case Else;check if slider's value matches what is in the input box; update if needed
            If $tmp_HPHeal <> Int(GUICtrlRead($HPHeal)) Then
                $tmp_HPHeal = GUICtrlRead($HPHeal)
                GUICtrlSetData($HPinput, $tmp_HPHeal)
            EndIf
            If $tmp_MPMed <> Int(GUICtrlRead($MPMed)) Then
                $tmp_MPMed = GUICtrlRead($MPMed)
                GUICtrlSetData($MPinput, $tmp_MPMed)
            EndIf
            
            If GUICtrlRead($HPinput) <> GUICtrlRead($HPHeal) Then GUICtrlSetData($HPHeal, GUICtrlRead($HPinput))
            If GUICtrlRead($MPinput) <> GUICtrlRead($MPMed) Then GUICtrlSetData($MPMed, GUICtrlRead($MPinput))
    EndSelect
    
WEnd
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

yes but where do i add the code from my other program? its a macro so it runs an infinate loop.

Don't know, we only helped with the code you supplied.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

use [ code ] at the beginning and [ / code ] at the end without the spaces

#include <GUIConstants.au3>

Global $Paused = 1
HotKeySet("{Pause}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
Sleep("2000");wait till game runnung
;3238597;Blue color
;15526360;white color
;15526360;grey
;some of those not needed, there from previous versions i made
$battle = 0
$hp = 10
$mp = 10
$mp2 = 1000
;declaring varyables so stuff doesnt screw up


GUICreate("Prog1", 190, 110, -1, -1, -1, $WS_EX_TOPMOST)
$HPHeal = 80
$MPMed = 65

; lable for Heal%
GUICtrlCreateLabel("HP needed to trigger heal %", 10, 10, 140, 20)
$HPinput = GUICtrlCreateInput($HPHeal, 150, 8, 20, 20)
;Slider1 - used for $HPHeal
$HPHeal = GUICtrlCreateSlider(5, 30, 170, 20)
GUICtrlSetLimit(1, 0, 100); change min/max value
GUICtrlSetData($HPHeal, 80)
$tmp_HPHeal = 80

; lable for MP%
GUICtrlCreateLabel("MP needed b4 Meditate %", 10, 60, 140, 20)
$MPinput = GUICtrlCreateInput($MPMed, 150, 58, 20, 20)
;Slider2 - used for $MPMed
$MPMed = GUICtrlCreateSlider(5, 80, 170, 20)
GUICtrlSetLimit(1, 0, 100); change min/max value
GUICtrlSetData($MPMed, 65)
$tmp_MPMed = 65

; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            MsgBox(0x1000, "Info", "HP % is " & GUICtrlRead($HPinput))
            MsgBox(0x1000, "Info", "MP % is " & GUICtrlRead($MPinput))
            Exit
        Case $msg = $HPHeal;slider was moved, so update input box's value
            GUICtrlSetData($HPinput, GUICtrlRead($HPHeal))
        Case $msg = $MPMed;slider was moved, so update input box's value
            GUICtrlSetData($MPinput, GUICtrlRead($MPMed))
        Case Else;check if slider's value matches what is in the input box; update if needed
            If $tmp_HPHeal <> Int(GUICtrlRead($HPHeal)) Then
                $tmp_HPHeal = GUICtrlRead($HPHeal)
                GUICtrlSetData($HPinput, $tmp_HPHeal)
            EndIf
            If $tmp_MPMed <> Int(GUICtrlRead($MPMed)) Then
                $tmp_MPMed = GUICtrlRead($MPMed)
                GUICtrlSetData($MPinput, $tmp_MPMed)
            EndIf
            
            If GUICtrlRead($HPinput) <> GUICtrlRead($HPHeal) Then GUICtrlSetData($HPHeal, GUICtrlRead($HPinput))
            If GUICtrlRead($MPinput) <> GUICtrlRead($MPMed) Then GUICtrlSetData($MPMed, GUICtrlRead($MPinput))
            If Not $Paused Then
                ToolTip("")
                Do
                    $x = 196
                    Do
                        If $Paused Then ExitLoop 2
                        If PixelGetColor($x, 72) = 3238597 Then;blue, finds percent of health remaining
                            $x = $x - 24
                            $hp = $x / 172 * 100
                            $x = 24
                        Else
                            $x = $x - 1
                        EndIf
                    Until $x = 24
                    
                    
                    $x = 196
                    Do
                        If $Paused Then ExitLoop 2
                        If PixelGetColor($x, 104) = 3238597 Then;blue, finds magic remaining
                            $x = $x - 24
                            $mp = $x / 172 * 100
                            $x = 24
                        Else
                            $x = $x - 1
                        EndIf
                    Until $x = 24
                    Sleep("500")
                    
                ;Battle
                    If $battle = 0 Then
                        If $hp < 80 Then
                        ;do healing code, too long to post here
                        ElseIf $hp > 79 And $mp > 20 Then
                        ;do attack, again too long for here
                        EndIf
                    EndIf
                    
                    
                ;repeat forever
                    If $Paused Then ExitLoop
                Until $hp = 23423548329578943207589043728590324
            Else
                ToolTip('"Paused"', 0, 0)
            EndIf
            
    EndSelect
    
WEnd



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

Func Terminate()
    Exit 0
EndFunc  ;==>Terminate

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

well i been messing with the code for a while now and have a new set of problems...

Firstly i must say thanks for the help CyberSlug and Gafrost, you supplied me with a lot of help and code, most of which i have brutally mutilated to form this mess. You two have taught me 3 essential things... Keep stuff organized, site what im doing, and KISS.... lol. My thanks go out to you, and you diserve pretty much all the credit for what is below

Ok off to the problems...

$battle = 0
$hp = 10
$mp = 10
$mp2 = 1000
$HPHeal = 80
$MPMed = 75

GUICreate("Prog1", 190, 110, -1, -1, -1, $WS_EX_TOPMOST);makes window on top


; lable for Heal%
GuiCtrlCreateLabel("HP needed to trigger heal %", 10, 10, 140, 20)
GuiCtrlCreateLabel($HPHeal, 150, 8, 20, 20) ;displays current percentage
;Slider1 - used for $HPHeal
$HPHeal = GUICtrlCreateSlider (5,30,170,20)
GUICtrlSetLimit(1,0,100); change min/max value
GuiCtrlSetData($HPHeal, 80)

; lable for MP%
GuiCtrlCreateLabel("MP needed b4 Meditate %", 10, 60, 140, 20)
GuiCtrlCreateLabel($MPMed, 150, 58, 20, 20) ;displays current percentage
;Slider2 - used for $MPMed
$MPMed = GUICtrlCreateSlider (5,80,170,20)
GUICtrlSetLimit(1,0,100); change min/max value
GuiCtrlSetData($MPMed, 75)

; GUI MESSAGE LOOP - Not sure, guessing it starts messing with the data from the form
GuiSetState()

While 1
  $msg = GuiGetMsg();gets data from the form (whatever changed)? not too sure
  Select 
    Case $msg = $GUI_EVENT_CLOSE;if i close the thing using the X it does this first.... kinda nifty
      MsgBox(0x1000,"Info", "HP % is " & GuiCtrlRead($HPHeal))
      MsgBox(0x1000,"Info", "MP % is " & GuiCtrlRead($MPMed))
      Exit
  Endselect 
                                                           ;
  If Not $Paused Then;ummm.... removes the "script is paused" message
    ToolTip("")
                                                           ;
  If $Paused Then ExitLoop 1;exits to somewhere if paused... not exactly sure... seems to work

sleep("5000")
msgbox(0x1000,"HPHeal current value",$HPHeal)
msgbox(0x1000,"MPMed current value",$MPMed)

;Insert my program code here, mostly more if statments relying on readings from above, i added the message boxes to see whats going on

Else;if not paused, show "", leaves only one option right? not sure if this is the best thing here...
    ToolTip('"Paused"', 0, 0)
  EndIf
WEnd



Func TogglePause()
$Paused = NOT $Paused
;While $Paused     ;this junk taken out for the other meathod used in this form
;sleep(100)         ;taking this out should leave for being able to mess 
;ToolTip('"Paused"',0,0);with the sliders when the thing is paused
;WEnd
;ToolTip("")
EndFunc;==>TogglePause

Func Terminate()
    Exit 0
EndFunc ;==>Terminate

so this is what happens.... i run the script. It starts paused (which i really like, thanks! )

the HP is slid over to 80... thats fine

the MP is slid to 75.... also right

the message boxes start popping up

The hp pops up as 80... good

the MP pops up as 65?!? thats not right... :mellow: -edit ->that was my mistake looked at the code and it was me being a NOOB... lol

I wait for the 2nd round of values to come up, nbot touching the sliders...

0 and 0.... thats not supposed to happen... :>

i click the X to quit the program.... doesnt close until the messages pop up again.... (i want it to close right away)

now if i move the sliders, the first set of boxes change the values,

the display on the GUI does NOT change

and im still confused... lol :)

maybe noobs shouldnt try to program :">

Hers what i want it to do

i want to be able to call on the $HPHeal and $MPMed values at any time where my code is going (where the message boxes are now)

i want to be able to slide the sliders as the prog is running (and when its paused) and see values change

i want ONLY THE SLIDERS AND % VALUES, and the big red X to work when its paused

- OR -

i want the prog to pause exactly where it is... if its halfway through a line of code then i want it to halt there and start again when i hit pause again

what else... Escape should exit at any time if i need to.... panic buttons are my friend :o

lastly i want to give a great big "Pat on the back" to whoever can help get this all done...

im gonna get me an edjumakation on this one... lol :)

many thanks!

Share this post


Link to post
Share on other sites

This should take care of a few of your issues

#include <GUIConstants.au3>

Global $Paused = 1
HotKeySet("{Pause}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
Sleep("2000");wait till game runnung
;3238597;Blue color
;15526360;white color
;15526360;grey
;some of those not needed, there from previous versions i made
$battle = 0
$hp = 10
$mp = 10
$mp2 = 1000
;declaring varyables so stuff doesnt screw up


GUICreate("Prog1", 190, 110, -1, -1, -1, $WS_EX_TOPMOST)
$HPHeal = 80
$MPMed = 65

; lable for Heal%
GUICtrlCreateLabel("HP needed to trigger heal %", 10, 10, 140, 20)
$HPinput = GUICtrlCreateInput($HPHeal, 150, 8, 20, 20)
;Slider1 - used for $HPHeal
$HPHeal = GUICtrlCreateSlider(5, 30, 170, 20)
GUICtrlSetLimit(1, 0, 100); change min/max value
GUICtrlSetData($HPHeal, 80)
$tmp_HPHeal = 80

; lable for MP%
GUICtrlCreateLabel("MP needed b4 Meditate %", 10, 60, 140, 20)
$MPinput = GUICtrlCreateInput($MPMed, 150, 58, 20, 20)
;Slider2 - used for $MPMed
$MPMed = GUICtrlCreateSlider(5, 80, 170, 20)
GUICtrlSetLimit(1, 0, 100); change min/max value
GUICtrlSetData($MPMed, 65)
$tmp_MPMed = 65

; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Terminate()
        Case $msg = $HPHeal;slider was moved, so update input box's value
            GUICtrlSetData($HPinput, GUICtrlRead($HPHeal))
        Case $msg = $MPMed;slider was moved, so update input box's value
            GUICtrlSetData($MPinput, GUICtrlRead($MPMed))
        Case Else;check if slider's value matches what is in the input box; update if needed
            CheckSettings()
            If Not $Paused Then
                ToolTip("")
                Do
                    CheckSettings()
                    $msg = GUIGetMsg()
                    If $msg = $GUI_EVENT_CLOSE Then Terminate()
                    $x = 196
                    Do
                        CheckSettings()
                        $msg = GUIGetMsg()
                        If $msg = $GUI_EVENT_CLOSE Then Terminate()
                        If $Paused Then ExitLoop 2
                        If PixelGetColor($x, 72) = 3238597 Then;blue, finds percent of health remaining
                            $x = $x - 24
                            $hp = $x / 172 * 100
                            $x = 24
                        Else
                            $x = $x - 1
                        EndIf
                    Until $x = 24
                    
                    
                    $x = 196
                    Do
                        CheckSettings()
                        $msg = GUIGetMsg()
                        If $msg = $GUI_EVENT_CLOSE Then Terminate()
                        If $Paused Then ExitLoop 2
                        If PixelGetColor($x, 104) = 3238597 Then;blue, finds magic remaining
                            $x = $x - 24
                            $mp = $x / 172 * 100
                            $x = 24
                        Else
                            $x = $x - 1
                        EndIf
                    Until $x = 24
                    Sleep("500")
                    
                ;Battle
                    If $battle = 0 Then
                        If $hp < 80 Then
                        ;do healing code, too long to post here
                        ElseIf $hp > 79 And $mp > 20 Then
                        ;do attack, again too long for here
                        EndIf
                    EndIf
                    
                    
                ;repeat forever
                    If $Paused Then ExitLoop
                Until $hp = 23423548329578943207589043728590324
            Else
                ToolTip('"Paused"', 0, 0)
            EndIf
            
    EndSelect
    
WEnd

Func CheckSettings()
    If $tmp_HPHeal <> Int(GUICtrlRead($HPHeal)) Then
        $tmp_HPHeal = GUICtrlRead($HPHeal)
        GUICtrlSetData($HPinput, $tmp_HPHeal)
    EndIf
    If $tmp_MPMed <> Int(GUICtrlRead($MPMed)) Then
        $tmp_MPMed = GUICtrlRead($MPMed)
        GUICtrlSetData($MPinput, $tmp_MPMed)
    EndIf
    
    If GUICtrlRead($HPinput) <> GUICtrlRead($HPHeal) Then GUICtrlSetData($HPHeal, GUICtrlRead($HPinput))
    If GUICtrlRead($MPinput) <> GUICtrlRead($MPMed) Then GUICtrlSetData($MPMed, GUICtrlRead($MPinput))
EndFunc  ;==>CheckSettings

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

Func Terminate()
    MsgBox(0x1000, "Info", "HP % is " & GUICtrlRead($HPinput))
    MsgBox(0x1000, "Info", "MP % is " & GUICtrlRead($MPinput))
    Exit 0
EndFunc  ;==>Terminate

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

dude looks like u were using one of my previous posts not my latest bit of code...

anyways, this looks like its a lot better.... im getting good values returned, its updating when paused, its great. Many thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0