Jump to content

Need help with vb => Autoit


Recommended Posts

Okay I've tried the converter, and got errors. Also, I'm not 100% sure it'd work seeing how this isn't vbs.

Public Sub MoveMouseCC(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, _
                       ByVal range As Long, ByVal segments As Long, _
                       ByVal pcount As Long, ByVal delay As Long)
    Dim u As Double, nc1 As Double, nc2 As Double, nc3 As Double, nc4 As Double
    Dim dummyp As POINTAPI, p1() As POINTAPI, p2() As POINTAPI
    Dim r As RECT, i As Long
    ReDim p2(0)
    ReDim p1(pcount + 2)
    
    If segments < 15 Then segments = 50
    segments = segments + Rand(-12, 12)
    GetCursorPos dummyp
    GetWindowRect hwnd, r
    x = x + Rand(-range, range) + r.Left
    y = y + Rand(-range, range) + r.Top
    If pcount < 3 Then pcount = 3
    If (Abs(dummyp.x - x) + Abs(dummyp.y - y)) < 150 Then
        pcount = 3
        segments = 15
    End If
    
    For i = 0 To pcount + 2
        Select Case i
            Case Is < 2: p1(i) = dummyp
            Case Is >= pcount: p1(i).x = x: p1(i).y = y
            Case Else
                p1(i).x = Min(dummyp.x, x) + Rnd() * Abs(dummyp.x - x)
                p1(i).y = Min(dummyp.y, y) + Rnd() * Abs(dummyp.y - y)
        End Select
    Next i
    For i = 1 To pcount
        For u = 0 To 1 Step (1 / segments)
            nc1 = -(u ^ 3) / 6 + (u * u) / 2 - u / 2 + 1 / 6
            nc2 = (u ^ 3) / 2 - (u * u) + 2 / 3
            nc3 = (-(u ^ 3) + u * u + u) / 2 + 1 / 6
            nc4 = (u ^ 3) / 6
            dummyp.x = nc1 * p1(i - 1).x + nc2 * p1(i).x + nc3 * p1(i + 1).x + nc4 * p1(i + 2).x
            dummyp.y = nc1 * p1(i - 1).y + nc2 * p1(i).y + nc3 * p1(i + 1).y + nc4 * p1(i + 2).y
            ReDim Preserve p2(UBound(p2) + 1)
            p2(UBound(p2)) = dummyp
        Next u
    Next i
    For i = 0 To UBound(p2) - 1
        SetCursorPos p2(i).x, p2(i).y
        Wait (delay)
    Next i
End Sub

Private Function Min(ByVal val1 As Long, ByVal val2 As Long) As Long
    Min = val1
    If (val2 < val1) Then Min = val2
End Function

Private Function Rand(ByVal Low As Long, ByVal High As Long) As Long
    Randomize
    Rand = Int((High - Low + 1) * Rnd) + Low
End Function

Is what I'm trying to translate.

I started it, but I get lost since type pointapi holds 2 values.

Func MMove($mX = 0, $mY = 0, $range = 0, $seg = 0, $pcount = 0, $delay = 0)
    Local $dummyp, $i = 0, $p1($pcount + 2), $p2(0)
    If $seg < 15 Then $seg = 50
    $seg = $seg + Rand(-12, 12)
    $mX += Rand(-$range, $range)
    $mY += Rand(-$range, $range)
    $dummyp = MouseGetPos()
    If $pcount < 3 Then $pcount = 3
    If (Abs($dummyp[1] - $mX) + Abs($dummyp[2] - $mY)) < 150 Then
        $pcount = 3
        $seg = 15
    EndIf
    
    For $i = 0 to $pcount + 2
        Select
        Case $i < 2
            $p1[$i] = 
            
EndFunc

Func Rand($Low, $High)
    Local $retval
    $retval = Random($Low, $High, 1)
    Return $retval
EndFunc

How should I go upon doing this

/e

2d arrays is what I came too, man translating sucks..

Edited by igotandrew
Link to comment
Share on other sites

Here, I translated it...or tried too.

Func MMove($mX = 0, $mY = 0, $range = 0, $seg = 0, $pcount = 0)
    Local $dummyp, $i = 0, $p1[$pcount + 2][2], $p2[1][2], $u = 0
    Local $nc1, $nc2, $nc3, $nc4
    If $seg < 15 Then $seg = 50
    $seg = $seg + Rand(-12, 12)
    $mX += Rand(-$range, $range)
    $mY += Rand(-$range, $range)
    $dummyp = MouseGetPos()
    If $pcount < 3 Then $pcount = 3
    If (Abs($dummyp[0] - $mX) + Abs($dummyp[1] - $mY)) < 150 Then
        $pcount = 3
        $seg = 15
    EndIf
    
    For $i = 0 to $pcount + 2
        Select
        Case $i < 2
            $p1[$i][1] = $dummyp[0]
            $p1[$i][2] = $dummyp[1]
        Case $i >= $pcount
            $p1[$i][1] = $mX
            $p1[$i][2] = $mY
        Case Else
            $p1[$i][1] = Min($dummyp[0], $mX) + Random(1, Abs($dummyp[0] - $mX))
            $p1[$i][2] = Min($dummyp[1], $mY) + Random(1, Abs($dummyp[1] - $mY))
        EndSelect
    Next
    
    For $i = 1 to $pcount
        For $u = 0 to 1 Step (1 / $seg)
            $nc1 = -($u ^ 3) / 6 + ($u * $u) / 2 - $u / 2 + 1 / 6
            $nc2 = ($u ^ 3) / 2 - ($u * $u) + 2 / 3
            $nc3 = (-($u ^ 3) + $u * $u + $u) / 2 + 1 / 6
            $nc4 = ($u ^ 3) / 6
            $dummyp[0] = $nc1 * $p1[$i - 1][1] + $nc2 * $p1[$i][1] + $nc3 * $p1[$i +1][1] + $nc4 *$p1[$i +2][1]
            $dummyp[1] = $nc1 * $p1[$i - 1][2] + $nc2 * $p1[$i][2] + $nc3 * $p1[$i +1][2] + $nc4 *$p1[$i +2][2]
            ReDim $p2[UBound($p2) + 1]
            $p2[UBound($p2)][1] = $dummyp[0]
            $p2[UBound($p2)][1] = $dummyp[1]
        Next
    Next
    
    For $i = 0 to UBound($p2) - 1
        MouseMove($p2[$i][1], $p2[$i][2], 0)
        Sleep(Random(8, 15, 1))
    Next
EndFunc

However, I ran it and I got some errors

C:\Documents and Settings\Drew\My Documents\AutoIt\LSBOT\d2jsp LSB.au3 (108) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$p1[$i][2] = $dummyp[1]
^ ERROR

The parameter I gave it was

MMove(100, 100, 5, 50, 5)
Link to comment
Share on other sites

Here, I translated it...or tried too.

Func MMove($mX = 0, $mY = 0, $range = 0, $seg = 0, $pcount = 0)
    Local $dummyp, $i = 0, $p1[$pcount + 2][2], $p2[1][2], $u = 0
    Local $nc1, $nc2, $nc3, $nc4
    If $seg < 15 Then $seg = 50
    $seg = $seg + Rand(-12, 12)
    $mX += Rand(-$range, $range)
    $mY += Rand(-$range, $range)
    $dummyp = MouseGetPos()
    If $pcount < 3 Then $pcount = 3
    If (Abs($dummyp[0] - $mX) + Abs($dummyp[1] - $mY)) < 150 Then
        $pcount = 3
        $seg = 15
    EndIf
    
    For $i = 0 to $pcount + 2
        Select
        Case $i < 2
            $p1[$i][1] = $dummyp[0]
            $p1[$i][2] = $dummyp[1]
        Case $i >= $pcount
            $p1[$i][1] = $mX
            $p1[$i][2] = $mY
        Case Else
            $p1[$i][1] = Min($dummyp[0], $mX) + Random(1, Abs($dummyp[0] - $mX))
            $p1[$i][2] = Min($dummyp[1], $mY) + Random(1, Abs($dummyp[1] - $mY))
        EndSelect
    Next
    
    For $i = 1 to $pcount
        For $u = 0 to 1 Step (1 / $seg)
            $nc1 = -($u ^ 3) / 6 + ($u * $u) / 2 - $u / 2 + 1 / 6
            $nc2 = ($u ^ 3) / 2 - ($u * $u) + 2 / 3
            $nc3 = (-($u ^ 3) + $u * $u + $u) / 2 + 1 / 6
            $nc4 = ($u ^ 3) / 6
            $dummyp[0] = $nc1 * $p1[$i - 1][1] + $nc2 * $p1[$i][1] + $nc3 * $p1[$i +1][1] + $nc4 *$p1[$i +2][1]
            $dummyp[1] = $nc1 * $p1[$i - 1][2] + $nc2 * $p1[$i][2] + $nc3 * $p1[$i +1][2] + $nc4 *$p1[$i +2][2]
            ReDim $p2[UBound($p2) + 1]
            $p2[UBound($p2)][1] = $dummyp[0]
            $p2[UBound($p2)][1] = $dummyp[1]
        Next
    Next
    
    For $i = 0 to UBound($p2) - 1
        MouseMove($p2[$i][1], $p2[$i][2], 0)
        Sleep(Random(8, 15, 1))
    Next
EndFunc

However, I ran it and I got some errors

C:\Documents and Settings\Drew\My Documents\AutoIt\LSBOT\d2jsp LSB.au3 (108) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$p1[$i][2] = $dummyp[1]
^ ERROR

The parameter I gave it was

MMove(100, 100, 5, 50, 5)
Im a newb at coding but I think I know your problem...

you declare your variables/arrays using the line below:

Local $dummyp, $i = 0, $p1[$pcount + 2][2], $p2[1][2], $u = 0

You assigned the array $p1[$pcount+2][2] which makes it an array with size 2

Then your code that is erroring out:

$p1[$i][2] = $dummyp[1]

tries to assign the value $dummyp[1] to the array $p1[$i][2] which would be the third value in the array, as the array $p1[$i][0] is first and $p1[$i][1] is second.

I think to fix your problem you should change the following code:

Case $i < 2
            $p1[$i][1] = $dummyp[0]
            $p1[$i][2] = $dummyp[1]

to:

Case $i < 2
            $p1[$i][0] = $dummyp[0]
            $p1[$i][1] = $dummyp[1]

Now, as I said I am a novice so if this is not right I appologize, just trying to help.

P.S. I think your going to run into even more errors after you fix that particular code, because at the beginning of your code you when you declared your array, you used $p1[$pcount + 2][2] at which time $pcount was = 0, so you basically created the array $p1[2][2], yet in your code, after your current error, you have the following code:

Case $i >= $pcount
            $p1[$i][1] = $mX
            $p1[$i][2] = $mY

which means $i will be greater than 2 minimum, which is more dimensions than you declared.

Now I am not sure if you have to be strict on your declarations or if you can declare simply by assignation, so this may not be your problem at all. Hope it helped.

Link to comment
Share on other sites

How do you think I should go upon re-sizing the 2d array then?

I'm pretty sure I translated it accurately, but there are few conversion problems with arrays I haven't been able to do, and you're looking at them.

I fixed the [1] [2] to [0] [1], but I really thought that [2] is that max it can contain, so [1] and [2] being the 2 values an array held.

Anyways, thanks for the input I appreciate it, and you're right I still have errors from sizing errors..

Link to comment
Share on other sites

One more question, why are you doing this?

This is essentially a function in VB to move your mouse and perform clicks, but autoit has all those functions built in, why would you want to convert that function to autoit code to accomplish something that mousemove() and mouseclick() will do?

Also, and I am not sure about this, but cant you include a VB file into your au3 script instead of rewriting it in au3? Not sure on this, I know you can call dll's, so you SHOULD be able to simply include a VB Module I would assume, then you can just call that function.

Link to comment
Share on other sites

2nd question: I think your thinking about autoitX

1st question: I haven't really quite thought it through, I was thinking that it wouldn't produce the same results as MoveMouseCC, and caught up with the insta-mouse move I didn't think it was up to the job.

/e

after testing this..

I don't think it's humanely possible to move a mouse straight down which mousemove does, versus mousemovecc

but I guess mousemovecc doesn't do it either...

hm..

Edited by igotandrew
Link to comment
Share on other sites

How do you think I should go upon re-sizing the 2d array then?

I'm pretty sure I translated it accurately, but there are few conversion problems with arrays I haven't been able to do, and you're looking at them.

I fixed the [1] [2] to [0] [1], but I really thought that [2] is that max it can contain, so [1] and [2] being the 2 values an array held.

Anyways, thanks for the input I appreciate it, and you're right I still have errors from sizing errors..

An array can hold as many values as you declare it, and have as many dimensions as you declare it, I am sure there is a limit, but I bet it is immense.

For instance Local $Array[100][1000][10000] is immense and I bet is ok within autoit's specifications.

[1] and [2] are two values, but most languages utilize the 0 as the first and 1 is the second. Now if you declared it as a [3] then [1] and [2] would both be good, as there are three separate values declared. [0], [1] & [2], see what I mean?

Link to comment
Share on other sites

2nd question: I think your thinking about autoitX

1st question: I haven't really quite thought it through, I was thinking that it wouldn't produce the same results as MoveMouseCC, and caught up with the insta-mouse move I didn't think it was up to the job.

/e

after testing this..

I don't think it's humanely possible to move a mouse straight down which mousemove does, versus mousemovecc

but I guess mousemovecc doesn't do it either...

hm..

no idea what autoitX is hehe, but if I understand you correctly you are trying to immitate human error in moving the mouse from one point to another, rather than an exact straight line? What game are you trying to automate hehe?

Just an FYI, no online game would actually monitor your mouse location on every move server side, and I never heard of one tracking it for suspicious activity. I have hacked/botted just about every game I have played at one time or another, and this shouldnt concern you. After thought I figured you were trying to bypass gameguard or somehting like that making the mouse movements a hardware thing rather than a software thing which game guard detects.

also, FYI you can build a mouse move function that would be easier and smaller than the one you have, which would throw in random numbers inside a certain threshhold, to vary the movement of your mouse, for instance make the threshhold 5, so everytime it moved the mouse you could vary it by 5 pixels, and then go from that location to the target location, making it NOT a straight line :).

Link to comment
Share on other sites

Games like runescape can easily detect mouse movement jumping ... 0,0 to like 400,300 in a matter of ms.

It's a flash game, with simple mechanics. After talking with you, I have revised my code ..

Func MClick($Coor, $Type = "Left", $Click = 1)
    Local $z, $i = 1
    $z = StringSplit($Coor, ", ", 1)
    MouseMove($z[1] + Random(-$R_Offset, $R_Offset, 1), $z[2] + Random(-$R_Offset, $R_Offset, 1), Random($R_MoveMin, $R_MoveMax, 1))
    For $i = 1 to $Click
    MouseDown("Left")
    Sleep(Random($D_ClickMin, $D_ClickMax, 1))
    MouseUp("Left")
    Sleep(Random($D_ClickMin, $D_ClickMax, 1))
    Next
EndFunc

However, i'll post if I have any other problems.

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