Nologic Posted January 16, 2010 Share Posted January 16, 2010 (edited) This is basically a twist on Monamo's Keyboard MouseMover script, by integrating Ejoc's JoyStick UDF.Movement can be done by ether the POV or Joystick 1, Button 1 acts as Primary Mouse Button and Button 2 as Secondary Mouse Button, with Button 3 being Middle Mouse Button. Acceleration multiplier is Button 6 and ESC will exit the application.expandcollapse popup; //////////////////////////////////// ; /// Original by Monamo ; /// Original by Ejoc ; /// Improved by Adam1213 ; /// Modded by Nologic ; //////////////////////////////////// HotKeySet ( "{ESC}" , "_Quit" ) $Modifier = 1 $Pressed = 1 $joy = _JoyInit() While 1 Sleep(10) _CursorMove() WEnd $lpJoy = 0 ; Joyclose ;====================================== ; _JoyInit() ;====================================== Func _JoyInit() Local $joy Global $JOYINFOEX_struct = "dword[13]" $joy=DllStructCreate($JOYINFOEX_struct) If @Error Then Return 0 DllStructSetData($joy, 1, DllStructGetSize($joy), 1) ; dwSize = sizeof(struct) DllStructSetData($joy, 1, 255, 2) ; dwFlags = GetAll Return $joy EndFunc ;====================================== ; _GetJoy($lpJoy,$iJoy) ; $lpJoy Return from _JoyInit() ; $iJoy Joystick # 0-15 ; Return Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos, POV ; Buttons down ; ; *POV This is a digital game pad, not analog joystick ; 65535 = Not pressed ; 0 = U ; 4500 = UR ; 9000 = R ; Goes around clockwise increasing 4500 for each position ;====================================== Func _GetJoy($lpJoy,$iJoy) Local $coor Dim $coor[8] DllCall("Winmm.dll","int","joyGetPosEx", _ "int",$iJoy,"ptr",DllStructGetPtr($lpJoy)) If NOT @Error Then $coor[0] = DllStructGetData($lpJoy,1,3) ; X Axis $coor[1] = DllStructGetData($lpJoy,1,4) ; Y Axis $coor[2] = DllStructGetData($lpJoy,1,5) ; Z Axis $coor[3] = DllStructGetData($lpJoy,1,6) ; R Axis $coor[4] = DllStructGetData($lpJoy,1,7) ; U Axis $coor[5] = DllStructGetData($lpJoy,1,8) ; V Axis $coor[6] = DllStructGetData($lpJoy,1,11) ; POV Value $coor[7] = DllStructGetData($lpJoy,1,9) ; Buttons Mask EndIf Return $coor EndFunc Func _CursorMove() $GamePad_1 = _GetJoy($joy,0) If $GamePad_1[6] = 65535 AND $GamePad_1[0] > 30000 AND $GamePad_1[0] < 40000 AND $GamePad_1[1] > 30000 AND $GamePad_1[1] < 40000 Then $Modifier = 1 $Pressed = 1 EndIf ; Check Keys Select ; Button 1 Case $GamePad_1[7] = 1 MouseClick ( "Primary" ) Sleep ( 150 ) Return ; Button 2 Case $GamePad_1[7] = 2 MouseClick ( "Secondary" ) Sleep ( 150 ) Return ; Button 3 Case $GamePad_1[7] = 4 MouseClick ( "Middle" ) Return ; Up + Left Case $GamePad_1[0] < 30000 AND $GamePad_1[1] < 30000 OR $GamePad_1[6] = 31500 $Delta_X = -1 $Delta_Y = -1 ; Up + Right Case $GamePad_1[0] > 40000 AND $GamePad_1[1] < 30000 OR $GamePad_1[6] = 4500 $Delta_X = +1 $Delta_Y = -1 ; Down + Left Case $GamePad_1[0] < 30000 AND $GamePad_1[1] > 40000 OR $GamePad_1[6] = 22500 $Delta_X = -1 $Delta_Y = +1 ; Down + Right Case $GamePad_1[0] > 40000 AND $GamePad_1[1] > 40000 OR $GamePad_1[6] = 13500 $Delta_X = +1 $Delta_Y = +1 ; Arrow Left Case $GamePad_1[0] < 30000 OR $GamePad_1[6] = 27000 $Delta_X = -1 $Delta_Y = 0 ; Arrow Up Case $GamePad_1[1] < 30000 OR $GamePad_1[6] = 0 $Delta_X = 0 $Delta_Y = -1 ; Arrow Right Case $GamePad_1[0] > 40000 OR $GamePad_1[6] = 9000 $Delta_X = +1 $Delta_Y = 0 ; Arrow Down Case $GamePad_1[1] > 40000 OR $GamePad_1[6] = 18000 $Delta_X = 0 $Delta_Y = +1 Case Else Return EndSelect ; Boost Mouse Speed If IsInt($Pressed / 10) Then $Modifier = $Modifier + 1 $Pressed = $Pressed + 1 Else $Pressed = $Pressed + 1 EndIf ; Button 6 Accelerate If $GamePad_1[7] = 32 Then $Accel = 3 Else $Accel = 1 EndIf ; Throttle Modifier If $Modifier >= 15 Then $Modifier = 15 $X_Axis = MouseGetPos(0) + ($Delta_X * ($Modifier * $Accel)) $Y_Axis = MouseGetPos(1) + ($Delta_Y * ($Modifier * $Accel)) $Desktop = WinGetPos( "Program Manager" ) ; Test Location - Multi Monitor If $x_Axis < $Desktop[0] Then $x_Axis = $Desktop[0] If $Y_Axis < $Desktop[1] Then $Y_Axis = $Desktop[1] If $x_Axis > $Desktop[2] - $Desktop[0] Then $x_Axis = $Desktop[2] - $Desktop[0] If $Y_Axis > $Desktop[3] - $Desktop[1] Then $Y_Axis = $Desktop[3] - $Desktop[1] MouseMove( $X_Axis , $Y_Axis , 1 ) EndFunc Func _Quit() Exit EndFunc Edited January 16, 2010 by Nologic Link to comment Share on other sites More sharing options...
mfdemir Posted August 23, 2012 Share Posted August 23, 2012 Thanks, working perfectly. Link to comment Share on other sites More sharing options...
maillady Posted August 26, 2012 Share Posted August 26, 2012 Thanks, working perfectly. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now