Jump to content

Script not clicking radio/buttons when broken into functions


Regency
 Share

Recommended Posts

My code was one big function but i tried to brake it down for easier add-ons later. but now it wont do like it s told to.

If you look at the code as is everything works with out the little functions, for the life of me i dont know why braking them into smaller functions messed up the CrimesCommit() and GtaCommit() Functions. Help? why wont it reconize the page and click it?

#requireadmin
#AutoIt3Wrapper_run_debug_mode=Y
#include <GUIConstants.au3>
#include <Constants.au3>
#include <IE.au3>
#include  <Misc.au3>
;Opt("MustDeclareVars", 1); having this option set will help find mistakes before you run it. Such as using a variable before setting its value or misspelling a variable
Opt("TrayOnEventMode", 1)
Opt("TrayAutoPause", 0)
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "_MinimizeToTray")


Global $name1 = ''
Global $pass1 = ''
Global $url1 = ''
Global $Paused = 0
Global $oLoginPage = ''
Global $Crimes = ''
Global $Gta = ''
Global $oVerify = _IEGetObjById($Crimes, "ctl00_MainPageContent_valCrimes_btn1") = ''
Global $Verify = _IEGetObjById($Gta, "ctl00_MainPageContent_valCarTheft_btn1") = ''

Global $Quick = GUICreate("Auto Scripter - By - ScorpiA", 290, 200, 340, 300)
Global $Desired = GUICtrlCreateGroup("TMN Login Name", 8, 8, 265, 49) ; Log in name for Themafianetwork.net
Global $username = GUICtrlCreateInput("", 16, 24, 145, 21)
Global $savename = GUICtrlCreateButton("Save", 168, 24, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $DesiredP = GUICtrlCreateGroup("Password", 8, 56, 265, 49) ; Password for the acct stated above
Global $password = GUICtrlCreateInput("", 16, 72, 145, 21)
Global $savepassword = GUICtrlCreateButton("Save", 168, 72, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $StartUrl = GUICtrlCreateGroup("Address to log into TMN with", 8, 104, 256, 49) ; You can use proxys if you like, it just needs to get you to The mafia network
Global $address = GUICtrlCreateInput("", 16, 120, 145, 21)
Global $saveurl = GUICtrlCreateButton("Save", 168, 120, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)


Global $User = GUICtrlCreateLabel("", 8, 352, 250, 17) ; This is the Username
Global $Pass = GUICtrlCreateLabel("", 8, 368, 250, 17) ; This is the password
Global $Url = GUICtrlCreateLabel("", 8, 384, 250, 17) ; The url you posted above
Global $Crime = GUICtrlCreateLabel("", 8, 400, 250, 17) ; You need to click this on the script program interface or it wont work
Global $Create = GUICtrlCreateLabel("", 8, 464, 250, 17)
Global $Gta = GUICtrlCreateLabel("", 8, 432, 250, 17)
Global $Make = GUICtrlCreateButton("Start Auto Scripter By ScorpiA - Hit ESC to Exit", 8, 168, 267, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            _MinimizeToTray()
        Case $savename
            $name1 = GUICtrlRead($username)
            GUICtrlSetData($User, $name1)
        Case $savepassword
            $pass1 = GUICtrlRead($password)
            GUICtrlSetData($Pass, $pass1)
        Case $saveurl
            $url1 = GUICtrlRead($address) & "/login.aspx"
            GUICtrlSetData($Url, $url1)
        Case $address
            $Cr1 = GUICtrlRead($address) & "/Authenticated/crimes.aspx"
            GUICtrlSetData($Crime, $Cr1)
            $G1 = GUICtrlRead($address) & "/Authenticated/cartheft.aspx"
            GUICtrlSetData($Gta, $G1)
        Case $Make
            myRun()
    EndSwitch
WEnd

Func myRun()
    HotKeySet("{Home}", "TogglePause")
    HotKeySet("{ESC}", "Terminate")


    Local $oLoginPage = 0
    Local $oUser = 0
    Local $oPass = 0
    Local $oLogIn = 0

    $oLoginPage = _IECreate($url1)
    _IELoadWait($oLoginPage)
    $oUser = _IEGetObjByName($oLoginPage, "Login1$UserName")
    _IEFormElementSetValue($oUser, $name1)
    $oPass = _IEGetObjByName($oLoginPage, "Login1$Password")
    _IEFormElementSetValue($oPass, $pass1)
    $oLogIn = _IEGetObjByName($oLoginPage, "Login1$LoginLinkButton")
    _IEAction($oLogIn, "click")
    _IELoadWait($oLoginPage)


    Local $begin = ''
    Local $begin3 = ''
    Local $dif3 = 0
    Local $dif = 0

    While 2
        Sleep(10)
        $dif = Int(TimerDiff($begin) / 1000)
        If $dif >= (2 * 60) Then
            Gta()
            $begin = TimerInit()
        EndIf
    WEnd

EndFunc   ;==>myRun

Func Gta()
    $Gta = _IECreate($G1, 0, 0, 1, 0)
    _ieloadwait($gta)
    
    If WinExists("TMN - Local Prison - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Gta)
    EndIf
    If WinExists("Cannot find server - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Gta)
    EndIf
    If WinExists("TMN - Timer is on - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Gta)
    EndIf
    GtaCommit()
EndFunc   ;==>Gta

Func GtaCommit()
    $oRadio = _IEGetObjById($Gta, "ctl00_MainPageContent_rblCarThefts_5")
    _IEAction($oRadio, "click")
    $oSubmit = _IEGetObjByName($Gta, "ctl00$MainPageContent$btnCommit")
    _IEAction($oSubmit, "click")
    LogCheck()
EndFunc   ;==>GtaCommit

Func LogCheck()
    ;WinSetState("TMN - Steal a Car - Microsoft Internet Explorer", "", @SW_MAXIMIZE)

    If WinExists("tmnX - themafianetwork Xclusive Edition - Microsoft Internet Explorer") = 1 Then
        ALO()
        _IEQuit($Gta)
    EndIf

    If IsObj($Verify) = 1 Then
        Pop()
    EndIf


    If WinExists("TMN - Local Prison - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Gta)
    EndIf
    If WinExists("Cannot find server - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Gta)
    EndIf
    If WinExists("TMN - Timer is on - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Gta)
    EndIf
    Crimes()
EndFunc   ;==>LogCheck

Func Crimes()

    $Crimes = _IECreate($Cr1, 0, 0, 1, 0)
    _IELoadWait($crimes)
    If WinExists("TMN - Crimes - Microsoft Internet Explorer") = 0 Then
        _IEQuit($Crimes)
        CrimesCommit()
    EndIf
EndFunc   ;==>Crimes

Func CrimesCommit()
    $oRadio = _IEGetObjById($Crimes, "ctl00_MainPageContent_rblCrimes_8")
    _IEAction($oRadio, "click")
    $oSubmit = _IEGetObjByName($Crimes, "ctl00$MainPageContent$btnCommit")
    _IEAction($oSubmit, "click")
    LogCheck2()
EndFunc   ;==>CrimesCommit

Func LogCheck2()
    ;WinSetState("TMN - Crimes - Microsoft Internet Explorer", "", @SW_MAXIMIZE)
    If WinExists("tmnX - themafianetwork Xclusive Edition - Microsoft Internet Explorer") = 1 Then
        ALO2()
        _IEQuit($Crimes)
    EndIf

    If IsObj($oVerify) = 1 Then
        Pop2()
    EndIf

    If WinExists("Cannot find server - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Crimes)
    EndIf
    If WinExists("TMN - Timer is on - Microsoft Internet Explorer") = 1 Then
        _IEQuit($Crimes)
    EndIf
        Gta()
EndFunc   ;==>LogCheck2

Func Pop2()
    $Crimes = _IECreate($Cr1, 0, 1, 1, 0)
    _IELoadWait($crimes)
    If WinExists("TMN - Crimes - Microsoft Internet Explorer") = 0 Then
        _IEQuit($Crimes)
    EndIf
    
    $oRadio = _IEGetObjById($Crimes, "ctl00_MainPageContent_rblCrimes_8")
    _IEAction($oRadio, "click")
    $oSubmit = _IEGetObjByName($Crimes, "ctl00$MainPageContent$btnCommit")
    _IEAction($oSubmit, "click")

    WinSetState("TMN - Crimes - Microsoft Internet Explorer", "", @SW_MAXIMIZE)
    
    Do
        Sleep(3000)
    Until WinExists("TMN - Crimes - Microsoft Internet Explorer") = 0
    _IEQuit($Crimes)
    If WinExists("TMN - Crimes - Microsoft Internet Explorer") = 0 Then
        _IEQuit($Crimes)
        Gta()
    EndIf
    
EndFunc   ;==>Pop2

Func Pop()
    $Gta = _IECreate($G1, 0, 1, 1, 0)
    _IELoadWait($gta)
    If WinExists("TMN - Steal a Car - Microsoft Internet Explorer") = 0 Then
        _IEQuit($Gta)
    EndIf

    $oRadio = _IEGetObjById($Gta, "ctl00_MainPageContent_rblCarThefts_5")
    _IEAction($oRadio, "click")
    $oSubmit = _IEGetObjByName($Gta, "ctl00$MainPageContent$btnCommit")
    _IEAction($oSubmit, "click")

    WinSetState("TMN - Steal a Car - Microsoft Internet Explorer", "", @SW_MAXIMIZE)
    If WinExists("tmnX - themafianetwork Xclusive Edition - Microsoft Internet Explorer") = 1 Then
        ALO()
        _IEQuit($Gta)

    ElseIf WinExists("TMN - Steal a Car - Microsoft Internet Explorer") = 1 Then
        Sleep(3000)
    EndIf
    Do
        Sleep(3000)
    Until WinExists("TMN - Steal a Car - Microsoft Internet Explorer") = 0
    _IEQuit($GTA)
    If WinExists("TMN - Steal a Car - Microsoft Internet Explorer") = 0 Then
        _IEQuit($Gta)
        Crimes()
    Endif
EndFunc   ;==>Pop

Func Food()
    $Rest = _IECreate($url1 & "/Authenticated/restaurant.aspx", 0, 0, 1, 0)
    _IELoadWait($Rest)
    $oSubmit = _IEGetObjByName($Rest, "ctl00$MainPageContent$btnItem3")
    _IEAction($oSubmit, "click")
    _IELoadWait($Rest)
    _IEQuit($Rest)
    Gta()
EndFunc   ;==>Food

Func ALO()
    $oUser = _IEGetObjByName($Gta, "Login1$UserName")
    _IEFormElementSetValue($oUser, $name1)
    $oPass = _IEGetObjByName($Gta, "Login1$Password")
    _IEFormElementSetValue($oPass, $pass1)
    $oLogIn = _IEGetObjByName($Gta, "Login1$LoginLinkButton")
    _IEAction($oLogIn, "click")
    _IELoadWait($Gta)
    Food()
EndFunc   ;==>ALO

Func ALO2()
    $oUser = _IEGetObjByName($Crimes, "Login1$UserName")
    _IEFormElementSetValue($oUser, $name1)
    $oPass = _IEGetObjByName($Crimes, "Login1$Password")
    _IEFormElementSetValue($oPass, $pass1)
    $oLogIn = _IEGetObjByName($Crimes, "Login1$LoginLinkButton")
    _IEAction($oLogIn, "click")
    _IELoadWait($Crimes)
    Food()
EndFunc   ;==>ALO2

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Why the fuck are you pausing this shit? It rocks!!', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func _MinimizeToTray()
    If BitAND(WinGetState($Quick), 2) Then
        GUISetState(@SW_HIDE)
    Else
        GUISetState(@SW_SHOW)
    EndIf
EndFunc   ;==>_MinimizeToTray
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...