Jump to content

GLobal If Command


J0ker
 Share

Recommended Posts

Try this change

$pos = MouseGetPos()

Func ScriptStuck()
    $var_2 = MouseGetPos()
    If IsArray($var_2) And IsArray($pos) Then
        If $Timestack = 10 Then
            $Timestack = 0
            Start()
        ElseIf $pos[0] = $var_2[0] And $pos[1] = $var_2[1] Then
            $Timestack += 1
        Else
            $pos = $var_2
        EndIf
    EndIf
EndFunc

:P

Link to comment
Share on other sites

You need to declare $pos before the function is called. Add it at the top of your script as

Global $pos, $Timestack

; other code

$pos = MouseGetPos()

Func ScriptStuck()
    Local $var_2 = MouseGetPos()
    If IsArray($var_2) And IsArray($pos) Then
        If $Timestack = 10 Then
            $Timestack = 0
            Start()
        ElseIf $pos[0] = $var_2[0] And $pos[1] = $var_2[1] Then
            $Timestack += 1
        Else
            $pos = $var_2
        EndIf
    EndIf
EndFunc
Link to comment
Share on other sites

I dont get any errors now but it's not working. $TimeStack are not stacking value. I tried to put a splash text to see if $TimeStack was changing and it's not.

SplashTextOn ("", "Time Stack: " & $TimeStack, 290, 20, 0, 30, 1, "", 10)

With my other code values were stacking but I cannot get the else to work :S

Link to comment
Share on other sites

Depends how you have your script set up.

With this test

Global $pos, $Timestack

AdlibEnable('ScriptStuck', 500)

While 1
    $pos = MouseGetPos()
    Sleep(500)
WEnd

Func ScriptStuck()
    Local $var_2 = MouseGetPos()
    If IsArray($var_2) And IsArray($pos) Then
        If $Timestack = 10 Then
            ConsoleWrite('If' & @CRLF)
            $Timestack = 0
;~          Start()
        ElseIf $pos[0] = $var_2[0] And $pos[1] = $var_2[1] Then
            ConsoleWrite('ElseIf' & @CRLF)
            $Timestack += 1
        Else
            ConsoleWrite('Else' & @CRLF)
            $pos = $var_2
        EndIf
    EndIf
EndFunc

CODE

Else

Else

ElseIf

Else

Else

ElseIf

Else

Else

Else

ElseIf

ElseIf

Else

Else

ElseIf

Else

ElseIf

ElseIf

ElseIf

ElseIf

ElseIf

If

ElseIf

ElseIf

ElseIf

Else

Else

Else

Else

ElseIf

ElseIf

ElseIf

I get If, ElseIf and Else showing as being used.
Link to comment
Share on other sites

Global $pos, $Timestack

AdlibEnable('ScriptStuck', 500)

While 1
    $pos = MouseGetPos()
    Sleep(500)
WEnd

Func ScriptStuck()

SplashTextOn ("", "Time Stack: " & $TimeStack ,290, 20, 0, 30, 1, "", 10)
    Local $var_2 = MouseGetPos()
    If IsArray($var_2) And IsArray($pos) Then
        If $Timestack = 10 Then
            ConsoleWrite('If' & @CRLF)
            $Timestack = 0
            Exit
        ElseIf $pos[0] = $var_2[0] And $pos[1] = $var_2[1] Then
            ConsoleWrite('ElseIf' & @CRLF)
            $Timestack += 1
        Else
            ConsoleWrite('Else' & @CRLF)
            $pos = $var_2
            $Timestack = 0
        EndIf
    EndIf
EndFunc

The splashtext always display 0, and the Exit never happen. It's like if no values were stacking.

EDIT: If I run it in alone, it work, but If I add it to my real script, nothing happen. So this code work but I will see if I can get it to work in my script.

EDIT2:

Alone : The ConsoleWrite work

In my script: He write nothing in the console

Edited by J0ker
Link to comment
Share on other sites

Func ScriptStuck()
SplashTextOn ("", "Time Stack: " & $TimeStack ,290, 20, 0, 30, 1, "", 10)
    Local $var_2 = MouseGetPos()
    ConsoleWrite('Test' & @CRLF)
    If IsArray($var_2) And IsArray($pos) Then
        If $Timestack = 10 Then
            ConsoleWrite('If' & @CRLF)
            $Timestack = 0
            Exit
        ElseIf $pos[0] = $var_2[0] And $pos[1] = $var_2[1] Then
            ConsoleWrite('ElseIf' & @CRLF)
            $Timestack += 1
        Else
            ConsoleWrite('Else' & @CRLF)
            $pos = $var_2
            $Timestack = 0
        EndIf
    EndIf
ConsoleWrite('ENDFUNC' & @CRLF)
EndFunc

# CONSOLEWRITE #

Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC
Test
ENDFUNC

The script reach the If and then exit the function :P.

Link to comment
Share on other sites

The splashtext always display 0, and the Exit never happen. It's like if no values were stacking.

Upon executing your code, if I do not move the mouse the the splash increases the count and finally exits. In your real script, $pos does need to be updated for the function to react to those mouse coordinate changes.
Link to comment
Share on other sites

I'm knew to programming in general, only made 2 programs (although they were no small feet, one was 15 hours of work the other about 5) and there are a few things in that script I don't understand the point of.

AdlibEnable("ScriptStuck", 6000)
Func ScriptStuck()
$pos = MouseGetPos()   ;why is this $pos
$var_2 = MouseGetPos()  ;but this $var_2. why not make this simply $pos2 ?
if $pos[0] = $var_2[0] AND $pos[1] = $var_2[1] then    ;and whats up with the [1] and [0]'s??
oÝ÷ Ø    ݶ§Â+a¢ëm槳«¶a¢Çª¹ë-ìZ¥vØb³
+«­¢+Ø(í±°Ñ¡Ñ¡¥¹Ìɸ½¹°¥¹±Õ¥¹¸¸¸(ÀÌØíÑ¥µÍѬôÀ()Õ¹MÉ¥ÁÑMÑÕ¬ ¤(ÀÌØíÁ½ÌÄõ5½ÕÍÑA½Ì ¤)ͱÀ ØÀÀÀ¤(ÀÌØíÁ½ÌÈõ5½ÕÍÑA½Ì ¤)%ÀÌØíÁ½ÌÄõÁ½ÌÈÑ¡¸ÀÌØíÑ¥µÍѬ¬ôÄ)%ÀÌØíÑ¥µÍѬôÈÀÑ¡¸±°¡µ¥¸¤)¹Õ¹()Õ¹µ¥¸ ¤)±¥¹± ÅÕ½ÐíMÉ¥ÁÑMÑÕ¬ÅÕ½Ðì°ØÀÀÀ¤(í¹Ñ¥ÉÁɽɴ)±¥¹¥Í± ¤)¹Õ¹

Makes sense to me...

Edited by kindlin
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...