User Avatar Image

Autohotkey script for mouse movement in W&G

posted by Derrick on - last edited - Viewed by 2.3K users

I wrote an AutoHotkey script that will help users control the movement in W&G with the mouse instead of the keyboard.

There are 2 methods of movement when using this script. Both are accessed by pressing either the left or right mouse button. You may find that when you use the left button for moving, you may accidentally click and trigger a selectable object. That is why I also allow for using the right button to move. It will not trigger the items, so I highly recommend using it instead of the left button.

Method 1:
When you click on the edge of the screen, it will simulate the arrow key for as long as you hold the mouse button down. The corners of the screen will press 2 arrows for diagonal movement.

Method 2:
When the cursor is not at the edges of the screen, you can press and hold the mouse button for movement. After a short user specified delay, the mouse movement will be limited to a small box. Moving to the edges and diagonals of this box will cause the corresponding arrow keys to be pressed. You can use this method anywhere on the screen as long as it is 1 movement box in size from the edge of the screen. The box defaults to 100 pixels, but you can change that.

When the game is running in a window instead of fullscreen, the movement works the same. When you click the mouse in the window it will lock itself into the window so you can easily use Movement Method 1. The mouse will free itself to the full window by pressing the 'F' key or by [Alt][Tab]ing to another running program.

To get this running you will need to install AutoHotkey available here:
www.autohotkey.com

Then download the attached script. Unzip the file some where. When you run it, it will launch the game and you are good to go. When you quit the game, the script will quit so mouse clicks are no longer remapped as arrow keys.

You can also right click on the script file and compile it if you like. Then it can be run on other computers without installing AutoHotkey.

You can edit settings in the script file by right clicking on it and picking Edit Script. Then at the start of the file, look for the following lines to change as you like:

How to change the game:
set episode to 0 for the demo. 1, 2, 3, 4 for the corresponding episode. Other values will give you an error and quit the script.
As of writing this, episodes 3&4 have not been released so I can not test them. I believe it should work fine.
; Set this to the W&G episode you want to run with this script
; 0 = Demo
episode := 1

How to change the button functions:
* Remember using the left button for movement can cause triggerable items to be selected.
set the following values to 0 to disable and 1 to enable.
useEdgesL - enables Movement Method 1 for the left mouse button.
useCenterL - enables Movement Method 2 for the left mouse button.
useEdgesR - enables Movement Method 1 for the right mouse button.
useCenterR - enables Movement Method 2 for the right mouse button.
; set options to 0=disable 1=enable
; Left Button options
useEdgesL := 1
useCenterL := 1

; Right Button options
useEdgesR := 1
useCenterR := 1

How to change the delay before Movement Method 2 is activated:
buttonDelayL - time in milliseconds to press the left mouse button.
buttonDelayR - time in milliseconds to press the right mouse button.
; how long in milliseconds to press mouse button in center screen before movement is controlled by mouse dragging
; left move delay
buttonDelayL := 150

; right move delay
buttonDelayR := 50

How to change the Movement Method 2 box size:
boxSize - height and width in pixels of the restricted mouse movement for Movement Method 2
; movement box size in pixels
boxSize := 100

How to change how wide of a selection area at the edge of the game view window that can be pressed for Movement Method 1:
borderPixels - number of pixels in from the edge
; pixels at edge used to select movement
; must be 1 to 25
borderPixels := 5

Have fun. Hopefully TTG does not delete this. If they feel the need to, then please p-mail me with the reason for removing this thread/info.

If for some reason the download is corrupt, you can just copy and paste the following code into a new script file called wg.ahk
; Script Function:
; Map mouse clicks at the edges of the screen as arrow keys
; You can also move by holding down the button and dragging the mouse
; The script will time out after 2 minutes if game is not launched
; Press 'F' in windowed mode to free the cursor


; Set this to the W&G episode you want to run with this script
; 0 = Demo
episode := 1

; set options to 0=disable 1=enable
; Left Button options
useEdgesL := 1
useCenterL := 1

; Right Button options
useEdgesR := 1
useCenterR := 1

; how long in milliseconds to press mouse button in center screen before movement is controlled by mouse dragging
; left move delay
buttonDelayL := 150

; right move delay
buttonDelayR := 50

; movement box size in pixels
boxSize := 100

; pixels at edge used to select movement
; must be 1 to 25
borderPixels := 5


; ==================================
; only change values above this line
; ==================================

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance ignore ; only allow 1 running script
SetTitleMatchMode, 3 ; Names must be exact

; check values
if (borderPixels < 1 OR borderPixels > 25)
{
MsgBox, borderPixels value out of range
ExitApp
}

timeDelayL := buttonDelayL // 10
timeDelayR := buttonDelayR // 10
movePixels := boxSize // 2
edgeMargin := movePixels * 2 + borderPixels
border := borderPixels
mouseLocked := 0

; setup paths and file
if (episode = 0)
{
gameFile = WallaceGromitDemo.exe
launcherName = Wallace & Gromit Demo
}
else if (episode = 1)
{
gameFile = WallaceGromit101.exe
launcherName = Fright of the Bumblebees
}
else if (episode = 2)
{
gameFile = WallaceGromit102.exe
launcherName = The Last Resort
}
else if (episode = 3)
{
gameFile = WallaceGromit103.exe
launcherName = Muzzled!
}
else if (episode = 4)
{
gameFile = WallaceGromit104.exe
launcherName = The Bogey Man
}
else
{
MsgBox, Invalid Episode #
ExitApp
}
gameReg = SOFTWARE\Telltale Games\%gameFile%
RegRead, gameDir, HKEY_LOCAL_MACHINE, %gameReg% , Install Location

; this is the name of the game as shown on the task bar
; Demo, Ep1 and Ep2 all use the same name, so I assume all episodes will
gameName = Telltale Games


; launch game
Run, %gameFile%, %gameDir%, UseErrorLevel
if ErrorLevel = ERROR
{
MsgBox, Episode %episode% could not be found
ExitApp
}
winwait, %gameName%, , 120
if ErrorLevel
{
ExitApp
}
gameID := WinExist(gameName)
WinActivate, ahk_id %gameID%
SetTimer, gameCheck ; check every 250ms
; setup rect variable for DLL call
VarSetCapacity(rect, 16)
return


gameCheck:
;------------------------------
; quit script on game exit
;------------------------------
if ((mouseLocked AND isFullScreen()) OR !WinActive(\"ahk_id\" . gameID))
{
; free the mouse if we switched modes or window no longer active
DllCall(\"ClipCursor\")
mouseLocked := 0
}
IfWinNotExist, ahk_id %gameID%
{
; free the mouse just in case
DllCall(\"ClipCursor\")
ExitApp
}
return


~LButton::
useEdges := useEdgesL
useCenter := useCenterL
timeDelay := timeDelayL
testButton = LButton
Gosub, mouseToArrows
return


~RButton::
useEdges := useEdgesR
useCenter := useCenterR
timeDelay := timeDelayR
testButton = RButton
Gosub, mouseToArrows
return


mouseToArrows:
;------------------------------
; process mouse movement
;------------------------------
usingCenterMove := 0
if (isFullScreen())
{
; fullscreen
CoordMode, Mouse, Screen
width := A_ScreenWidth
height := A_ScreenHeight
winXpos := 0
winYpos := 0
winXoffset := 0
winYoffset := 0
}
else
{
; only do mouse to key conversion in game window
IfWinNotActive, ahk_id %gameID%
Return,

; get window information
CoordMode, Mouse, Relative
WinGetPos, winXpos, winYpos, winWidth, winHeight, ahk_id %gameID%

; calculate border info from client window
; we do it at every mouse press because the size could change
DllCall(\"GetClientRect\", \"UInt\", gameID, \"UInt\", &rect)
width := NumGet(rect, 8, \"int\")
height := NumGet(rect, 12, \"int\")
winBorderPixels := (winWidth - width) // 2
winBarPixels := winHeight - height - winBorderPixels

; free up mouse if on top bar
MouseGetPos, , curY
if (curY < winBarPixels)
Return,

winXoffset := winBorderPixels
winYoffset := winBarPixels
; set top left of game window
; keep locking the window so the mouse does not get free
mouseLocked := 1
Gosub, lockWindow
}

; check aspect ratio and adjust
if (width * 9 // height < 16)
{
; top and bottom letterboxed
newHeight := width * 9 // 16
edgeLeft := 0
edgeRight := width
edgeUp := (height - newHeight) // 2
edgeDown := edgeUp + newHeight
}
else
{
; sides letterboxed
newWidth := height * 16 // 9
edgeLeft := (width - newWidth) // 2
edgeRight := edgeLeft + newWidth
edgeUp := 0
edgeDown := height
}

; bottom corner is one pixel in
edgeRight--
edgeDown--

if (useCenter = 1)
{
timePressed := 0
; the valid center movement area
centerLeft := edgeLeft + edgeMargin
centerRight := edgeRight - edgeMargin
centerUp := edgeUp + edgeMargin
centerDown := edgeDown - edgeMargin
}

While GetKeyState(testButton)
{
MouseGetPos, curX, curY
if (!usingCenterMove)
{
; adjust for window border
curX -= winXoffset
curY -= winYoffset
}

; remap mouse to arrow keys
; only press the down key once
if (useEdges = 1 OR usingCenterMove = 1)
{
if (curX < edgeLeft + border)
{
if (!downL)
{
Send {Left Down}
downL := 1
}
}
else
{
if (downL)
{
Send {Left Up}
downL := 0
}
}

if (curX > edgeRight - border)
{
if (!downR)
{
Send {Right Down}
downR := 1
}
}
else
{
if (downR)
{
Send {Right Up}
downR := 0
}
}

if (curY < edgeUp + border)
{
if (!downU)
{
Send {Up Down}
downU := 1
}
}
else
{
if (downU)
{
Send {Up Up}
downU := 0
}
}

if (curY > edgeDown - border)
{
if (!downD)
{
Send {Down Down}
downD := 1
}
}
else
{
if (downD)
{
Send {Down Up}
downD := 0
}
}
}

if (useCenter AND !usingCenterMove)
{
; start counting if in center of screen
if (curX > centerLeft AND curX < centerRight AND curY > centerUp AND curY < centerDown)
{
timePressed++
if (timePressed > timeDelay)
{
; button down long enough, start using center move
; readjust mousepos to real and setup movement box
curX += winXoffset
curY += winYoffset
edgeLeft := curX - movePixels
edgeUp := curY - movePixels
edgeRight := curX + movePixels
edgeDown := curY + movePixels
; fill the RECT structure with UInt values
NumPut(winXpos + edgeLeft , &rect + 0)
NumPut(winYpos + edgeUp , &rect + 4)
NumPut(winXpos + edgeRight + 1, &rect + 8)
NumPut(winYpos + edgeDown + 1, &rect + 12)
DllCall(\"ClipCursor\", UInt, &rect)
usingCenterMove := 1
border := 1
}
}
else
{
; reset count when not in center
timePressed := 0
}
}
Sleep, 10
}

if (usingCenterMove)
{
; free the cursor
if (mouseLocked)
Gosub, lockWindow
else
DllCall(\"ClipCursor\")
; reset to view border
border := borderPixels
}

; unpress any keys that are down
if (downL)
{
Send {Left Up}
downL := 0
}
if (downR)
{
Send {Right Up}
downR := 0
}
if (downU)
{
Send {Up Up}
downU := 0
}
if (downD)
{
Send {Down Up}
downD := 0
}
Return,


isFullScreen()
;------------------------------
; check to see if fullscreen
;------------------------------
{
Global gameID
WinGet, style, Style, ahk_id %gameID%
; 0x800000 is WS_BORDER.
; 0x20000000 is WS_MINIMIZE.
; no border and not minimized
Return, (style & 0x20800000) ? 0 : 1
}


~f::
;------------------------------
; free mouse from window
;------------------------------
if (mouseLocked)
{
IfWinActive, ahk_id %gameID%
{
; free the cursor
DllCall(\"ClipCursor\")
mouseLocked := 0
}
}
Return,


lockWindow:
;------------------------------
; lock mouse to window
;------------------------------
; fill the RECT structure with UInt values
NumPut(winXpos + winBorderPixels, &rect + 0)
NumPut(winYpos + winBarPixels, &rect + 4)
NumPut(winXpos + winBorderPixels + width, &rect + 8)
NumPut(winYpos + winBarPixels + height, &rect + 12)
DllCall(\"ClipCursor\", UInt, &rect)
Return,

29 Comments - Linear Discussion: Classic Style
  • @Derrick said: Just curious if you have tried my newer version of the script that lets you hold down the right mouse button to move.

    I'll try it this or next evening, but I'm quite sure what the result will be - it won't feel natural to me. The exact reason why I liked your original script (modded to the left button) is that it's very close to the point-and-click method - keeping the button pressed is intuitive enough, and the game has a rich environment which means it's always easy to find objects to interact with when I'm not moving towards the edge of the screen. I did have minor navigation problems (most notably, it was a bit painful to reach the front door from the outside), but on the other hand, I was able to assume my usual ultra-comfortable adventure gaming position, and it is more than worth a few minor troubles :D

    @Derrick said: I do have thoughts on how TTG could do the mouse control, but I don't beleive they care. They have made up their minds and will not change.

    To be honest, I quite understand them. They had to come up with a control scheme that fits both the XBox and the PC, and the way the scenes are shot, a direct control approach certainly seems more obvious.
    As for not offering a secondary, mouse based control scheme: I'd do the same in their place, and would undertake the extra fuss for maintaining a secondary scheme only if the market response would force me to.

  • @Pantagruel's Friend said: I'll try it this or next evening, but I'm quite sure what the result will be - it won't feel natural to me. The exact reason why I liked your original script (modded to the left button) is that it's very close to the point-and-click method - keeping the button pressed is intuitive enough

    I just updated the script, hopefully for the last time.

    You can now select to use the left/right mouse button for either of the 2 movement types.

    You can now also easily change the episode number. Or even use the demo. It will find the game path from the registry.

    The first post in this thread has been updated with all the info.

    Also... Could someone tell me if the script downloads corrupted for them? Ever since I modified the first post, it now seems to pad the file with a few extra bytes at the beginning, corrupting the file.

  • @Derrick said: I just updated the script, hopefully for the last time.

    You can now select to use the left/right mouse button for either of the 2 movement types.

    You can now also easily change the episode number. Or even use the demo. It will find the game path from the registry.

    The first post in this thread has been updated with all the info.

    Also... Could someone tell me if the script downloads corrupted for them? Ever since I modified the first post, it now seems to pad the file with a few extra bytes at the beginning, corrupting the file.

    I'll try it - now with The Last Resort :)
    The file download works fine for me, there's no corruption!

  • Well atm the Keyboard arent working 100% either, quite alot of time, it makes the same problems are people say with this script, that you walk in wrong direction or doesnt move at all.

    So atm no solution is 100%, i would still prefer the mouse, i must say, im not gonna buy another season if the control scheme doesnt change. Just ruins the game for me. :(

    Atleast this script will make Season 1 work for me.

  • Cool beans.

    I've never used AutoHotKey before. How does the "screen edge" stuff cope with the game in windowed mode, or with multiple monitors?

  • @Pantagruel's Friend said: I'll try it - now with The Last Resort :)
    The file download works fine for me, there's no corruption!

    OK, I tried the mouse movement solution - it works pretty well, but as I predicted, it's not my automatic choice for movement. It's nice however when the edge detection has difficulties.

    Good stuff! :)

  • @[TTG said: Yare;124357']Cool beans.

    Thanks for trying it out. I found myself using Movement Method 2 mostly.

    @[TTG said: Yare;124357']I've never used AutoHotKey before. How does the "screen edge" stuff cope with the game in windowed mode, or with multiple monitors?

    I just started playing with AutoHotkey myself. I've used it for a few keystroke macros in the past, but this is the first fancy thing I've used it for.

    First let me mention my goal is not to diss TTG's design decision. You guys have been playing with the new controls longer then us and have probably got used to them. For me I could not get past the issue long enough to play. Even after re-mapping my joystick. It worked great with a joystick, but then I missed how easy it is to select on-screen items with the mouse.

    The only way I could play the game long enough to enjoy it was to write this script. And for better or worse, I thought I would share it.

    Anyways....
    I did not attempt, or even thought about making this script compatible with either Windowed mode or Multi-Monitors. But as I am really just hacking into the mouse movement, anything other then full screen would be a pain to do. While I'm trying to work out something, here are some thoughts:

    Windowed Mode:
    Currently you have the mouse get sticky when you move to the top of the window. You have to move the mouse harder to get it out of the view window. Very nice and that makes it easy to click for movement on the top edge. Unfortunately the same is not true for the other 3 sides. Actually the bottom is sticky in game but not when the menu panel is on-screen.

    I could probably force the mouse to be a bit sticky myself. But for the sake of argument, here is how I would handle it if it was coded in the game.

    First, when in windowed mode, I would get rid of the resolution selection and just make the window resizeable. It would be a fixed 16:9 resize, that way there is no black area like when you use 800x600 windowed. Now the edges of the view are defined by the program window. Then we make the mouse sticky when it is in the window on all four edges. Probably even a bit stickier then you have it set at the top now. This would make it so you can easily click at the edge of the window for movement.

    Of course if it was programed in game, you could easily use the left mouse button. If the edges are clicked and pressed, it would ignore any selectable item. But with the script, all I can do is recommend to use the right button so items are not triggered.

    From a script POV based on the current game workings, I would have to calculate the aspect ratio, fudge up some data and do a best guess where the game view window is. Then make it sticky to that.

    Multi-Monitor Mode: would probably be easier to do. But I have no way of testing it. To be honest, I have never even tried the script in a mode other then 16:9. So I will have to try that after dinner and a trip to the last resort.

    Movement Mode 1. Just some thoughts how this would work if used in a future game. The cursor would change to the arrow of the direction at the edge of the screen acknowledging you will be pressing the button for movement. Obviously in game code it would be easy to ignore selecting on-screen items while moving with the left mouse button pressed.

    Movement Mode 2. Just like mode 1, but you could draw an arrow in the movement box that follows the 8 directions. The neat thing about this movement mode is that if you drag left for instance, and W/G moves left in the current view, then the screen changes and he is moving down the screen, as long as you don't move the mouse, W&G will keep moving in the original direction. At that point any future game code can change the direction of the on-screen arrow, move the the mouse position in the movement box to compensate and things will remain smooth.

    Well, enough rambling for now.

  • @Pantagruel's Friend said: OK, I tried the mouse movement solution - it works pretty well, but as I predicted, it's not my automatic choice for movement. It's nice however when the edge detection has difficulties.

    Thanks for trying and giving feedback.

    FWIW, I have not had any selection problems with the edge movement. I know in Ep1 when you are in the front yard trying to go to the front door, it can be tricky to get to. But I had the same problems with the keyboard and joystick. Remember, you can always click on the corners for diagonals. Also like I mentioned, there can be problems with using the left button for moving due to it activating any selectable items during movement. Which is why I use the right button. I do tend to use the left for edge movement because that seems more natural after years playing adventure games. But my brain is surprisingly happy with the right button for the new Movement Mode 2.

    Just out of curiosity, what video resolution are you using? I have only tried 16:9 modes. I imagine you are not trying a windowed mode. I never even thought about that until [TTG] Yare mentioned it.

    EDIT: I think I see what you mean. I tried 1024x768 and it seemed harder to select at the bottom. I'll look into adding a border size option to give more selection area.

  • @Pantagruel's Friend said: however when the edge detection has difficulties.

    Try this test version. It compensates for aspect ratios that are not exactly 16x9. Also it seems that even though the mouse looks like it stops at any letter-boxing, it really goes into it. So you can push past the border making the mouse slow to come out of it. I now select the whole area as the movement click.

    There is also a new borderPixels setting that be changed so the mouse does not have to be exactly at the edge.

    EDIT: The top post has been updated to the newest version.

    Here is the script in case the download is corrupt:
    ; Script Function:
    ; Map mouse clicks at the edges of the screen as arrow keys
    ; You can also move by holding down the button and dragging the mouse
    ; The script will time out after 2 minutes if game is not launched


    ; Set this to the W&G episode you want to run with this script
    ; 0 = Demo
    episode := 1

    ; set options to 0=disable 1=enable
    ; Left Button options
    useEdgesL := 1
    useCenterL := 1

    ; Right Button options
    useEdgesR := 1
    useCenterR := 1

    ; how long in milliseconds to press mouse button in center screen before movement is controlled by mouse dragging
    ; left move delay
    buttonDelayL := 150

    ; right move delay
    buttonDelayR := 50

    ; movement box size in pixels
    boxSize := 100

    ; pixels at edge used to select movement
    ; must be 1 to 25
    borderPixels := 5

    ; ==================================
    ; only change values above this line
    ; ==================================

    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
    #SingleInstance ignore ; only allow 1 running script
    SetTitleMatchMode, 3 ; Names must be exact
    CoordMode, Mouse, Screen

    ; check values
    if (borderPixels < 1 OR borderPixels > 25)
    {
    MsgBox, borderPixels value out of range
    ExitApp
    }

    timeDelayL := buttonDelayL // 10
    timeDelayR := buttonDelayR // 10
    movePixels := boxSize // 2
    edgeMargin := movePixels * 2 + borderPixels

    ; setup paths and file
    if (episode = 0)
    {
    gameFile = WallaceGromitDemo.exe
    launcherName = Wallace & Gromit Demo
    }
    else if (episode = 1)
    {
    gameFile = WallaceGromit101.exe
    launcherName = Fright of the Bumblebees
    }
    else if (episode = 2)
    {
    gameFile = WallaceGromit102.exe
    launcherName = The Last Resort
    }
    else if (episode = 3)
    {
    gameFile = WallaceGromit103.exe
    launcherName = Muzzled!
    }
    else if (episode = 4)
    {
    gameFile = WallaceGromit104.exe
    launcherName = The Bogey Man
    }
    else
    {
    MsgBox, Invalid Episode #
    ExitApp
    }
    gameReg = SOFTWARE\Telltale Games\%gameFile%
    RegRead, gameDir, HKEY_LOCAL_MACHINE, %gameReg% , Install Location

    ; this is the name of the game as shown on the task bar
    ; Demo and Ep1 both use the same name, so I assume all episodes will
    gameName = Telltale Games


    ; launch game
    Run, %gameFile%, %gameDir%, UseErrorLevel
    if ErrorLevel = ERROR
    {
    MsgBox, Episode %episode% could not be found
    ExitApp
    }
    winwait, %gameName%, , 120
    Gosub, gameCheck
    WinActivate, %gameName%
    SetTimer, gameCheck
    return


    ; quit script if game is not running
    gameCheck:
    IfWinNotExist, %gameName%
    {
    ExitApp
    }
    return


    ~LButton::
    useEdges := useEdgesL
    useCenter := useCenterL
    timeDelay := timeDelayL
    testButton = LButton
    Gosub, mouseToArrows
    return


    ~RButton::
    useEdges := useEdgesR
    useCenter := useCenterR
    timeDelay := timeDelayR
    testButton = RButton
    Gosub, mouseToArrows
    return


    mouseToArrows:
    timePressed := 0
    usingCenterMove := 0
    border := borderPixels
    ; This would be how you get the multi-screen size
    ; but the values seem to change
    ;SysGet, screenWidth, 78
    ;SysGet, screenHeight, 79

    ; check aspect ratio and adjust
    if (A_ScreenWidth * 9 // A_ScreenHeight < 16)
    {
    ; top and bottom letterboxed
    newHeight := A_ScreenWidth * 9 // 16
    edgeUp := (A_ScreenHeight - newHeight) // 2
    edgeDown := edgeUp + newHeight
    edgeLeft := 0
    edgeRight := A_ScreenWidth

    }
    else
    {
    ; sides letterboxed
    newWidth := A_ScreenHeight * 16 // 9
    edgeLeft := (A_ScreenWidth - newWidth) // 2
    edgeRight := edgeLeft + newWidth
    edgeUp := 0
    edgeDown := A_ScreenHeight
    }

    ; bottom corner is one pixel in
    edgeRight--
    edgeDown--

    While GetKeyState(testButton)
    {
    MouseGetPos, curX, curY

    if (useEdges = 1 OR usingCenterMove = 1)
    {
    if (curX < edgeLeft + border)
    {
    downL := 1
    Send {Left Down}
    }
    else
    {
    if (downL = 1)
    {
    Send {Left Up}
    }
    downL := 0
    }

    if (curX > edgeRight - border)
    {
    downR := 1
    Send {Right Down}
    }
    else
    {
    if (downR = 1)
    {
    Send {Right Up}
    }
    downR := 0
    }

    if (curY < edgeUp + border)
    {
    downU := 1
    Send {Up Down}
    }
    else
    {
    if (downU = 1)
    {
    Send {Up Up}
    }
    downU := 0
    }

    if (curY > edgeDown - border)
    {
    downD := 1
    Send {Down Down}
    }
    else
    {
    if (downD = 1)
    {
    Send {Down Up}
    }
    downD := 0
    }
    }

    if (useCenter = 1 AND usingCenterMove = 0)
    {
    ; start counting if in center of screen
    if (curX > edgeLeft + edgeMargin AND curX < edgeRight - edgeMargin AND curY > edgeUp + edgeMargin AND curY < edgeDown - edgeMargin)
    {
    timePressed++
    if (timePressed > timeDelay)
    {
    ; button down long enough, start using center move
    edgeLeft := curX - movePixels
    edgeUp := curY - movePixels
    edgeRight := curX + movePixels
    edgeDown := curY + movePixels
    border := 1
    VarSetCapacity(R, 16, 0), NumPut(edgeLeft, &R+0), NumPut(edgeUp, &R+4), NumPut(edgeRight+1, &R+8), NumPut(edgeDown+1, &R+12)
    DllCall( \"ClipCursor\", UInt, &R )
    usingCenterMove := 1
    }
    }
    else
    {
    ; reset count when not in center
    timePressed := 0
    }
    }
    Sleep, 10
    }

    if (usingCenterMove = 1)
    {
    ; free the cursor
    DllCall( \"ClipCursor\")
    }

    ; unpress any keys that are down
    if (downL = 1)
    {
    Send {Left Up}
    }
    downL := 0
    if (downR = 1)
    {
    Send {Right Up}
    }
    downR := 0
    if (downU = 1)
    {
    Send {Up Up}
    }
    downU := 0
    if (downD = 1)
    {
    Send {Down Up}
    }
    downD := 0
    return

  • @Derrick said: Try this test version. It compensates for aspect ratios that are not exactly 16x9. Also it seems that even though the mouse looks like it stops at any letter-boxing, it really goes into it. So you can push past the border making the mouse slow to come out of it. I now select the whole area as the movement click.

    Hmmm, interesting. You got the problem right - I was playing at 1280x1024. The aspect ratio problem did cross my mind, but I thought then I wouldn't be able to move towards the Y-edges at all, and dissed the idea :)

    I'll try the new version after work.

    Cheers!

Add Comment