AutoHotkey Community

It is currently May 27th, 2012, 10:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Invert mouse axis
PostPosted: May 20th, 2007, 8:01 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 12:05 am 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
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.google.com/answers/threadview?id=408579

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 1:49 am 
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!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 2:19 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
This should invert the y (vertical) direction of the mouse:
Code:
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
Code:
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 2:35 am 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
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! : )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 2:44 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 3:27 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.
Code:
#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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2007, 12:00 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2007, 5:09 am 
Is there any way you could also post a script for just the y-axis that doesn't fail at the edges?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2007, 3:09 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Code:
#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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2007, 11:47 pm 
Can you disable one of the axis?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2007, 11:51 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Code:
#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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2007, 11:26 pm 
When i add a hotkey (so while you are pressing it) it does not work?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2007, 1:06 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
The hotkey should start/stop the timer WatchMouse (On/Off).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2008, 10:39 pm 
Offline

Joined: July 6th, 2006, 7:26 pm
Posts: 48
Location: Poland
Laszlo wrote:
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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Maestr0 and 60 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