Jump to content

cant run more than one func


Recommended Posts

Hello :D

this bot is simply meant to send key stokes if i check a check box and press start. this works if i check only one check box, but if multiple boxes are checked it will only run which ever function is at the top most of the script and i cant figure out why?

i would like to have any number of combination's of the check boxes checked and run the appropriate function tied to them.

#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
Opt("TrayIconDebug", 1)
$mainwindow = GUICreate("Auto W0W", 313, 220, 298, 134)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
;Gui buttons \/
$Start = GUICtrlCreateButton("Start", 32, 136, 257, 65)
$Fast = GUICtrlCreateButton("Fast", 32, 8, 65, 41)
$Stop = GUICtrlCreateButton("Stop all", 256, 96, 33, 33)
$Medium = GUICtrlCreateButton("Medium", 128, 8, 65, 41)
$Slow = GUICtrlCreateButton("Slow", 224, 8, 65, 41)
$Afk = GUICtrlCreateCheckbox("AFK", 48, 64, 97, 17)
$As = GUICtrlCreateCheckbox("Auto Swing", 152, 64, 97, 17)
$Clicker = GUICtrlCreateCheckbox("Clicker", 48, 104, 97, 17)
$Class = GUICtrlCreateCheckbox("Class Ability", 152, 104, 97, 17)
;Setonevent
GUICtrlSetOnEvent($Start, "Start")
GUICtrlSetOnEvent($Stop, "stop")
GUISetState(@SW_SHOW)
$dostart = false
$doafk = false
$doAs = false
$doClicker = false
$doClass  = false

While 1
    Sleep(100)
    if $dostart then start2()
    if $doAs  then startas()
    if $doafk then startafk()
    if $doClicker then startClicker()
    if $doClass  then startClass()

WEnd

Func CLOSEClicked()

    If @GUI_WinHandle = $mainwindow Then
        Exit
    EndIf

EndFunc

Func Start()
$dostart = true

EndFunc

Func start2()
    If GUICtrlRead($As) = 1 Then $doAs = True
    If GUICtrlRead($Afk) = 1 Then $doafk = True
    If GUICtrlRead($Clicker) = 1 Then $doClicker = True
    If GUICtrlRead($Class) = 1 Then $doClass  = True

EndFunc

;check box functions
Func startAs()
        Do
            sleep (1100)
            Send("{2}")
            Sleep(80)
            Send("{2}")
            Sleep(Random(1000, 2000))
            GUICtrlRead($As)
        Until  $doas = false
EndFunc

Func startafk()
        Do
            sleep (1000)
            Send("{3}")
            Sleep(Random(800, 1000))
            GUICtrlRead($Afk)
        Until  $doafk = false
EndFunc

Func startClicker()
        Do
            sleep (1301)
            MouseClick("right")
            Sleep(100)
            MouseClick("left")
            Sleep(Random(9000, 9500))
            GUICtrlRead($Clicker)
        Until  $doClicker = false
EndFunc

Func startClass()
        Do
            sleep (1200)
            Send("{4}")
            Sleep(150)
            Send("{4}")
            Sleep(150)
            Send("{4}")
            Sleep(Random(4000, 8000))
            GUICtrlRead($Class )
        Until  $doClass = false
EndFunc
    
;stop function
Func Stop()
    $dostart = false
    $doafk = False
    $doClass = false
    $doClicker = false
    $doas = false
    GUICtrlSetState($As, $GUI_UNCHECKED)
    GUICtrlSetState($Afk, $GUI_UNCHECKED)
    GUICtrlSetState($Clicker, $GUI_UNCHECKED)
    GUICtrlSetState($Class, $GUI_UNCHECKED)
    MsgBox(0, "GUI Event", "Stoped")

EndFunc

i have found out that i cant realy run 2 functions simultaneously. besides making separate .exes for each function is there any other way i could look in to to make this work in one project with out all the extra .exes?

Edited by ulti
Link to comment
Share on other sites

One Loop, conditional statements?

Do

Select

Case <Item Checked>

;do stuff for this bit

Case <Item Checked>

;do stuff for this bit

Case <Item Checked>

;do stuff for this bit

;etc

EndSelect

Unti <CONDITION>

Or something like that :D

Cheers,

Brett

Link to comment
Share on other sites

I tried something similar to this before but it had the same result only one thing happens at once

#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
Opt("TrayIconDebug", 1)
$mainwindow = GUICreate("Auto W0W", 313, 220, 298, 134)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
;Gui buttons \/
$Start = GUICtrlCreateButton("Start", 32, 136, 257, 65)
$Fast = GUICtrlCreateButton("Fast", 32, 8, 65, 41)
$Stop = GUICtrlCreateButton("Stop all", 256, 96, 33, 33)
$Medium = GUICtrlCreateButton("Medium", 128, 8, 65, 41)
$Slow = GUICtrlCreateButton("Slow", 224, 8, 65, 41)
$Afk = GUICtrlCreateCheckbox("AFK", 48, 64, 97, 17)
$As = GUICtrlCreateCheckbox("Auto Swing", 152, 64, 97, 17)
$Clicker = GUICtrlCreateCheckbox("Clicker", 48, 104, 97, 17)
$Class = GUICtrlCreateCheckbox("Class Ability", 152, 104, 97, 17)
;Setonevent
GUICtrlSetOnEvent($Start, "Start")
GUICtrlSetOnEvent($Stop, "stop")
GUISetState(@SW_SHOW)
$dostart = false

While 1
    Sleep(100)
    if $dostart then start2()

WEnd

Func CLOSEClicked()

    If @GUI_WinHandle = $mainwindow Then
        Exit
    EndIf

EndFunc

Func Start()
$dostart = true

EndFunc

Func start2()
Do
Select
    Case GUICtrlRead($Afk) = 1
            sleep (1000)
            Send("{3}")
            Sleep(Random(800, 1000))
    Case GUICtrlRead($As) = 1
            sleep (1000)
            Send("{4}")
            Sleep(Random(800, 1000))
    Case GUICtrlRead($Class) = 1
            sleep (1000)
            Send("{5}")
            Sleep(Random(800, 1000))
    Case GUICtrlRead($Clicker) = 1
            sleep (1000)
            Send("{2}")
            Sleep(Random(800, 1000))
EndSelect
Until $dostart = false

EndFunc
Func Stop()
    $dostart = false
    GUICtrlSetState($As, $GUI_UNCHECKED)
    GUICtrlSetState($Afk, $GUI_UNCHECKED)
    GUICtrlSetState($Clicker, $GUI_UNCHECKED)
    GUICtrlSetState($Class, $GUI_UNCHECKED)
    MsgBox(0, "GUI Event", "Stoped")

EndFunc

any other ideas?

Link to comment
Share on other sites

No need to PM me... :D

Try doing something like this:

$case1 = 1
$case2 = 1
$case3 = 0
$case4 = 1

If $case1 = 1 Then
        MsgBox (0, "", "Case 1 is True")
EndIf

If $case2 = 1 Then
        MsgBox (0, "", "Case 2 is True")
EndIf

If $case3 = 1 Then
        MsgBox (0, "", "Case 3 is True")
EndIf

If $case4 = 1 Then
        MsgBox (0, "", "Case 4 is True")
EndIf

Cheers,

Brett

Link to comment
Share on other sites

No need to PM me... :D

Try doing something like this:

$case1 = 1
$case2 = 1
$case3 = 0
$case4 = 1

If $case1 = 1 Then
        MsgBox (0, "", "Case 1 is True")
EndIf

If $case2 = 1 Then
        MsgBox (0, "", "Case 2 is True")
EndIf

If $case3 = 1 Then
        MsgBox (0, "", "Case 3 is True")
EndIf

If $case4 = 1 Then
        MsgBox (0, "", "Case 4 is True")
EndIf

Cheers,

Brett

did u mean something like this? i already tried that if u did

#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
Opt("TrayIconDebug", 1)
$mainwindow = GUICreate("Auto W0W", 313, 220, 298, 134)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
;Gui buttons \/
$Start = GUICtrlCreateButton("Start", 32, 136, 257, 65)
$Fast = GUICtrlCreateButton("Fast", 32, 8, 65, 41)
$Stop = GUICtrlCreateButton("Stop all", 256, 96, 33, 33)
$Medium = GUICtrlCreateButton("Medium", 128, 8, 65, 41)
$Slow = GUICtrlCreateButton("Slow", 224, 8, 65, 41)
$Afk = GUICtrlCreateCheckbox("AFK", 48, 64, 97, 17)
$As = GUICtrlCreateCheckbox("Auto Swing", 152, 64, 97, 17)
$Clicker = GUICtrlCreateCheckbox("Clicker", 48, 104, 97, 17)
$Class = GUICtrlCreateCheckbox("Class Ability", 152, 104, 97, 17)
;Setonevent
GUICtrlSetOnEvent($Start, "Start")
GUICtrlSetOnEvent($Stop, "stop")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$dostart = false

While 1
    Sleep(100)
    if $dostart then start2()
WEnd


Func start2()
  If GUICtrlRead($Afk) = 1 then
        Do
            sleep (1000)
            Send("{3}")
            Sleep(Random(800, 1000))
            GUICtrlRead($Afk)
        Until  $dostart = false
    EndIf

  If GUICtrlRead($As) = 1 Then
        Do
            sleep (1100)
            Send("{2}")
            Sleep(80)
            Send("{2}")
            Sleep(Random(1000, 2000))
            GUICtrlRead($As)
        Until $dostart = false
    EndIf


  If GUICtrlRead($Clicker) = 1 Then
        Do
            sleep (1301)
            MouseClick("right")
            Sleep(100)
            MouseClick("left")
            Sleep(Random(9000, 9500))
            GUICtrlRead($Clicker)
        Until $dostart = false
    EndIf


  If GUICtrlRead($Class ) = 1 Then
        Do
            sleep (1200)
            Send("{4}")
            Sleep(150)
            Send("{4}")
            Sleep(150)
            Send("{4}")
            Sleep(Random(4000, 8000))
            GUICtrlRead($Class )
        Until  $dostart = false
    EndIf

EndFunc

Func startafk()
        Do
            sleep (1000)
            Send("{3}")
            Sleep(Random(800, 1000))
            GUICtrlRead($Afk)
        Until  $dostart = false
EndFunc


Func CLOSEClicked()

    If @GUI_WinHandle = $mainwindow Then
        Exit
    EndIf

EndFunc ;==>CLOSEClicked



Func Start()
$dostart = true

EndFunc ;==>Start


Func Stop()
    $dostart = false
    GUICtrlSetState($As, $GUI_UNCHECKED)
    GUICtrlSetState($Afk, $GUI_UNCHECKED)
    GUICtrlSetState($Clicker, $GUI_UNCHECKED)
    GUICtrlSetState($Class, $GUI_UNCHECKED)
    MsgBox(0, "GUI Event", "Stoped")

EndFunc ;==>Stop

im thinking the only way might be to have separate .exes

Link to comment
Share on other sites

well the only way i could figure out how to do it was useing Run("") and haveing each of the seperate loops saved as a single .exe

case $fast
            If ProcessExists("fFol.exe") Then
                ProcessClose("fFol.exe")
                GUICtrlSetData($fast, "Fast Follow")
            Else
                Run("fFol.exe")
                GUICtrlSetData($fast, "Turn off Fast Follow")
            EndIf

ohh well one day ill figure out a way im sure :D

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