 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
CraSH23000
Joined: 22 Jun 2007 Posts: 40
|
Posted: Sun Jan 13, 2008 6:23 am Post subject: Un-Interrupting Second Mouse Used by Joystick |
|
|
I was playing around with http://www.autohotkey.com/docs/scripts/JoystickMouse.htm and I thought it would be cool to make a 2nd mouse. I am trying to find away to get what window is under my second mouse so that I can do controlclicks instead of mouseclicks so that I dont have to pull the primary mouse and change active windows.
It is kind of cool and has potential but there is some obstacles.
Heres the code:
| Code: | ; Using a Joystick as a Mouse
; http://www.autohotkey.com
; This script converts a joystick into a three-button mouse. It allows each
; button to drag just like a mouse button and it uses virtually no CPU time.
; Also, it will move the cursor faster depending on how far you push the joystick
; from center. You can personalize various settings at the top of the script.
; Increase the following value to make the mouse cursor move faster:
JoyMultiplier = 0.30
; Decrease the following value to require less joystick displacement-from-center
; to start moving the mouse. However, you may need to calibrate your joystick
; -- ensuring it's properly centered -- to avoid cursor drift. A perfectly tight
; and centered joystick could use a value of 1:
JoyThreshold = 3
; Change the following to true to invert the Y-axis, which causes the mouse to
; move vertically in the direction opposite the stick:
InvertYAxis := false
; Change these values to use joystick button numbers other than 1, 2, and 3 for
; the left, right, and middle mouse buttons. Available numbers are 1 through 32.
; Use the Joystick Test Script to find out your joystick's numbers more easily.
ButtonLeft = 1
ButtonRight = 2
ButtonMiddle = 3
; If your joystick has a POV control, you can use it as a mouse wheel. The
; following value is the number of milliseconds between turns of the wheel.
; Decrease it to have the wheel turn faster:
WheelDelay = 250
; If your system has more than one joystick, increase this value to use a joystick
; other than the first:
JoystickNumber = 1
; END OF CONFIG SECTION -- Don't change anything below this point unless you want
; to alter the basic nature of the script.
MouseGetPos, xval, yval
CoordMode,Mouse, Screen
SplashImage, mouse_clone.jpg, B X%xval% Y%yval%,,,, splash_image_title
#SingleInstance
JoystickPrefix = %JoystickNumber%Joy
Hotkey, %JoystickPrefix%%ButtonLeft%, ButtonLeft
Hotkey, %JoystickPrefix%%ButtonRight%, ButtonRight
Hotkey, %JoystickPrefix%%ButtonMiddle%, ButtonMiddle
; Calculate the axis displacements that are needed to start moving the cursor:
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
if InvertYAxis
YAxisMultiplier = -1
else
YAxisMultiplier = 1
SetTimer, WatchJoystick, 10 ; Monitor the movement of the joystick.
GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P ; Joystick has POV control, so use it as a mouse wheel.
SetTimer, MouseWheel, %WheelDelay%
return ; End of auto-execute section.
; The subroutines below do not use KeyWait because that would sometimes trap the
; WatchJoystick quasi-thread beneath the wait-for-button-up thread, which would
; effectively prevent mouse-dragging with the joystick.
ButtonLeft:
MouseGetPos, xmval, ymval
xclkspot := xval-1
yclkspot := yval-1
MouseClick, left,%xclkspot%, %yclkspot%, 1, 0
SetMouseDelay, 10
MouseMove, %xmval%, %ymval%, 0
return
ButtonRight:
MouseGetPos, xmval, ymval
xclkspot := xval-1
yclkspot := yval-1
MouseClick, Right,%xclkspot%, %yclkspot%, 1, 0
SetMouseDelay, 10
MouseMove, %xmval%, %ymval%, 0
return
ButtonMiddle:
MouseGetPos, xmval, ymval
xclkspot := xval-1
yclkspot := yval-1
MouseClick, Middle,%xclkspot%, %yclkspot%, 1, 0
SetMouseDelay, 10
MouseMove, %xmval%, %ymval%, 0
return
WatchJoystick:
MouseNeedsToBeMoved := false ; Set default.
SetFormat, float, 03
GetKeyState, joyx, %JoystickNumber%JoyX
GetKeyState, joyy, %JoystickNumber%JoyY
if joyx > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaX := joyx - JoyThresholdUpper
}
else if joyx < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaX := joyx - JoyThresholdLower
}
else
DeltaX = 0
if joyy > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
MouseNeedsToBeMovedup := true
DeltaY := joyy - JoyThresholdUpper
}
else if joyy < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaY := joyy - JoyThresholdLower
}
else
DeltaY = 0
if MouseNeedsToBeMoved
{
xval := xval + DeltaX * JoyMultiplier
yval := yval + DeltaY * JoyMultiplier * YAxisMultiplier
SplashImage, Off
SplashImage, mouse_clone.jpg, B X%xval% Y%yval%,,,, splash_image_title
}
return
|
I have a .rar so that it will work because of the image for the 2nd mouse
Download Mouse_Clone.rar
EDIT: 7-zip requested: Download Mouse_Clone.7z
Thanks to "Guest" for telling me about .7z, looks like thy compress even smaller than .rar
Thanks for any advise or criticism. _________________ Truth is truth, whether you believe it or not.
Last edited by CraSH23000 on Sun Jan 13, 2008 5:09 pm; edited 2 times in total |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jan 13, 2008 8:38 am Post subject: Re: Un-Interrupting Second Mouse Used by Joystick |
|
|
| CraSH23000 wrote: | | I have a .rar... |
...grrrrr!...can I PLEASE beg people to stop posting .rar's?...if you can make a .rar, you can make a .zip...or even better make a .7z... |
|
| Back to top |
|
 |
CraSH23000
Joined: 22 Jun 2007 Posts: 40
|
Posted: Sun Jan 13, 2008 5:07 pm Post subject: |
|
|
Changed top post to include a .7z. I only used .rar because they compress better than .zip but its nice that .7z compresses even smaller than .rar.  _________________ Truth is truth, whether you believe it or not. |
|
| Back to top |
|
 |
geekdude
Joined: 23 Nov 2009 Posts: 64
|
Posted: Thu Feb 25, 2010 3:13 pm Post subject: |
|
|
i do have something to say,, you can use these instead of all those ;
| Quote: | In addition, the /* and */ symbols can be used to comment out an entire section, but only if the symbols appear at the beginning of a line as in this example:
/*
MsgBox, This line is commented out (disabled).
MsgBox, This one too.
*/ |
http://www.autohotkey.com/docs/Scripts.htm#Comments  _________________ /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|