Here is some background. I downloaded a free app for my BlackBerry that maps the BB keyboard and trackball to the PC keyboard/mouse over bluetooth. The program works fine but I am using AHK to build extra functionality into it. Currently I am struggling with mapping the mouse movements to keyboard arrow movements. I am doing this so that I can use the BB trackball to navigate menu's and XBMC on my HTPC. I am using a simple toggle to switch between the native mouse movements and the arrow keys.
The problem with the script below seems to be the MouseMove at the end. The program (XBMC or Boxee) detects this and it ruins the SendInput of the arrow keys. If I remove the MouseMove at the end then it goes whacky and enters a neverending loop.
Basically I was wondering if there was anyway to completely hide the mouse movements but at the same time map the mouse movements to the arrow keys (up, down, left, right). I've been going through a lot of threads but nothing addressed this problem. One solution that was beyond me seems to be ClipCursor but not sure if it is right for what I am doing.
Here is the simple script:
NoEnv #SingleInstance force #Persistent SetBatchLines -1 Process Priority,,R BlockInput SendAndMouse ; user mouse input is ignored during MouseMove CoordMode Mouse, Screen ; absolute coordinates 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 If (x < (x0-10)) { SendInput {Left} } Else If (x > (x0+10)) { SendInput {Right} } Else If (y > (y0+10)) { SendInput {Down} } Else If (y < (y0-10)) { SendInput {Up} } MouseMove x0, y0, 0 ; set mouse to original location Return ^z::ExitApp