Jump to content

Multiple button hotkey on a gamepad


Recommended Posts

How would the hotkey line with button[6] be modified to support 2 button presses? Tried to use & operator but it gave me errors.

#include <_XInput.au3>

$dll = DllOpen("user32.dll")
$inputhwnd = _XInputInit()
$fire1=0
$fire2=0
$forward = 0
$left = 0
$right = 0
$back = 0
$crouch = 0
$sensitivity = 1000 ;Higher Value equals less sensitive

While 1

$input = _XInputGetInput($inputhwnd)
$buttons = _XInputButtons($input[2])

If $input[4]<200 Then
    If $fire1=1 Then
        MouseUp("left")
        $fire1=0
    EndIf
Else
    If $fire1=0 then
        MouseDown ( "left" )
        $fire1=1
    EndIf
EndIf


                     ;;;;
;;This part need two hotkeys instead of just one;;
                     ;;;;

If $buttons[6] Then
    If abs($input[7]) > 4000 Or abs($input[8])>4000 Then _MouseMovePlus((($buttons[8]*2)+1)*($input[7]/$sensitivity),-(($buttons[8]*2)+1)*($input[8]/$sensitivity),$dll)
Endif
_MySleep(20)
WEnd

Func _MySleep($t)
    DllCall("winmm.dll","long","timeBeginPeriod","long",1)
    DllCall("kernel32.dll", "none", "Sleep", "long", $t)
    DllCall("winmm.dll","long","timeEndPeriod","long",1)
EndFunc

Func _MouseMovePlus($X = "", $Y = "",$dll = 0)
        Local $MOUSEEVENTF_MOVE = 0x1
    If $dll = 0 Then
    DllCall("user32.dll", "none", "mouse_event", _
            "long",  $MOUSEEVENTF_MOVE, _
            "long",  $X, _
            "long",  $Y, _
            "long",  0, _
        "long",  0)
    Else
    DllCall($dll, "none", "mouse_event", _
            "long",  $MOUSEEVENTF_MOVE, _
            "long",  $X, _
            "long",  $Y, _
            "long",  0, _
        "long",  0)
    EndIf
EndFunc
Edited by darknezz21
Link to comment
Share on other sites

  • Moderators

darknezz21,

A variable named "$fire1" and your use of _MouseMovePlus say otherwise. Thread locked. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...