AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single-key toggle doesn't work in game

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
badmojo



Joined: 11 Nov 2005
Posts: 150

PostPosted: Mon Apr 28, 2008 2:22 am    Post subject: Single-key toggle doesn't work in game Reply with quote

i'm trying to use AHK to toggle 'walk' and 'run' mode in a game. the idea is when i press a key, it will auto-repeat itself until i press the same key to make it stop. but somehow it doesn't work even though it works on notepad, etc. can someone suggest what i need to do differently in order to get it working?

Code:
; "Always Run" mode
; Send shift+w continuously while 'r' key is pressed
; Press 'w' to stop
$r::
Loop
{
Send, {Shift Down}{w down}
Sleep 250
If !GetKeyState("w", "U")
  {
  Send, {Shift Up}
  Break
  }
}
Return

the above code works fine but since i'm trying to use a single key for both actions, i'm trying this code below which i "borrowed" from here only functions with Notepad, etc but not inside the game. am i missing something?

Code:
#MaxThreadsPerHotkey 2
$r::
PressKey := ! PressKey   ;Toggle PressKey True/False
Loop
{   If ! PressKey
      Break         ;If PressKey is False, stop pressing key
   Send +{w}
   Sleep 250      ;Delay between keypresses
}
Return
#MaxThreadsPerHotkey 1
Back to top
View user's profile Send private message
badmojo



Joined: 11 Nov 2005
Posts: 150

PostPosted: Mon Apr 28, 2008 12:00 pm    Post subject: Reply with quote

btw, the game i'm playing is Lost: via Domus and being a console port the controls are not as sleek as i would like to be. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group