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 

[Help] with script for "loop key"

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



Joined: 28 Dec 2009
Posts: 5

PostPosted: Mon Dec 28, 2009 10:41 pm    Post subject: [Help] with script for "loop key" Reply with quote

hi!
I wanted to create a script witch can do that:
every 5 seconds it presses left ctrl
I tried to create it but 1. it doesnt work in the game i use it and when i press ctrl myself it doesnt work(The normal funktion doesnt work when the script is active)
Thats the code:

Code:
#SingleInstance
gActivateScript = 0


~Insert::
KeyWait, Insert
GetKeyState, InsertState, Insert, T
If InsertState = D
{
    gActivateScript = 1
    Goto, ctrlscript

}
else
{
    gActivateScript = 0

}
return




ctrlscript:
if gActivateScript = 1
{
    Loop
    {
        IfWinActive, Left 4 Dead 2
   {

       LControl::
       Sleep, 5000
       return
        }
        else
        {
            break
        }
    }
   
}
exit

return


what is wrong???
Back to top
View user's profile Send private message
poo_noo



Joined: 08 Dec 2006
Posts: 248
Location: Sydney Australia

PostPosted: Mon Dec 28, 2009 11:08 pm    Post subject: Reply with quote

Code:
LControl::
       Sleep, 5000
       ;return


I think you should remove the RETURN command after the sleep.
_________________
Paul O
Back to top
View user's profile Send private message Visit poster's website
BMGP



Joined: 28 Dec 2009
Posts: 5

PostPosted: Mon Dec 28, 2009 11:12 pm    Post subject: Reply with quote

poo_noo wrote:
Code:
LControl::
       Sleep, 5000
       ;return


I think you should remove the RETURN command after the sleep.


after some time there is a window and it says that there is needed a return^^
Back to top
View user's profile Send private message
poo_noo



Joined: 08 Dec 2006
Posts: 248
Location: Sydney Australia

PostPosted: Tue Dec 29, 2009 2:22 am    Post subject: Reply with quote

sorry I can't test this

Code:
IfWinActive, Left 4 Dead 2
   Loop
      {
      Send LControl
      Sleep 5000
      WinGetTitle, theWindow, A
      If theWindow != Left 4 Dead 2
         Break
      }

_________________
Paul O
Back to top
View user's profile Send private message Visit poster's website
a_h_k



Joined: 02 Feb 2008
Posts: 626

PostPosted: Tue Dec 29, 2009 7:05 am    Post subject: Reply with quote

Just a few tweaks
Code:
Loop
{
   IfWinActive, Left 4 Dead 2
   {
      Send {LControl}
      Sleep 5000
   }
   Sleep, 100
}
Back to top
View user's profile Send private message Visit poster's website
BMGP



Joined: 28 Dec 2009
Posts: 5

PostPosted: Tue Dec 29, 2009 10:40 am    Post subject: Reply with quote

Hmmmm.. no error at both scripts(the scripts by a_h_k and ) but there is nothing in the game^^ so when i press insert nothing happens(vtrl = crouch...)
When you crouch you must hold the key... is that the error??? maybe the key have to be hold done 1 second and than wait...
if so how can i do this?

HELP!!!!
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 626

PostPosted: Wed Dec 30, 2009 12:42 am    Post subject: Reply with quote

Could you ellaborate a bit more about what you want to happen...
- Press left ctrl key --> crouch
- Press Insert key --> (what do you want Insert key to do?)
- WHY do you want to send left ctrl once every 5 secs?
Back to top
View user's profile Send private message Visit poster's website
BMGP



Joined: 28 Dec 2009
Posts: 5

PostPosted: Fri Jan 01, 2010 4:24 pm    Post subject: Reply with quote

a_h_k wrote:
Could you ellaborate a bit more about what you want to happen...
- Press left ctrl key --> crouch
- Press Insert key --> (what do you want Insert key to do?)
- WHY do you want to send left ctrl once every 5 secs?



^^ when i press insert the "script" is activated...(i would use the script that im not afk.. so every 5 seconds i should crouch one second and then release ctrl again^^)
Back to top
View user's profile Send private message
BMGP



Joined: 28 Dec 2009
Posts: 5

PostPosted: Fri Jan 01, 2010 4:24 pm    Post subject: Reply with quote

a_h_k wrote:
Could you ellaborate a bit more about what you want to happen...
- Press left ctrl key --> crouch
- Press Insert key --> (what do you want Insert key to do?)
- WHY do you want to send left ctrl once every 5 secs?



^^ when i press insert the "script" is activated...(i would use the script that im not afk.. so every 5 seconds i should crouch one second and then release ctrl again^^)
Back to top
View user's profile Send private message
Display posts from previous:   
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