eKolin

Question

8 posts in this topic

#1 ·  Posted (edited)

$value1=0
$value2=0

Global $hGUI = GUICreate("V1", 573, 120, -1, -1)
GUICtrlCreateLabel("Value1", 16, 16, 188, 17)
Global $iVariable = GUICtrlCreateInput("0", 208, 16, 105, 21)
Global $Label2 = GUICtrlCreateLabel("OR", 320, 16, 116, 17)
GUICtrlCreateLabel("Value2", 17, 85, 188, 50)
Global $iVariable2 = GUICtrlCreateInput("0", 209, 82, 105, 21)
Global $Label4 = GUICtrlCreateLabel("k", 318, 85, 105, 50)
Global $bChange = GUICtrlCreateButton("Start", 440, 16, 113, 57)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $bChange
            $value1 = GUICtrlRead($iVariable)
            $value2 = GUICtrlRead($iVariable2)
            WinClose("V1")
    EndSwitch
    Sleep(10)
 WEnd

$x = WinActivate("Screen")


While ($value1>245160)
   functions()
   $value1-=245160
WEnd

While ($value2>0)
   functions()
   $value2-=1
WEnd


I was expecting, that after i will press the "start" button the window will close and perform functions(). What's wrong with this? (After i've typed "2" in $value2 field)

Edited by eKolin
Typo

Share this post


Link to post
Share on other sites

Why should it call functions()? You never leave the While 1 loop.
BTW: Why do you want to WinClose the GUI you created yourself. Do you want to minimize the window or what do you try to achieve?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@waterI'm trying to change 2 $variables values and then when pressed "start" the GUI would dissapear and following functions would be executed depending on values

I've found that

While ($variable>0)
Wend

Works good when i want to do exact amount of loops, unless you've a better suggestion.

Btw i've replaced like 200 lines of unneeded code to functions()

Edited by eKolin
Typo

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try:

Opt("TrayAutoPause", 0)
Global $hGUI = GUICreate("V1", 573, 120, -1, -1)
GUICtrlCreateLabel("Value1", 16, 16, 188, 17)
Global $iVariable = GUICtrlCreateInput("0", 208, 16, 105, 21)
Global $Label2 = GUICtrlCreateLabel("OR", 320, 16, 116, 17)
GUICtrlCreateLabel("Value2", 17, 85, 188, 50)
Global $iVariable2 = GUICtrlCreateInput("0", 209, 82, 105, 21)
Global $Label4 = GUICtrlCreateLabel("k", 318, 85, 105, 50)
Global $bChange = GUICtrlCreateButton("Start", 440, 16, 113, 57)
GUISetState(@SW_SHOW)

Global $value1 = 0
Global $value2 = 0
Global $gold, $trips


While 1
    Switch GUIGetMsg()
        Case -3
            Exits()
        Case $bChange
            $value1 = GUICtrlRead($iVariable)
            $value2 = GUICtrlRead($iVariable2)
            GUISetState(@SW_HIDE, $hGUI)
            TrayTip("Auto Start", "Working...", 1)
            
            WinActivate("Screen")

            While ($value1 > 245160)
                FunctionAutoGame()
                $gold -= 245160
            WEnd

            While ($value2 > 0)
                FunctionAutoGame()
                $trips -= 1
            WEnd
            
            GUISetState(@SW_SHOW, $hGUI)
            GUISetState(@SW_RESTORE, $hGUI)
    EndSwitch
WEnd

Func FunctionAutoGame()
    ; Start auto game
EndFunc   ;==>FunctionAutoGame

Func Exits()
    Exit
EndFunc   ;==>Exits

OR:

Opt("TrayAutoPause", 0)
Global $hGUI = GUICreate("V1", 573, 120, -1, -1)
GUICtrlCreateLabel("Value1", 16, 16, 188, 17)
Global $iVariable = GUICtrlCreateInput("0", 208, 16, 105, 21)
Global $Label2 = GUICtrlCreateLabel("OR", 320, 16, 116, 17)
GUICtrlCreateLabel("Value2", 17, 85, 188, 50)
Global $iVariable2 = GUICtrlCreateInput("0", 209, 82, 105, 21)
Global $Label4 = GUICtrlCreateLabel("k", 318, 85, 105, 50)
Global $bChange = GUICtrlCreateButton("Start", 440, 16, 113, 57)
GUISetState(@SW_SHOW)

Global $value1 = 0
Global $value2 = 0
Global $gold, $trips


While 1
    Switch GUIGetMsg()
        Case -3
            Exits()
        Case $bChange
            $value1 = GUICtrlRead($iVariable)
            $value2 = GUICtrlRead($iVariable2)
            GUIDelete($hGUI)
            While ($value1 > 245160)
                FunctionAutoGame()
                $gold -= 245160
            WEnd

            While ($value2 > 0)
                FunctionAutoGame()
                $trips -= 1
            WEnd
    EndSwitch
WEnd

Func FunctionAutoGame()
    ; Start auto game
EndFunc   ;==>FunctionAutoGame

Func Exits()
    Exit
EndFunc   ;==>Exits

 



R

Opt("TrayAutoPause", 0)
Global $hGUI = GUICreate("V1", 573, 120, -1, -1)
GUICtrlCreateLabel("Value1", 16, 16, 188, 17)
Global $iVariable = GUICtrlCreateInput("0", 208, 16, 105, 21)
Global $Label2 = GUICtrlCreateLabel("OR", 320, 16, 116, 17)
GUICtrlCreateLabel("Value2", 17, 85, 188, 50)
Global $iVariable2 = GUICtrlCreateInput("0", 209, 82, 105, 21)
Global $Label4 = GUICtrlCreateLabel("k", 318, 85, 105, 50)
Global $bChange = GUICtrlCreateButton("Start", 440, 16, 113, 57)
GUISetState(@SW_SHOW)

Global $value1 = 0
Global $value2 = 0
Global $gold, $trips


While 1
    Switch GUIGetMsg()
        Case -3
            Exits()
        Case $bChange
            $value1 = GUICtrlRead($iVariable)
            $value2 = GUICtrlRead($iVariable2)
            GUIDelete($hGUI)
            ExitLoop
    EndSwitch
WEnd


WinActivate("Screen")

While ($value1 > 245160)
    FunctionAutoGame()
    $gold -= 245160
WEnd

While ($value2 > 0)
    FunctionAutoGame()
    $trips -= 1
WEnd


Func FunctionAutoGame()
    ; Start auto game
EndFunc   ;==>FunctionAutoGame

Func Exits()
    Exit
EndFunc   ;==>Exits

 

Edited by Trong
;

Regards,
 

Share this post


Link to post
Share on other sites

With "disappear" you mean "become invisible" (so it can be displayed again after the functions have ended) or "delete"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@waterDelete. I will try Trong suggestion in a minute.

Jeez i've messed up in original code. Tried to be sneaky but didin't change $gold and $trips. Don't be rude at me for game automation, it's just that i want to have a goal where i could say that i'm good enough in AutoIt to go advanced.

Btw i've edited main post "While" and "Wend" stuff.

EDIT:
@Trong Modified your first script and got what i've wanted

Edited by eKolin

Share this post


Link to post
Share on other sites

Kolin,

59 minutes ago, eKolin said:

Tried to be sneaky but didin't change $gold and $trips. Don't be rude at me for game automation

That is your flex all used up, so do not try that again.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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