AutoHotkey Community

It is currently May 27th, 2012, 1:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: MouseLook mode for BF2
PostPosted: July 18th, 2005, 9:38 pm 
Offline

Joined: July 7th, 2005, 11:13 pm
Posts: 4
If you play BF2, you will be as annoyed as me that it does not support HAT switches in planes & helicopters. So heres a script to do it for you !

Code:
; HatMouse script
; by Dave Derrick.
; Enables Joystick HAT switch to operate MouseLook POV mode
; in various games, e.g. BattleField 2


; Joystick to use
JoystickNumber = 1

; The delay in milliseconds to check state of HAT control
HatDelay = 100

; Amount to move mouse by
MoveBy = 10

; Speed to move mouse at, 0 - 100
MoveSpeed = 10

;MouseLook key
MouseLookOn = {LCTRL Down}
MouseLookOff = {LCTRL Up}

ButtonLeft = 1

#SingleInstance

; define a hotkey that does nothing, to stop script exitting
Hotkey, %JoystickNumber%Joy%ButtonLeft%, ButtonLeft

GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P  ; Joystick has POV control
   SetTimer, HatMouse, %HatDelay%

return  ; End of auto-execute section.

ButtonLeft:
return

HatMouse:
GetKeyState, JoyPOV, %JoystickNumber%JoyPOV
if JoyPOV = -1  ; No angle.
{
   Send %MouseLookOff%
   return
}
else
{
   Send %MouseLookOn%
}
if JoyPOV = 0 ; Up
{
  MouseMove,0,-%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 4500 ; up/right
{
  MouseMove,%MoveBy%,-%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 9000 ; right
{
  MouseMove,%MoveBy%,0,%MoveSpeed%,R
}
else if JoyPOV = 13500 ; right/down
{
  MouseMove,%MoveBy%,%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 18000 ; down
{
  MouseMove,0,%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 22500 ; down/left
{
  MouseMove,-%MoveBy%,%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 27000 ; left
{
  MouseMove,-%MoveBy%,0,%MoveSpeed%,R
}
else if JoyPOV = 31500 ; left/up
{
  MouseMove,-%MoveBy%,-%MoveBy%,%MoveSpeed%,R
}
return


Its my 1st script for AutoHotkeys, so dont be too harsh ;)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Guest
PostPosted: September 4th, 2005, 4:26 pm 
This is something i've been looking for quite a while! But where exactly do i add these lines? Which file should be edited?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 4th, 2005, 5:21 pm 
Offline

Joined: July 7th, 2005, 11:13 pm
Posts: 4
I have a better version of the script, go here -
http://www.milagro.pwp.blueyonder.co.uk ... Mouse.html

Here's how you get it working.
1) Download & Install AutoHotKey.
2) Download & save my script, I save all my scripts to C:\Program Files\Autohotkey\Scripts
3) Right click my script file & select "Compile script" from the pop-up menu.
4) When the compiler finishes, you have a file called HatMouse.exe, just run this & your done !

Any problems, give me a shout.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Good work
PostPosted: December 8th, 2005, 5:49 pm 
Nice work Gungho, I was using JoyToKey to accomplish the same thing. I haven't tried your script yet but intend to try it later.

Would it be possible to only have the POV mode using the hat active when you have a certain Joystick button pressed, say key 6 or 7 for instance. I would prefer the Hat keys default function to be switching between Chase Rear, Chase Front and Fly-by views and only have the POV mode kick in when another button in pressed.

Great work though.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 29th, 2005, 6:55 pm 
Thanks very much for this. me and a buddy were discussing how usefull a HAT controlled POV would be in a plane when chasing someone... glad someone else felt the same way 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2006, 12:27 pm 
can u change the up and down
so that up is down and down is up


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2006, 12:38 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
I guess you have to invert the up/down values of MouseMove in the above script. You can do it yourself.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2006, 12:40 pm 
yer i tryed that and it didnt work, thats y i asked if u could
cos i tryed and didnt work


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2006, 12:45 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Does the original code work?

If it does, you have to invert the sign of the second parameter of the MouseMove commands, e.g.
Code:
MouseMove,%MoveBy%,-%MoveBy%
to
Code:
MouseMove,%MoveBy%,%MoveBy%
and
Code:
MouseMove,%MoveBy%,%MoveBy%
to
Code:
MouseMove,%MoveBy%,-%MoveBy%
regardless of what is in the first parameter

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2006, 12:51 pm 
yer that top code works i just dont know how to get it to work the way im asking,


ps i have no idea what im doing
so asked if someone could make it for me


Report this post
Top
  
Reply with quote  
 Post subject: Problem adding buttons
PostPosted: February 16th, 2006, 12:39 pm 
Offline

Joined: February 16th, 2006, 12:25 pm
Posts: 1
This script is just what I've been looking for since BF2 came out :D Made my life as a heli-pilot so much easier when I actually can keep an eye out for trees, buildings, enemies... Thank you 8)

My problem/question is that I would like to add a few functions from other bf2 scripts I've found on this forum but when I do the hat looses all mouselook functions. Since I'm a complete AHK newb I must do something wrong and would love it if someone could help figure it out.

I'm using the script above with this addon at the end.
Code:
; Use Joy4 to report spotted enemies
$Joy4::
   Send, {Q Down}
   Sleep 100
   MouseClick, left, , , , D
   Sleep 100
   MouseClick, left, , , , U
   Sleep 100
   Send, {Q Up}
return

; Use Joy5 to say Sorry for TK
$Joy5::
   Send, {q Down}
   Sleep 100
   MouseMove, 30, 1, , R
   Sleep 100
   MouseClick, left
   Sleep 100
   Send, {q Up}
return

If I combine these script to one file the joystick buttons works as they should but not the hat. If I compile them as two seperate .EXEs both functions work but not as one combined .exe. Could someone help me figure this one out?

/W


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 18th, 2006, 3:59 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
watar wrote:
If I combine these script to one file the joystick buttons works as they should but not the hat.
Generally, your hotkeys should appear beneath the auto-execute section, which is the top part of the script that executes automatically when you launch the script. In this case, it is probably safest to put your joystick hotkeys at the bottom of the script.

For details, see http://www.autohotkey.com/docs/Scripts.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2006, 5:51 am 
i know this is off topic by alot but i have been searching the net for a while and this is the closest forum i have come to for my answer. is there a way that you can asign a key so you can leave a squad in bf2? for example as default 'insert' creates a squad ...is there a way that someone could asign 'end' to leave the squad? is there a way to do it just by editing the controls file in bf2? or can you do it with one of those programs? thanks in advance


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2006, 12:12 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
If the game doesn't have a built-in way to do it, you might be able to do it with a hotkey that sends keystrokes or mouse clicks. For details, see the Hotkeys page and the Quick-start Tutorial.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2006, 12:03 am 
This is a message for watar who post his problem above.

Can you post us a copy of the working script with both the mouse hat trick from above as well as your radio binds working as well,

I sure am interested.

:)

awaiting your soonest response, RickyRayRay


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 20 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