Jump to content

Confusing Code


Recommended Posts

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
Link to comment
Share on other sites

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[[
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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.
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...