AutoHotkey Community

It is currently May 27th, 2012, 4:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: January 13th, 2008, 7:23 am 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
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 January 13th, 2008, 6:09 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 13th, 2008, 9:38 am 
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...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2008, 6:07 pm 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
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. :P

_________________
Truth is truth, whether you believe it or not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2010, 4:13 pm 
Offline

Joined: November 23rd, 2009, 2:11 pm
Posts: 104
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Mickers, rbrtryn, Yahoo [Bot] and 66 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group