Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Invert mouse axis


  • Please log in to reply
28 replies to this topic
Frans
  • Guests
  • Last active:
  • Joined: --
Hello all,

I'm busy with a project for school and fabricated a mouse-like device, that is, it doesn't look like a mouse, but has a ps2 connector and moves my cursor very nicely around the screen...unfortinately I haven't been so smart and now figured out that I need to invert the mouse axis, or rebuild the thing.

I found on internet a file which should invert the axis, but doesn't work for me...
; Script for AutoHotKeys, http://autohotkey.com/
; Inverts the mouse along the y axis. Works great, but not in games or other
; apps that use DirectInput. :/

#SingleInstance
#Persistent

SetBatchLines, 10ms
;CoordMode, Mouse, Screen
BlockInput, Mouse
SetMouseDelay, -1 ; Makes movement smoother.

oldy = 0 ; initial value
SetTimer, WatchMouse, 1
return

WatchMouse:
IfWinNotActive, Beyond Good & Evil - Ubisoft
return

MouseGetPos, x, y,

delta = %y%
delta -= %oldy%
if delta <> 0
{
delta *= -2
MouseMove, 0, %delta%, 0, R
MouseGetPos, x, oldy
}
return

What could I change in the script in order to make it work?
greetz, Frans

Murp-e
  • Members
  • 531 posts
  • Last active: Sep 27 2011 11:44 AM
  • Joined: 12 Jan 2007
I'm afraid I can't help you, but I tried to google around a bit and found someone who was in the exact same situation as you:
http://answers.googl...dview?id=408579

Since the script you pasted doesn't work in your game, I'm not sure any AutoHotkey scripts will??

frans
  • Guests
  • Last active:
  • Joined: --
The problem is that It doesn't work at al...I don't want to use it in a gaming environment, just in windows.. But thanks for your reply anyway!

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
This should invert the y (vertical) direction of the mouse:
BlockInput Mouse
SetMouseDelay -1

MouseGetPos x, oldy
SetTimer WatchMouse, 1
Return

WatchMouse:
   MouseGetPos x, y
   MouseMove 0, 2*(oldy-y), 0, R
   MouseGetPos x, oldy
Return

!z::ExitApp
This version inverts both axes
BlockInput Mouse
SetMouseDelay -1

MouseGetPos x0, y0
SetTimer WatchMouse, 1
Return

WatchMouse:
   MouseGetPos x, y
   MouseMove 2*(x0-x), 2*(y0-y), 0, R
   MouseGetPos x0, y0
Return

!z::ExitApp


Murp-e
  • Members
  • 531 posts
  • Last active: Sep 27 2011 11:44 AM
  • Joined: 12 Jan 2007
Nice work Laszlo, although it seemed a little bit bumpy, this worked like a charm for me. But do you think it will work in the game that was requested considering the other script did not?

P.S. Don't dive below the taskbar with this thing on! : )

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
These scripts fail at the screen edges, because you cannot move the mouse any more out, what was necessary to move the pointer away from the edge.

This kind of mouse movement manipulation is always jerky a bit, because of the processing time and the timer routine, which cannot be activated more often than every 10..16ms, the Windows timer resolution.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Here is a version of the x/y script, which does not fail on the screen edges: it keeps the mouse pointer 1 pixel from the sides.
#NoEnv

SetBatchLines -1

Process Priority,,R



BlockInput Mouse        ; user mouse input is ignored during MouseMove

CoordMode Mouse, Screen ; absolute coordinates

SysGet m, Monitor       ; get the screen edges

mLeft += 1, mRight -= 2, mTop += 1, mBottom -= 2

SetMouseDelay -1        ; fastest action



MouseGetPos x0, y0      ; get initial mouse pointer location

SetTimer WatchMouse, 1  ; run the subroutine fast (10..16ms)

Return



WatchMouse:

   MouseGetPos x, y     ; get current mouse position

   x0 += 2*(x0-x), x0 := x0 < mLeft ? mLeft : (x0 > mRight  ? mRight  : x0)

   y0 += 2*(y0-y), y0 := y0 < mTop  ? mTop  : (y0 > mBottom ? mBottom : y0)

   MouseMove x0, y0, 0  ; set new position as old, for the next timer

Return



!z::ExitApp             ; stop the madness; make the script persistent



Frans
  • Guests
  • Last active:
  • Joined: --
THANK YOU ALL!

for helping me out, it works perfectly! I'm really interested in learning how to use Autohotkey now! Thanks again for the posts!

Greetz, Frans

  • Guests
  • Last active:
  • Joined: --
Is there any way you could also post a script for just the y-axis that doesn't fail at the edges?

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
#NoEnv

SetBatchLines -1

Process Priority,,R



BlockInput Mouse        ; user mouse input is ignored during MouseMove

CoordMode Mouse, Screen ; absolute coordinates

SysGet m, Monitor       ; get the screen edges

mTop += 1, mBottom -= 2

SetMouseDelay -1        ; fastest action



MouseGetPos x0, y0      ; get initial mouse pointer location

SetTimer WatchMouse, 1  ; run the subroutine fast (10..16ms)

Return



WatchMouse:

   MouseGetPos x, y     ; get current mouse position

   y0 += 2*(y0-y), y0 := y0 < mTop  ? mTop  : (y0 > mBottom ? mBottom : y0)

   MouseMove x, y0, 0  ; set new position as old, for the next timer

Return



!z::ExitApp             ; stop the madness; make the script persistent


Disable
  • Guests
  • Last active:
  • Joined: --
Can you disable one of the axis?

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
#NoEnv

SetBatchLines -1

Process Priority,,R



BlockInput Mouse        ; user mouse input is ignored during MouseMove

CoordMode Mouse, Screen ; absolute coordinates

SysGet m, Monitor       ; get the screen edges

mTop += 1, mBottom -= 2

SetMouseDelay -1        ; fastest action



MouseGetPos x0, y0      ; get initial mouse pointer location

SetTimer WatchMouse, 1  ; run the subroutine fast (10..16ms)

Return



WatchMouse:

   MouseGetPos x, y     ; get current mouse position

   y0 += 2*(y0-y), y0 := y0 < mTop  ? mTop  : (y0 > mBottom ? mBottom : y0)

   MouseMove x0, y0, 0  ; set new position as old, for the next timer

Return



!z::ExitApp             ; stop the madness; make the script persistent


Disable
  • Guests
  • Last active:
  • Joined: --
When i add a hotkey (so while you are pressing it) it does not work?

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
The hotkey should start/stop the timer WatchMouse (On/Off).

Tester
  • Members
  • 48 posts
  • Last active: Feb 07 2011 01:34 PM
  • Joined: 06 Jul 2006

Here is a version of the x/y script, which does not fail on the screen edges: it keeps the mouse pointer 1 pixel from the sides.
...


Unfortunately none of it didn't work with digitizer input on TabletPC.
any other ideas how to revert tablet stylus movement?