Hello everyone, just came across the AHK program in my search for mouse support for Resident Evil 4 for the PC. The game by default (ver. 1.1 US rel) has no mouse support, nor is there an available patch for it. It does, however, function with aiming via an analog joystick or using the arrow keys to aim.
My question is if the AutoHotKey program can allow the mapping of the joystick analog movement or the regular arrow keys to direct mouse movement? This would allow a hot fix of sorts to be able to aim in Resident Evil 4 the same as in any FPS game.
So far I've tried the following script, but with no luck:
MouseMove, 0, -10, 0, R::up
MouseMove, 0, 10, 0, R::down
MouseMove, -10, 0, 0, R::left
MouseMove, 10, 0, 0, R::right
The script does function backwards, allowing my arrow keys to navigate the mouse cursor. Unfortunately though, that is the opposite of what I'm looking for.
Any help is greatly appreciated. Thanks.
![Photo](https://secure.gravatar.com/avatar/e6dfa0b7780b47f09ad319be4fadac7c?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
Analog Joystick or Arrow Keys to Mouse Movement? for RE4
Started by
Tw1tch
, Jun 25 2007 07:29 AM
11 replies to this topic
#1
-
Posted 25 June 2007 - 07:29 AM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
:: is a hotkey identifier, you can't have a command like MouseMove to the left of it.
This sort of works, but I don't have a game to test it on... Hit F6 to make it start and Escape to make it stop, since it otherwise takes over your mouse. You also need to fill in the program name (multiple AddGroup lines are allowed if you want it for more than one program)
This sort of works, but I don't have a game to test it on... Hit F6 to make it start and Escape to make it stop, since it otherwise takes over your mouse. You also need to fill in the program name (multiple AddGroup lines are allowed if you want it for more than one program)
#persistent #singleInstance force CoordMode, Pixel, Mouse GroupAdd, MyGroup, PUT PROGRAM NAME HERE homeX = 300 homeY = 300 return F6:: Settimer, checkmouse, 100 return checkmouse: IfWinActive, ahk_group MyGroup { MouseGetPos, curX, curY If (curX-homeX > 5) Send {right} If (curX-homeX < -5) Send {left} If (curY-homeY > 5) Send {down} If (curY-homeY < -5) Send {up} MouseMove, %homeX%, %homeY% , 0 ;tooltip, % prevX . " " . curX . " " . prevY . " " . curY, 20,20 } eturn Esc::ExitApp
#2
-
Posted 25 June 2007 - 03:37 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thanks for the help, although it doesn't work for me. The only error in the code I could find was the "eturn" which I changed to "return". Otherwise the scripting for this is a bit out of my league, so Im not sure where to go.
I tried the standard script you wrote which I couldnt get to work. Then I tried to do away with the on/off-F6/Escape and still no dice. I tried the program name "notepad" and also the RE4 .exe. I took it one step further and tried to use it on all of Windows, using "GroupAdd, AllWindows", and still nothing.
I'll try and think of something else, and thanks again.
I tried the standard script you wrote which I couldnt get to work. Then I tried to do away with the on/off-F6/Escape and still no dice. I tried the program name "notepad" and also the RE4 .exe. I took it one step further and tried to use it on all of Windows, using "GroupAdd, AllWindows", and still nothing.
I'll try and think of something else, and thanks again.
#3
-
Posted 26 June 2007 - 05:30 AM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
The "program name" should actually be the window name (i.e. "Untitled - Notepad" instead of "notepad".) By default, "notepad" will match any windows with titles starting with "notepad". (Look up SetTitleMatchMode in the help file.)
The script seems to work in notepad if I replace
I assume where engunneer wrote
Strangely, the Esc::ExitApp hotkey doesn't work for me... If I press Escape, the script only exits after I press Ctrl+Alt+Delete. :?
The script seems to work in notepad if I replace
GroupAdd, MyGroup, PUT PROGRAM NAME HEREwith
GroupAdd, MyGroup, ahk_class Notepad("ahk_class notepad" matches all notepad windows, regardless of title.)
I assume where engunneer wrote
CoordMode, Pixel, Mousehe actually meant
CoordMode, Mouse, Screento make the MouseGetPos and MouseMove coords relative to the screen rather than the active window.
Strangely, the Esc::ExitApp hotkey doesn't work for me... If I press Escape, the script only exits after I press Ctrl+Alt+Delete. :?
#4
-
Posted 26 June 2007 - 11:43 AM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
hmmm... I don't think re4 is taking what Autohotkey is sending. I got a modified version of the posted script to work in the normal windows (notebook, etc) but re4 wont accept the Send. I tried various sends... sendraw, sendinput, etc and none of them were accepted. Re4 can handle remapped keys so I can set f8::a and what's-his-face turns left when I hit f8. That's no help.
Will play some more but, even if it accepts these sends, it's still not a real PC mouse input. Shooters that use the mouse accept a fast swipe as turning quickly and a slow swipe as careful aiming. RE4 will only take "turn left" at one speed.
I just hope Capcom gets their head out of their you know what and posts a patch.
Will play some more but, even if it accepts these sends, it's still not a real PC mouse input. Shooters that use the mouse accept a fast swipe as turning quickly and a slow swipe as careful aiming. RE4 will only take "turn left" at one speed.
I just hope Capcom gets their head out of their you know what and posts a patch.
#5
-
Posted 05 July 2007 - 01:57 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
[quote name="whygnat"]hmmm... I don't think re4 is taking what Autohotkey is sending. I got a modified version of the posted script to work in the normal windows (notebook, etc) but re4 wont accept the Send. I tried various sends... sendraw, sendinput, etc and none of them were accepted. Re4 can handle remapped keys so I can set f8::a and what's-his-face turns left when I hit f8. That's no help.[/quote]
If F8::a works, send should also work.
[quote name="help]When a script is launched, each remapping is translated into a pair of hotkeys. For example, a script containing a::b actually contains the following two hotkeys instead:
If you're simply sending keypresses (i.e. Send {Left}), you probably need to add a delay; like:
If F8::a works, send should also work.
[quote name="help]When a script is launched, each remapping is translated into a pair of hotkeys. For example, a script containing a::b actually contains the following two hotkeys instead:
*a:: SetKeyDelay -1 ; If the destination key is a mouse button, SetMouseDelay is used instead. Send {Blind}{b DownTemp} ; DownTemp is like Down except that other Send commands in the script won't assume "b" should stay down during their Send. return *a up:: SetKeyDelay -1 ; See note below for why press-duration is not specified with either of these SetKeyDelays. Send {Blind}{b Up} return[/quote]
If you're simply sending keypresses (i.e. Send {Left}), you probably need to add a delay; like:
Send {Left Down} Sleep, 50 ; may need adjustment Send {Left Up}This is because many games poll for input only once per game loop/frame. If it runs at 30 frames per second, that's rougly every 33 milliseconds (1/30). The problem with the above code is that the sleep may reduce the responsiveness of your script, so timers might work better:
Send {Left Down} SetTimer, LeftUp, -50 ; execute once in 50 ms return LeftUp: Send {Left Up} return[quote]even if it accepts these sends, it's still not a real PC mouse input. Shooters that use the mouse accept a fast swipe as turning quickly and a slow swipe as careful aiming. RE4 will only take "turn left" at one speed.[/quote]Too right. If RE4 accepts analog joystick input for aiming, you could try PPJoy, which is able to emulate one or more joysticks. Specifically, look for Supported interfaces -> Virtual joysticks -> PPJoyMouse in the side-menu. (You'll need to install PPJoy and configure a virtual joystick before using PPJoyMouse.)
#6
-
Posted 05 July 2007 - 11:27 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thanks for the insights, lexikos. I've done some stuff with AHK but it eludes me at times when operating games and such. The lexikos method with the timer sort of works but it's pretty herky-jerky... even tweaking the timings, the guy studder turns.
What was closer was to just keeping the key down until the mouse stopped moving. But that horks the other keyboard commands and I'll have to look into that.
On the whole, I'm even more inclined to think it's fruitless because:
a) RE4s up/down aim view does not stay put but self homes.
the a/d keys are turn left/right and not strafe.
I'll check PPJoy next.
For the record, here's the code I came up with but messes up other key commands:
What was closer was to just keeping the key down until the mouse stopped moving. But that horks the other keyboard commands and I'll have to look into that.
On the whole, I'm even more inclined to think it's fruitless because:
a) RE4s up/down aim view does not stay put but self homes.
![B)](http://www.autohotkey.com/board/public/style_emoticons/default/cool.png)
I'll check PPJoy next.
For the record, here's the code I came up with but messes up other key commands:
#persistent #singleInstance force CoordMode, Pixel, Mouse homeX = 300 homeY = 300 fLeft = false fRight = false fUp = false fDown = false return F6:: Settimer, checkmouse, 100 return checkmouse: MouseGetPos, curX, curY If (curX-homeX > 5) { fRight = true Send {d Down} } else if (fRight) { fRight = false Send {d up} } If (curX-homeX < -5) { fLeft = true Send {a Down} } else if (fLeft) { fLeft = false Send {a up} } If (curY-homeY > 15) { fDown = true Send {Down Down} } else if (fDown) { fDown = false Send {Down up} } If (curY-homeY < -15) { fUp = true Send {Up Down} } else if (fUp) { fUp = false Send {Up up} } MouseMove, %homeX%, %homeY% , 0 return F7::Settimer, checkmouse, off F8::ExitApp
#7
-
Posted 06 July 2007 - 01:52 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
The only problem I can see is that while the mouse is moving, the script "releases" the modifier keys. This is because:[*:2s27lf3v]it repeatedly sends {a/d/Down/Up Down}, even if the key is already down; andBut that horks the other keyboard commands and I'll have to look into that.
[*:2s27lf3v]Send causes the modifier keys to be "released."I suggest:
if (fRight != (curX-homeX > 5)) { fRight := !fRight Send % "{Blind}{d " . (fRight ? "Down}" : "Up}") }This compacts the code, doesn't send repeated key-down events, and doesn't interfere with the modifier keys. (The ?: ternary operator requires AHK v1.0.46+.)
One last thing:When {Blind} is the first item in the string, the program avoids releasing Alt/Control/Shift/Win if they started out in the down position. For example, the hotkey +s::Send {Blind}abc would send ABC rather than abc because the user is holding down the Shift key.
b = false if (b) MsgBox, The string "false" evaluates to true.Either of the following is acceptable:
b := false ; in an expression, 'false' = 0 b = 0
#8
-
Posted 07 July 2007 - 12:26 AM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
That's pretty good stuff... thanks! I didn't know ahk went ternary cause I really need to check the new stuff. Next I'll add the left mouse button sending 'e' and rearrange the keys a bit and it should be good.
I'll post what I have but probably not for a week due to a trip. Just wanted to say thanks for the help and quick replies.
I'll post what I have but probably not for a week due to a trip. Just wanted to say thanks for the help and quick replies.
#9
-
Posted 07 July 2007 - 04:54 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
is it possible to add in whygnat's version of script one more term?
i mean some thing like this:
GetKeyState(RButton, P)
If (state = 0 and curX-homeX ...)
{
start F6 action
}
else (If state = 1)
{
start F7 sction
}
i tried many ways, but can't do it right...
i mean some thing like this:
GetKeyState(RButton, P)
If (state = 0 and curX-homeX ...)
{
start F6 action
}
else (If state = 1)
{
start F7 sction
}
i tried many ways, but can't do it right...
#10
-
Posted 04 February 2011 - 11:58 AM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #10](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Well, that's not quite how you use GetKeyState:
state := GetKeyState("RButton", "P") If (state = false && curX-homeX ...) { ; start F6 action } Else If ( state = true ) { ; start F7 sction }
#11
-
Posted 04 February 2011 - 01:20 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #11](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
My code is written for AHK Basic unless otherwise specified. This means it may not work in AHK_L (especially Unicode), due to a few known compatibility issues.
hmmm, second noob question:
how to design "start F6 action" and "start F7 action" so that F6,F7 pressing automatically?
maybe add "Send {F6,F7}"...
plz give me full script, because im really noob in AHK syntax.
thx for answer!
how to design "start F6 action" and "start F7 action" so that F6,F7 pressing automatically?
maybe add "Send {F6,F7}"...
plz give me full script, because im really noob in AHK syntax.
thx for answer!
#12
-
Posted 04 February 2011 - 05:18 PM
![Analog Joystick or Arrow Keys to Mouse Movement? for RE4: post #12](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)