Results 1 to 8 of 8
  1. #1
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored

    Holding down Middle Mouse Buttion for Combat Arms

    So, this makes no sense to me. I'm using this code to hold down the middle mouse button ingame (to hold down voice chat) and it only works when it says (this team wins, like Alpha Team Wins! or Bravo Team Wins!).

    Code:
    Public Class Form1
    
        Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vbkey As Int16) As Int32
        Dim onoff As Boolean = False
        Const MButton As Byte = &H4 'Middle Mouse Button
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim endbutton As Boolean
            endbutton = GetAsyncKeyState(Keys.End)
    
            If endbutton = True Then
                If onoff = False Then
                    onoff = True
                    keybd_event(MButton, 0, 0, 0) 'Hold down Middle Mouse Button
                Else
                    onoff = False
                    keybd_event(MButton, 0, 2, 0) 'Stop holding down Middle Mouse Button
                End If
            End If
        End Sub
    End Class
    When I use the T button, it works fine. The only problem with using T is that when you go to type T, it stops holding it down. Anyone have a clue what's going on?

  2. #2
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    You press T is fine, but you hold is bad?
    I don't understand you what you mean..

    Quote Originally Posted by Cryptonic View Post
    So, this makes no sense to me. I'm using this code to hold down the middle mouse button ingame (to hold down voice chat) and it only works when it says (this team wins, like Alpha Team Wins! or Bravo Team Wins!).

    Code:
    Public Class Form1
    
        Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vbkey As Int16) As Int32
        Dim onoff As Boolean = False
        Const MButton As Byte = &H4 'Middle Mouse Button
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim endbutton As Boolean
            endbutton = GetAsyncKeyState(Keys.End)
    
            If endbutton = True Then
                If onoff = False Then
                    onoff = True
                    keybd_event(MButton, 0, 0, 0) 'Hold down Middle Mouse Button
                Else
                    onoff = False
                    keybd_event(MButton, 0, 2, 0) 'Stop holding down Middle Mouse Button
                End If
            End If
        End Sub
    End Class
    When I use the T button, it works fine. The only problem with using T is that when you go to type T, it stops holding it down. Anyone have a clue what's going on?
    Donations like thanks .)
    ...





  3. #3
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Drokechas View Post
    You press T is fine, but you hold is bad?
    I don't understand you what you mean..

    It's for holding down a button on your keyboard/mouse. The code for holding down T, or any other number/letter works fine, but if I try to use Middle Mouse Button it doesn't work ingame (but actually pressing the button works). But, no one will probably figure it out, yet alone understand what I'm trying to say here.

  4. #4
    R3DDOT's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Location
    C://Windows/system32
    Posts
    347
    Reputation
    38
    Thanks
    2,366
    My Mood
    Cheerful
    Quote Originally Posted by Cryptonic View Post


    It's for holding down a button on your keyboard/mouse. The code for holding down T, or any other number/letter works fine, but if I try to use Middle Mouse Button it doesn't work ingame (but actually pressing the button works). But, no one will probably figure it out, yet alone understand what I'm trying to say here.
    o.o
    why are you using keybd_event to trigger an event for a mouse button?
    Use mouse_Event instead:

    Code:
        ''' <summary>
        ''' The mouse_event function synthesizes mouse motion and button clicks.
        ''' </summary>
        ''' <param name="dwFlags">Controls various aspects of mouse motion and button clicking. This parameter can be certain combinations of the following values.</param>
        ''' <param name="dx">The mouse's absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE.</param>
        ''' <param name="dy">The mouse's absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE.</param>
        ''' <param name="dwData">If dwFlags contains MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement.</param>
        ''' <param name="dwExtraInfo">An additional value associated with the mouse event.</param>
        Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As UInteger, ByVal dx As UInteger, ByVal dy As UInteger, ByVal dwData As UInteger, ByVal dwExtraInfo As ULong)
        Public Enum MouseEvent_Flags As UInt32
            MOUSEEVENTF_ABSOLUTE = &H8000 'The dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system.
            MOUSEEVENTF_LEFTDOWN = &H2 'The left button is down.
            MOUSEEVENTF_LEFTUP = &H4 'The left button is up.
            MOUSEEVENTF_MIDDLEDOWN = &H20 'The middle button is down.
            MOUSEEVENTF_MIDDLEUP = &H40 'The middle button is up.
            MOUSEEVENTF_MOVE = &H1 'Movement occurred.
            MOUSEEVENTF_RIGHTDOWN = &H8 'The right button is down.
            MOUSEEVENTF_RIGHTUP = &H10 'The right button is up.
            MOUSEEVENTF_XDOWN = &H80 'An X button was pressed.
            MOUSEEVENTF_XUP = &H100 'An X button was released.
            MOUSEEVENTF_WHEEL = &H800 'The wheel has been moved, if the mouse has a wheel. The amount of movement is specified in dwData.
            MOUSEEVENTF_HWHEEL = &H1000 'The wheel button is tilted.
            MOUSEEVENTF_VIRTUALDESK = &H4000 'Maps coordinates to the entire desktop. Must be used with MOUSEEVENTF_ABSOLUTE.
        End Enum
    If you wish to hold down MButton then:
    Code:
    Dim IsEndPressed As Boolean = False
    Dim AfterEndRelease as boolean = false
    
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim endbutton As Boolean = GetAsyncKeyState(Keys.End)
    
            If endbutton = True Then
                If IsEndPressed = False Then
                    IsEndPressed = True
                    AfterEndRelease = True
                    mouse_event(MouseEvent_Flags.MOUSEEVENTF_MIDDLEDOWN , 0, 0, 0) 'Holds down Middle Mouse Button.
                end If
            Else
                  IsEndPressed = True
                   if AfterEndRelease = True then
                      AfterEndRelease = False
                      mouse_event(MouseEvent_Flags.MOUSEEVENTF_MIDDLEUP , 0, 0, 0) 'Releases Middle Mouse Button.
                   end if
            End If
    
        End Sub

  5. The Following User Says Thank You to R3DDOT For This Useful Post:

    Cryptonic (06-01-2014)

  6. #5
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    But after not work midle mouse, is any problem? or not problem for using?

    Quote Originally Posted by Cryptonic View Post


    It's for holding down a button on your keyboard/mouse. The code for holding down T, or any other number/letter works fine, but if I try to use Middle Mouse Button it doesn't work ingame (but actually pressing the button works). But, no one will probably figure it out, yet alone understand what I'm trying to say here.
    Donations like thanks .)
    ...





  7. #6
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by R3DDOT View Post

    o.o
    why are you using keybd_event to trigger an event for a mouse button?
    Use mouse_Event instead:

    Code:
        ''' <summary>
        ''' The mouse_event function synthesizes mouse motion and button clicks.
        ''' </summary>
        ''' <param name="dwFlags">Controls various aspects of mouse motion and button clicking. This parameter can be certain combinations of the following values.</param>
        ''' <param name="dx">The mouse's absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE.</param>
        ''' <param name="dy">The mouse's absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE.</param>
        ''' <param name="dwData">If dwFlags contains MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement.</param>
        ''' <param name="dwExtraInfo">An additional value associated with the mouse event.</param>
        Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As UInteger, ByVal dx As UInteger, ByVal dy As UInteger, ByVal dwData As UInteger, ByVal dwExtraInfo As ULong)
        Public Enum MouseEvent_Flags As UInt32
            MOUSEEVENTF_ABSOLUTE = &H8000 'The dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system.
            MOUSEEVENTF_LEFTDOWN = &H2 'The left button is down.
            MOUSEEVENTF_LEFTUP = &H4 'The left button is up.
            MOUSEEVENTF_MIDDLEDOWN = &H20 'The middle button is down.
            MOUSEEVENTF_MIDDLEUP = &H40 'The middle button is up.
            MOUSEEVENTF_MOVE = &H1 'Movement occurred.
            MOUSEEVENTF_RIGHTDOWN = &H8 'The right button is down.
            MOUSEEVENTF_RIGHTUP = &H10 'The right button is up.
            MOUSEEVENTF_XDOWN = &H80 'An X button was pressed.
            MOUSEEVENTF_XUP = &H100 'An X button was released.
            MOUSEEVENTF_WHEEL = &H800 'The wheel has been moved, if the mouse has a wheel. The amount of movement is specified in dwData.
            MOUSEEVENTF_HWHEEL = &H1000 'The wheel button is tilted.
            MOUSEEVENTF_VIRTUALDESK = &H4000 'Maps coordinates to the entire desktop. Must be used with MOUSEEVENTF_ABSOLUTE.
        End Enum
    If you wish to hold down MButton then:
    Code:
    Dim IsEndPressed As Boolean = False
    Dim AfterEndRelease as boolean = false
    
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim endbutton As Boolean = GetAsyncKeyState(Keys.End)
    
            If endbutton = True Then
                If IsEndPressed = False Then
                    IsEndPressed = True
                    AfterEndRelease = True
                    mouse_event(MouseEvent_Flags.MOUSEEVENTF_MIDDLEDOWN , 0, 0, 0) 'Holds down Middle Mouse Button.
                end If
            Else
                  IsEndPressed = True
                   if AfterEndRelease = True then
                      AfterEndRelease = False
                      mouse_event(MouseEvent_Flags.MOUSEEVENTF_MIDDLEUP , 0, 0, 0) 'Releases Middle Mouse Button.
                   end if
            End If
    
        End Sub
    Although your code has some errors, I was able to get it to work, though the only problem is that it doesn't turn off once it's on. But it's not a big deal since you can just press the MMB and it will turn off.
    @Drokechas I'm sorry, but I don't understand you.

  8. #7
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    If something bothers you that if it does not work or not?

    Quote Originally Posted by Cryptonic View Post


    Although your code has some errors, I was able to get it to work, though the only problem is that it doesn't turn off once it's on. But it's not a big deal since you can just press the MMB and it will turn off.
    @Drokechas I'm sorry, but I don't understand you.
    Donations like thanks .)
    ...





  9. #8
    R3DDOT's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Location
    C://Windows/system32
    Posts
    347
    Reputation
    38
    Thanks
    2,366
    My Mood
    Cheerful
    Quote Originally Posted by Cryptonic View Post


    Although your code has some errors, I was able to get it to work, though the only problem is that it doesn't turn off once it's on. But it's not a big deal since you can just press the MMB and it will turn off.
    @Drokechas I'm sorry, but I don't understand you.
    What sort of errors? Can you explain a little bit better? (NVM, I already saw the error.)

    When GetAsyncKeyState(Keys.End) = False, make sure that IsEndPressed = FALSE, and not True.

Similar Threads

  1. What mouse sensitivy do you use for Combat arms
    By death9191 in forum Combat Arms Hacks & Cheats
    Replies: 29
    Last Post: 07-05-2009, 12:15 AM
  2. [Release]LOLWAT | C++ Trainer for Combat Arms
    By KiN in forum Combat Arms Hacks & Cheats
    Replies: 19
    Last Post: 08-23-2008, 10:51 AM
  3. [Release]LOLWAT | C++ Trainer for Combat Arms
    By KiN in forum Combat Arms Hacks & Cheats
    Replies: 46
    Last Post: 08-23-2008, 07:48 AM
  4. Yay, My own settings for Combat Arms!
    By gudsoldier in forum Combat Arms Hacks & Cheats
    Replies: 23
    Last Post: 08-21-2008, 01:03 PM
  5. Best place to get hacks for Combat Arms?
    By Callousone in forum Combat Arms Hacks & Cheats
    Replies: 4
    Last Post: 08-08-2008, 02:23 PM