AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: March 8th, 2010, 2:27 am 
maxkill wrote:
Lanser wrote:
Hmmn not sure why it isn't working for you know, I had setup a crouch toggle method for BF2 and it still works in BF2142, initially I was using the toggle on/off method but I decided the default Crouch operation became handy in BF2 as well. So instead my method acts normal when I press and hold 'Ctrl' but if I double tap within a specified time window a loop is run to press and hold Ctrl, simply press and release Ctrl again to break out of Crouch. Maybe you could adapt it to your purposes. I've already posted this some time back in the main BF2 thread ...

Quote:
~LCtrl up:: ;use LCtrl "up" so it doesn't get triggered when you hold ctrl
Goto, Crouch

Crouch:
; Changed: Trigger was changed to "~LCtrl" as ~ allows normal operation of key.
If (a_tickCount-lasttime < 400) ;Check when we released ctrl the last time if < 400ms initiate Crouch
{
Loop
{
Send, {LCtrl down} ; Initiate 'Crouch'
If IsKeyPressed("LCtrl") ; Check if 'LCtrl' pressed. If pressed & released, Break loop.
Send, {LCtrl up} ; Release 'Crouch'
Break
}
}
lasttime:=a_tickCount
Return

IsKeyPressed(v_KeyName)
; Returns 1 if %v_KeyName% is currently being pressed, otherwise 0
{
GetKeyState, state, %v_KeyName%, P
If state = D ; The key has been pressed
{
Return 1
}
Return 0
}

This works perfectly
I'm gonna use it every time now, thanks.

Btw is there a way to have one normal crouch button and another button for this script with toggle crouch? (not neccassary but would be nice)

Sure, have another section that simply sends the normal key up/down on the other key:

Code:
~*X::
 Send, {<crouch_key>}
return
[/code]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 3:14 am 
Garbledygook wrote:
Sure, have another section that simply sends the normal key up/down on the other key:

Code:
~*X::
 Send, {<crouch_key>}
return
[/code]

You mean like this?

Code:
~LAlt up:: ;use LAlt "up" so it doesn't get triggered when you hold ctrl
Goto, Crouch

Crouch:
; Changed: Trigger was changed to "~LAlt" as ~ allows normal operation of key.
If (a_tickCount-lasttime < 400) ;Check when we released ctrl the last time if < 400ms initiate Crouch
{
Loop
{
Send, {LAlt down} ; Initiate 'Crouch'
If IsKeyPressed("LAlt") ; Check if 'LAlt' pressed. If pressed & released, Break loop.
Send, {LAlt up} ; Release 'Crouch'
Break
}
}
lasttime:=a_tickCount
Return

IsKeyPressed(v_KeyName)
; Returns 1 if %v_KeyName% is currently being pressed, otherwise 0
{
GetKeyState, state, %v_KeyName%, P
If state = D ; The key has been pressed
{
Return 1
}
Return 0
}

~*X::
 Send, {LCtrl}
return

Sorry for being a pain in the ass but:

Now, what I would like is one button pressing once for toggle crouch and if you press that toggle crouch again you stand up. Then if you are in toggle crouch and press the normal crouch button (not toggle) you also stand up. The the normal crouch button should disable the toggle crouch button.

Also you don't need 2 taps for toggle crouch when you have one for normal crouch and another one for toggle crouch.

Is this what the script will do now or do I have to change it again?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 2:58 pm 
Offline

Joined: March 8th, 2010, 2:28 am
Posts: 11
maxkill wrote:
Garbledygook wrote:
Sure, have another section that simply sends the normal key up/down on the other key:

Code:
~*X::
 Send, {<crouch_key>}
return
[/code]

You mean like this?

Code:
~LAlt up:: ;use LAlt "up" so it doesn't get triggered when you hold ctrl
Goto, Crouch

Crouch:
; Changed: Trigger was changed to "~LAlt" as ~ allows normal operation of key.
If (a_tickCount-lasttime < 400) ;Check when we released ctrl the last time if < 400ms initiate Crouch
{
Loop
{
Send, {LAlt down} ; Initiate 'Crouch'
If IsKeyPressed("LAlt") ; Check if 'LAlt' pressed. If pressed & released, Break loop.
Send, {LAlt up} ; Release 'Crouch'
Break
}
}
lasttime:=a_tickCount
Return

IsKeyPressed(v_KeyName)
; Returns 1 if %v_KeyName% is currently being pressed, otherwise 0
{
GetKeyState, state, %v_KeyName%, P
If state = D ; The key has been pressed
{
Return 1
}
Return 0
}

~*X::
 Send, {LCtrl}
return

Sorry for being a pain in the ass but:

Now, what I would like is one button pressing once for toggle crouch and if you press that toggle crouch again you stand up. Then if you are in toggle crouch and press the normal crouch button (not toggle) you also stand up. The the normal crouch button should disable the toggle crouch button.

Also you don't need 2 taps for toggle crouch when you have one for normal crouch and another one for toggle crouch.

Is this what the script will do now or do I have to change it again?

You'll have to forgive me, but I try to keep my scripts pretty simple since I'm still learning the language.

for me, it's much easier to just bind those functions in-game to keys I would not normally press so that I can have it function in multiple ways.

Look for my last response:
http://www.autohotkey.com/forum/viewtopic.php?t=55411


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, Google Feedfetcher, HotkeyStick, krajan, Yahoo [Bot] and 30 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