Jump to content

Help with variables


YaBoy
 Share

Recommended Posts

This is what I have so far:

$Test = 0

If StringInStr(WinGetText("Program", ""), "Text") Then $Test = 1



[SOME CODE HERE.. A BUNCH]


If $Test = 1 Then

[CODE HERE]

EndIf

Should it work if it reads the word 'Text' then it should go down to the code If the $Test = 1?

What am I doing wrong?

It compiles, but it doesnt go down to the "If $Test = 1 Then [code HERE]"

Link to comment
Share on other sites

  • Moderators

How do I test it with the window tool? Whats that do to help me know why its not working.. it compiles though.

There's always the Pre-Test before you actually include the code (You did test it first right?).

MsgBox(64, 'Info', StringInStr(WinGetText("Program", ""), "Text"))
If the message box shows anything greater than 0 it was found.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yeah I already did that test, It showed all the text. But Its not going all the way down to the variable.. I have to place the variable and the code underneath the variabl under the.. let me show you

$Test = 0
$Test2 = 0
$Test3 = 0

If StringInStr(WinGetText("Program", ""), "Text") Then $Test = 1

[SOME CODE HERE.. A BUNCH]

If $Test2 = 0 Then

[CODE HERE]

EndIf

If $Test3 = 0 Then

[CODE HERE]


If $Test = 1 Then

[CODE HERE]

EndIf

I tried putting $Test1 at the top and it will only work if its underneath the "

If StringInStr(WinGetText("Program", ""), "Text") Then $Test = 1"

BUT if its not, It will just do the next thing underneath.

BUT if I put $test1 first then $test 2 AND IF it doesnt read 'Text' It will skip $Test1 and go to the next, in this case, $Test2.

Hope it wasnt too complicated, but anyone can help?

Link to comment
Share on other sites

  • Moderators

Yeah I already did that test, It showed all the text. But Its not going all the way down to the variable.. I have to place the variable and the code underneath the variabl under the.. let me show you

$Test = 0
$Test2 = 0
$Test3 = 0

If StringInStr(WinGetText("Program", ""), "Text") Then $Test = 1

[SOME CODE HERE.. A BUNCH]

If $Test2 = 0 Then

[CODE HERE]

EndIf

If $Test3 = 0 Then

[CODE HERE]
If $Test = 1 Then

[CODE HERE]

EndIf

I tried putting $Test1 at the top and it will only work if its underneath the "

If StringInStr(WinGetText("Program", ""), "Text") Then $Test = 1"

BUT if its not, It will just do the next thing underneath.

BUT if I put $test1 first then $test 2 AND IF it doesnt read 'Text' It will skip $Test1 and go to the next, in this case, $Test2.

Hope it wasnt too complicated, but anyone can help?

Try providing a working example, your pseudo code isn't doing it for me. And your answer will be much quicker.

Edit:

P.S. - My example doesn't return the text of the window, it returns a number. If it was found, it will show you how many chars it went through to find it.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

$loop = 0
$another = 0
$walkedright = 0
$walkedUp = 0
$walkedLeft = 0
;$End = StringInStr(WinGetText("Program", ""), "Text1")
$Tp = 0
$Start = 0



    

Do
    Do
    
    
    MouseMove( 240, 151, .2 )
    MouseClick("Left", 240,151, 1)
    MouseMove( 189, 61, .2 )
    MouseClick("Left", 189, 61, 1) 
    
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() = 0
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() = 0    



;If StringInStr(WinGetText("Program", ""), "Test2") Then

If StringInStr(WinGetText("Program", ""), "Test2") Then $Start = 1
    
            
            
    
        
    If $Start = 1 Then
        
        MouseMove(582, 356, .2)
        MouseClick("left", 582, 356, 1) 
        
        MouseMove(58, 119, .2)
        MouseClick("right", 62,115, 1) 
        
        MouseClick("left", 233, 201) 
        
        
        
                    
                Do
                MouseClick("left", 613, 10)
                Do
                Sleep( 100 )
                Until MouseGetCursor() = 15
                Do
                Sleep( 100 )
                Until MouseGetCursor() <> 15
                $walkedLeft = $walkedLeft + 1
                
            Until $walkedLeft = 5
            
                    
                Do
                MouseClick("left", 6, 271)
                Do
                Sleep( 100 )
                Until MouseGetCursor() = 15
                Do
                Sleep( 100 )
                Until MouseGetCursor() <> 15
                $walkedUp = $walkedUp + 1
                
            Until $walkedUp = 7
            
    
        Do
        
        MouseMove(64, 176, .2) 
        MouseClick("left",64, 176)
        
        MouseMove(190, 60, .2)      
        MouseClick("left", 190, 60, 1) 
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 15
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 0
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 15
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 0  
        
        

        MouseMove(423, 232, .2)
        MouseClick("left", 414, 218, 1) 
        
        MouseMove(124, 109, .2)
        MouseClick("left", 124, 109, 1) 
        
        
    

        
    
        Do
        
        MouseMove( 193, 61, .2 )
        MouseClick("left", 193, 61, 1)     
    
        
        
        MouseClick("left", 572, 65)         
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 15
        Do
        Sleep( 100 )
        Until MouseGetCursor() <> 15     
        MouseClick("left", 331, 19)
        
        MouseMove(196, 59, .2)
        MouseClick("left", 196, 59, 1)
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 15
        Do
        Sleep( 100 )
        Until MouseGetCursor() <> 15
    Until $End = 1
    If $End = 1 Then $Tp = 1 
    EndIf


If StringInStr(WinGetText("Program", ""), "Test1") Then $Tp = 1


;If $End = 1 Then $tp = 1 

        
;Else


If $Tp = 0 Then
MouseClick("right", 359, 267) 
Sleep(1200)
MouseMove(582, 356, .2)
MouseClick("left", 582, 356, 1)

MouseMove(82,63, .2)
MouseClick("right", 82,63, 1)
MouseMove(358, 253, .2)
MouseClick("left", 358, 253, 1)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15
MouseMove(582, 356, .2)
MouseClick("left", 582, 356, 1)

MouseMove(81,81, .2)
MouseClick("right", 81,81, 1)
MouseMove(358, 253, .2)
MouseClick("left", 358, 253, 1)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15



MouseMove( 512, 165, .2 )  
MouseClick("Left",512, 165, 1) 

MouseMove( 129, 115, .2 ) 
MouseClick("Left",129, 115, 1)   

$loop = $loop + 1
$another = $another + 1






Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15     


MouseClick("left", 331, 19)

MouseMove(196, 59, .2)
MouseClick("left", 196, 59, 1)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15
;EndIf
EndIf

 Until $loop = 25  




If $Tp = 1 Then

MouseMove(582, 356, .2)
MouseClick("left", 582, 356, 1) 

MouseMove(58, 119, .2)
MouseClick("right", 62,115, 1) 

MouseClick("left", 268, 107)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15


MouseClick("left", 528, 283)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15

MouseClick("left", 413, 284)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15

MouseClick("left",629, 253)
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15

MouseClick("left", 348, 45)

MouseClick("left", 213, 62) 
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15
MouseClick("left", 473, 174) 

MouseClick("left", 55, 36) 
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15
MouseClick("left", 417, 254) 

MouseClick("left", 73, 58)

MouseClick("left", 202, 62) 
$walkedright = $walkedright + 1
Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15
    
    Do
        
        MouseClick("left", 625, 267)
        Do
        Sleep( 100 )
        Until MouseGetCursor() = 15
        Do
        Sleep( 100 )
        Until MouseGetCursor() <> 15
        $walkedright = $walkedright + 1
        
        
    Until $walkedright = 11




MouseClick("left", 462, 429) 

MouseClick("left", 59, 31)
MouseClick("left", 286, 284)
Send("{LWINDOWN}{LWINUP}")
WinWait("Start Menu","")
If Not WinActive("Start Menu","") Then WinActivate("Start Menu","")
WinWaitActive("Start Menu","")
MouseClick("left", 30, 212)


Do
Sleep( 100 )
Until MouseGetCursor() = 5
Do
Sleep( 100 )
Until MouseGetCursor() <> 15


MouseClick("left", 565, 401) 
EndIf
    
Until $another = 999






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;


MouseClick ("left", 6, 271)

Do
Sleep( 100 )
Until MouseGetCursor() = 15
Do
Sleep( 100 )
Until MouseGetCursor() <> 15






Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

I want it so if $Start = 1 then it goes to $Start no matter where the code is at. Same with everything.. no matter where the code is at

Edited by YaBoy
Link to comment
Share on other sites

So for an example when it comes to this:

Until $End = 1
    If $End = 1 Then $Tp = 1
    EndIf


If StringInStr(WinGetText("Program", ""), "Test1") Then $Tp = 1


;If $End = 1 Then $tp = 1

        
;Else


If $Tp = 0 Then
[CODE HERE BLAH BLAH]

It doesnt go there.. it actually goes back to here:

Do
    Do
    
    
    MouseMove( 240, 151, .2 )
    MouseClick("Left", 240,151, 1)

    MouseMove( 189, 61, .2 )
    MouseClick("Left", 189, 61, 1)
Edited by YaBoy
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...