Jump to content

Question


 Share

Recommended Posts

$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
Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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,
 

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...