Jump to content
Sign in to follow this  
FinalVersion

Confusing Code

Recommended Posts

FinalVersion

I can't get my head around to whats wrong, help is defiantly appreciated.

Ver()

Func Hoz()
    $x = 1
    $x = $x + 1
    Do
        $jpos = MouseGetPos()
        MouseMove($JPos[0] + 17, 45, 0)
        Sleep(100)
        Ver()
    Until $x = 3
EndFunc     ;==>Hoz

Func Ver()
    $i = 1
    Do
        $Pos = MouseGetPos()
        MouseMove($Pos[0], $Pos[1] + 10, 0)
        Sleep(100)
        $i = $i +1
    Until $i = 15
    Hoz()
EndFunc

Share this post


Link to post
Share on other sites
BrettF
Yashied

I can't get my head around to whats wrong, help is defiantly appreciated.

Ver()

Func Hoz()
    $x = 1
    $x = $x + 1
    Do
        $jpos = MouseGetPos()
        MouseMove($JPos[0] + 17, 45, 0)
        Sleep(100)
        Ver()
    Until $x = 3
EndFunc     ;==>Hoz

Func Ver()
    $i = 1
    Do
        $Pos = MouseGetPos()
        MouseMove($Pos[0], $Pos[1] + 10, 0)
        Sleep(100)
        $i = $i +1
    Until $i = 15
    Hoz()
EndFuncoÝ÷ Ûú®¢×ºÚ"µÍ
B[ÈÞ
B   ÌÍÞHB  ÌÍÚÜÈH[ÝÙQÙ]ÜÊ
B[ÝÙS[ÝJ ÌÍÒÜÖÌH
ÈMË

K
BÛY
L
B
BBIÌÍÞH  ÌÍÞ
ÈB[[   ÌÍÞHÂ[[ÈÏOIÝÒÞ[È
B   ÌÍÚHHBÂ ÌÍÔÜÈH[ÝÙQÙ]ÜÊ
B[ÝÙS[ÝJ ÌÍÔÜÖÌK   ÌÍÔÜÖÌWH
ÈL
BÛY
L
B   ÌÍÚHH    ÌÍÚH
ÌB[[   ÌÍÚHHMBÞ
B[[

Share this post


Link to post
Share on other sites
BrettF
Yashied
Qousio

How So..?

I think it doesn't increase because you have made a weird recursion. Your Do-Until loop should work until $X is 3. But $X doesn't increase inside the loop, the second function starts the first function, but the first function is still running! Thus you get an awkward recursion that causes problems.

Ver()

Func Hoz()
    $x = 1
    $x = $x + 1
    Do
        $jpos = MouseGetPos()
        MouseMove($JPos[0] + 17, 45, 0)
        Sleep(100)
        Ver()
    Until $x = 3
EndFunc;==>Hoz

Func Ver()
    $i = 1
    Do
        $Pos = MouseGetPos()
        MouseMove($Pos[0], $Pos[1] + 10, 0)
        Sleep(100)
        $i = $i +1
    Until $i = 15
EndFunc

MsgBox( 0, "", "Everything works!" )

This works =P

Or if Increasing $x is what you also need

Ver()

Func Hoz()
    $x = 1
    Do
$x +=1
        $jpos = MouseGetPos()
        MouseMove($JPos[0] + 17, 45, 0)
        Sleep(100)
        Ver()
    Until $x = 3
EndFunc;==>Hoz

Func Ver()
    $i = 1
    Do
        $Pos = MouseGetPos()
        MouseMove($Pos[0], $Pos[1] + 10, 0)
        Sleep(100)
        $i = $i +1
    Until $i = 15
EndFunc

MsgBox( 0, "", "Everything works!" )
Edited by Qousio

Share this post


Link to post
Share on other sites
AlmarM

Is this what your trying to do?

Ver()

Func Hoz()
    $x = 1
    Do
        $jpos = MouseGetPos()
        MouseMove($JPos[0] + 17, 45, 0)
        Sleep(100)
        $x += 1
    Until $x = 3
    Ver()
EndFunc  ;==>Hoz

Func Ver()
    $i = 1
    Do
        $Pos = MouseGetPos()
        MouseMove($Pos[0], $Pos[1] + 10, 0)
        Sleep(100)
        $i += 1
    Until $i = 15
    Hoz()
EndFunc

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
BrettF
Qousio

What happened to the wonderful For...Next loop over Do...Until $var = x... :)

Its alive!!

For(x=1; x<100; x++) {

}

Share this post


Link to post
Share on other sites
FinalVersion

Ok I'll explain what i want.

$Downs = InputBox("Downs", "Move Down How Many Times?")
$Rights = InputBox("Rights", "Move Right How Many Times?")

Just say the user enters 5 for downs & 4 for rights.

The mouse would move down +10 from it current location however many downs. Then it would move to the original location but to the right + 15, then do that over until rights has reached what the user entered.

Share this post


Link to post
Share on other sites
Qousio

Ok I'll explain what i want.

$Downs = InputBox("Downs", "Move Down How Many Times?")
$Rights = InputBox("Rights", "Move Right How Many Times?")

Just say the user enters 5 for downs & 4 for rights.

The mouse would move down +10 from it current location however many downs. Then it would move to the original location but to the right + 15, then do that over until rights has reached what the user entered.

$Downs = 5
$Rights = 4
$Pos = MouseGetPos()
For $i=0 to $Downs
    MouseMove( $Pos[0], $Pos[1]+$i*10 )
Next
For $i=0 to $Rights
    MouseMove( $Pos[0]+$i*15, $Pos[1] )
    Next

#Edit: Fixed it... @_@

#Edit2: Mad at the edit system, chopped off part of my code!

Edited by Qousio

Share this post


Link to post
Share on other sites
BrettF

Like this?

$max_x = 5
$max_y = 5

$original_pos = MouseGetPos()

For $i = 1 to $max_y
    $j = MouseGetPos ()
    MouseMove($j[0], $j[1] + 10)
Next

MouseMove ($original_pos[0], $original_pos[1])
For $i = 1 to $max_y
    $j = MouseGetPos ()
    MouseMove($j[0] + 17, 45)
Next

Share this post


Link to post
Share on other sites
Qousio

Thanks, But it doesn't work :)

Look above, I fixed it... I'm still new to Autoit syntax and often try something similair to C++ which doesnt work =P

Share this post


Link to post
Share on other sites
Qousio

@BrettF

Kind Of.

Better Explain It Better :)

I want it to go down squares in minesweeper then when it reaches the bottom defined by the user, it goes to the next column.

$Downs = 5
$Rights = 4
$Pos = MouseGetPos()
For $i=0 to $Downs
    MouseMove( $Pos[0], $Pos[1]+$i*10 )
Next
$Pos = MouseGetPos()
For $i=0 to $Rights
    MouseMove( $Pos[0]+$i*15, $Pos[1] )
    Next

Share this post


Link to post
Share on other sites
FinalVersion

Look above, I fixed it... I'm still new to Autoit syntax and often try something similair to C++ which doesnt work =P

Yours works, except i want it to stop @ each down, then do the next down. After all downs down it moves across a right then does the downs again, etc.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.