Sign in to follow this  
Followers 0
SofaKingWeTardEd

Confused... "If" etc

11 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

a way to change message box text?

or something else?

Share this post


Link to post
Share on other sites

a way to change message box text?

or something else?

ControlGetText I was/am using. The Text inside TStaticTextX I would like displayed inside the MsgBox? :/

Share this post


Link to post
Share on other sites

Nevermind! I found out by trail and error!

Thank you Tomb for your help. Hugely appreciated! :)

Share this post


Link to post
Share on other sites

sure no problem

now im curious, how did you do it.

Share this post


Link to post
Share on other sites

sure no problem

now im curious, how did you do it.

Kinda like:

$x = ControlGetText ("Window","","[CLASSNN:TStaticTextX]")
MsgBox (46,"Window Name","X=" & $x,0)

Share this post


Link to post
Share on other sites

A tip when you're looking for help is to post the actuall code you have, it will be alot easier to understand what you're having problems with. :)

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
Sign in to follow this  
Followers 0