AutoHotkey Community

It is currently May 27th, 2012, 2:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 7th, 2010, 10:57 am 
Hey all,

It took me a while to find something that works, I now have toggle crouch and sprint but was wondering if it could be improved. I have NO idea how to script and just used what other people had.

It works perfectly, I just dont like having 1 key to start the script and the action to be a different key.

This is what ive got:

~*LShift::
GetKeyState, state, LCtrl
if state = U
Send {LCtrl Down}
else
Send {LCtrl Up}
return
~*XButton1::
GetKeyState, state, P
if state = U
Send {P Down}
else
Send {P Up}
return

But I only want to have LShift and XButton1 in there, I dont like how Shift starts the Control toggle and XButton1 starts the P toggle..

Thanks for any assistance, and even if nothing works this will do me fine :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 10:01 am 
Offline

Joined: February 7th, 2010, 11:41 am
Posts: 3
Location: Sydney, Australia
Anyone have any suggestions?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 3:16 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Like this?:
Code:
~*LShift::
GetKeyState, state, Lshift
if state = P
Send {LCtrl Down}
else
Send {LCtrl Up}
return
~*XButton1::
GetKeyState, state, XButton1
if state = P
Send {P Down}
else
Send {P Up}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 3:45 am 
Offline

Joined: February 7th, 2010, 11:41 am
Posts: 3
Location: Sydney, Australia
Hey thanks for replying.

I think I might not of explained myself very well.

What I want to be able to do is press LShift to toggle LShift down then press it again to toggle it up, same for the XButton1.

I would like to be able to remove LCtrl and P from the script if its possible, but no other toggle script I tried seemed to work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 8:32 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Then try to adapt this script to your keys:
Code:
#MaxThreadsPerHotkey 2 ; Need this to allow two key press threads to run at same time
MButton::
Toggle:=!Toggle
While (Toggle)
{
      Send {w down}
      Sleep -1 ;Gibt dem Script die Chance, auf Nachrichten zu reagieren
}
Send {w up}
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 2:54 am 
Offline

Joined: February 24th, 2010, 2:51 am
Posts: 2
just stumbled up on this thread, here's my attempt:

Code:
crouchState:=0
~c::Goto Crouch
~Space::
   if crouchState
      GoSub, Crouch
   return

~w & LShift Up::
   if crouchState
      GoSub, Crouch

   Send {LShift down}
   while GetKeyState("w","P") and not GetKeyState("LShift", "P")
   {
      if crouchState
         break
      sleep 100 ; prevents high cpu usage
   }
   if GetKeyState("LShift")
      Send {LShift up}
   ;SoundBeep
   sleep 125
   return

Crouch:
   if crouchState
      Send {LCtrl up}
   else
      Send {LCtrl down}
   crouchState := !crouchState
   return


http://bunchafunk.googlecode.com/files/crouch_toggle.ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2010, 3:11 pm 
Offline

Joined: March 3rd, 2010, 3:10 pm
Posts: 1
Hi guys.
Your attempt is good, but for me the only thing which is missing is the ability of going ro crouch while sprinting, I've tryed few things but still doesn't work.
Someone can help me ?
Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: This works for l-shift
PostPosted: March 5th, 2010, 1:21 am 
Try something like this, if you tap L - shift 2 times it will toggle it on where it is held down you can hit L- Shift again to turn if off. You can edit this to be another key if you want.


#UseHook
#NoEnv ;
SendMode Input
SetWorkingDir %A_ScriptDir%


~LShift up:: ;use LShift "up" so it doesn't get triggered when you hold LShift
Goto, Sprint

Sprint:
; Changed: Trigger was changed to "~LShift" 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, {LShift down} ; Initiate 'Crouch'
If IsKeyPressed("LShift") ; Check if 'LShift' pressed. If pressed & released, Break loop.
Send, {LShift 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
}


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Bing [Bot], LazyMan, rbrtryn and 23 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