Making Mouse go down work within games

Posts 17 of 7 · Page 1 of 1
Making Mouse go down work within games
Currently i have a macro that is (almost) released Here and i'm adding a new function to help control recoil, everytime it calls the function mouse() which pushes down then releases the Lbutton. Then it will move the mouse down however many pixels you set in the form box i provide. It worked great until i went in-game and the macro worked but it did not move the gun down at all. Here is the code i'm using so far

Code:
    Private Sub MoveCursor()
        ' Set the Current cursor, move the cursor's Position, 

        Me.Cursor = New Cursor(Cursor.Current.Handle)
        Cursor.Position = New Point(Cursor.Position.X - TextBox4.Text, Cursor.Position.Y - TextBox5.Text)
    End Sub
Overall i want it to move the gun down the set amount of pixels defined in the box. Any ideas?

**NOTE** I have never coded in VB before but i have experience in C# so i should be able to figure stuff out :3
Cursor.Position won't work in game, you need to use a Windows API such as mouse_event or SendInput.

Code:
Declare Function mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean
    Private Const MOUSEEVENTF_MOVE As Integer = &H1
    Private Sub MoveCursor()
        ' Set the Current cursor, move the cursor's Position, 
        mouse_event(MOUSEEVENTF_MOVE, -(Integer.Parse(TextBox4.Text)), -(Integer.Parse(TextBox5.Text)), 0, 0)
    End Sub
Hopefully that works, I haven't tested it. Also, use a NumericUpDown control instead of a text box. If someone types a letter into the box the whole thing will crash.
Quote Originally Posted by master131 View Post
Cursor.Position won't work in game, you need to use a Windows API such as mouse_event or SendInput.

Code:
Declare Function mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean
    Private Const MOUSEEVENTF_MOVE As Integer = &H1
    Private Sub MoveCursor()
        ' Set the Current cursor, move the cursor's Position, 
        mouse_event(MOUSEEVENTF_MOVE, -(Integer.Parse(TextBox4.Text)), -(Integer.Parse(TextBox5.Text)), 0, 0)
    End Sub
Hopefully that works, I haven't tested it. Also, use a NumericUpDown control instead of a text box. If someone types a letter into the box the whole thing will crash.
Ohhh your amazing i'll test this out ASAP and tel lyou if it works but that makes complete sense :3

I have it set up however i get this error and, sicne i do not know VB very well i have no idea how to handle it

Code:
Error	15	
'Declare Ansi Sub mouse_event Lib "user32" Alias "mouse_event" (dwFlags As Integer, dx As Integer, dy As Integer, cButtons As Integer, dwExtraInfo As Integer)' and 'Declare Ansi Function mouse_event Lib "user32.dll" Alias "mouse_event" (dwFlags As Integer, dX As Integer, dY As Integer, cButtons As Integer, dwExtraInfo As Integer) As Boolean' cannot overload each other because they differ only by return types.	C:\Users\Jon\Desktop\AVA fast gun\Form1.vb	9	24	AVA fast gun
Nvm i think i figured it out, i had it already defined xD

IT WORKS D. You sir are awesome. Thanks and +rep for the great help
EDIT - I just edited my post, it works. :3

Delete the one I posted (Declare Function mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean) you can just use the one you already had.
Quote Originally Posted by master131 View Post
EDIT - I just edited my post, it works. :3

Delete the one I posted (Declare Function mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean) you can just use the one you already had.
Are you able to approve my attachments in my release in the AVA section? I would really appreciate it as its been idle for almost 2 days without such as a glimpse from someone who can approve it (that i know of)
Quote Originally Posted by master131 View Post
Nope, got no power there.
Rawrr, thanks anyway. Can you nudge someone who does have power to approve it i have all the required criteria to pass it ^.^
Posts 17 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?