Jump to content

Confused... "If" etc


Recommended Posts

Heya! Yes, i'm back, with another question. :)

I'm creating a script (duh!) and i'm having alot of trouble figuring out If/EndIf/Then/Next etc :) If this is an easy part, please slap me as hard as you can.

I've made some of my script (Works fine), but I need an If entering in it. I need it to check if "[CLASSNN:TStaticText1]" has the Text "1", and if it does; Give a MsgBox and stop the bot. And if it isn't "1", then to send a few keys then repeat. Just helping me with the layout of this would be extremely appreciated

Now, i'm not asking for all the script to be written, but the fundementals of If/EndIf/Then/Next so I can be on my way to make more advanced scripts in the future.

Thank you ever so much if you take your time to help me!

Link to comment
Share on other sites

ok how it works is

you start out with an If statement and after you put your If you put a Then ---> If $x = 1 Then

now you can put an Else or ElseIf. Else is just if the If is not true.

ElseIf requires a second statement. for example ----------------------------------> ElseIf $x = 2 Then

you can use as many ElseIf's as you want.

when all of your ElseIf's are added, you end with a EndIf -------------------------> EndIf

so for example you could say

$x = random(1, 2, 1)
If $x = 1 Then 
MsgBox(0, "hi", "Autoit is cool and your result is " & $x)
ElseIf $x = 2 Then 
MsgBox(0, "hi", "AUTOIT F*CKING OWNS.  RESULT IS " & $x)
EndIf
Edited by Tomb616
Link to comment
Share on other sites

ok how it works is

you start out with an If statement and after you put your If you put a Then ---> If $x = 1 Then

now you can put an Else or ElseIf. Else is just if the If is not true.

ElseIf requires a second statement. for example ----------------------------------> ElseIf $x = 2 Then

you can use as many ElseIf's as you want.

when all of your ElseIf's are added, you end with a EndIf -------------------------> EndIf

so for example you could say

$x = random(1, 2, 1)
If $x = 1 Then 
MsgBox(0, "hi", "Autoit is cool and your result is " & $x)
ElseIf $x = 2 Then 
MsgBox(0, "hi", "AUTOIT F*CKING OWNS.  RESULT IS " & $x)
EndIf
Hey, I get it! That's awesome, thank yooooouuuu :)

Is there anyway to get the MsgBox to Display what text is in TStaticText2 & TStaticText3 also? What make an excellent addition.

Link to comment
Share on other sites

sure no problem

actually yes you can change MsgBox text

Local $ChangeText[4] = ['', 'Enable', 'Disable', 'Quit']
$iMsg = _MsgBoxEx(3, 'nothing', 'something', 0, $ChangeText)
MsgBox(64, 'Info', 'The Return Was: ' & $iMsg)

Func _MsgBoxEx($iFlag, $sTitle, $sText, $iTime = 0, $sCIDChange = '')
    Local $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTime & '"))'
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_SHOW, 6)
    Do
        Sleep(10)
    Until WinExists($sTitle)
    If IsArray($sCIDChange) Then
        For $iCC = 1 To UBound($sCIDChange) - 1
            ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC])
        Next
    Else
        ControlSetText($sTitle, '', 'Button1', $sCIDChange)
    EndIf
    While ProcessExists($iPID)
        Local $iStdOut = StdoutRead($iPID)
        If Number($iStdOut) Then Return $iStdOut
        Sleep(10)
    WEnd
    If IsArray($sCIDChange) Then Return SetError(1, 0, 2)
    Return SetError(1, 0, 1)
EndFunc
Link to comment
Share on other sites

sure no problem

actually yes you can change MsgBox text

Local $ChangeText[4] = ['', 'Enable', 'Disable', 'Quit']
$iMsg = _MsgBoxEx(3, 'nothing', 'something', 0, $ChangeText)
MsgBox(64, 'Info', 'The Return Was: ' & $iMsg)

Func _MsgBoxEx($iFlag, $sTitle, $sText, $iTime = 0, $sCIDChange = '')
    Local $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTime & '"))'
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_SHOW, 6)
    Do
        Sleep(10)
    Until WinExists($sTitle)
    If IsArray($sCIDChange) Then
        For $iCC = 1 To UBound($sCIDChange) - 1
            ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC])
        Next
    Else
        ControlSetText($sTitle, '', 'Button1', $sCIDChange)
    EndIf
    While ProcessExists($iPID)
        Local $iStdOut = StdoutRead($iPID)
        If Number($iStdOut) Then Return $iStdOut
        Sleep(10)
    WEnd
    If IsArray($sCIDChange) Then Return SetError(1, 0, 2)
    Return SetError(1, 0, 1)
EndFunc
Is there no other way? That's looks way out of my league. Lol :)
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...