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 a script

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





PostPosted: Thu Jul 05, 2007 2:25 am    Post subject: Help with a script Reply with quote

Hi, I need help with a script that spams the F1 key. So far I have

Code:
*PAUSE::Suspend
return

*F1::
Loop
{
     GetKeyState,state,F1,P
     if state = U
           break

     Send,{F1}
     Sleep,10
}
return


However that only spams it if I hold down F1. Is there any way to have it spam F1 continuously by pressing it once and then stop spamming by pressing it a second time?
Back to top
nick



Joined: 24 Aug 2005
Posts: 345
Location: Berlin / Germany

PostPosted: Thu Jul 05, 2007 7:02 am    Post subject: Reply with quote

Code:
#MaxThreadsPerHotkey 2
$*F1::
_Break := False
If (_F1)
{
   _F1 := False
   _Break := True
   Return
}
_F1 := True
Loop
{
   If (_Break)
   {
      Break
   }
   Send, {F1}
   Sleep, 10
}
Return


$ This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The exact behavior of the $ prefix varies depending on operating system:

On Windows NT4/2k/XP or later: The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey.
_________________
nick

denick @ http://de.autohotkey.com/forum/
Back to top
View user's profile Send private message
dev
Guest





PostPosted: Thu Jul 05, 2007 12:41 pm    Post subject: Reply with quote

Thanks! That works very well Very Happy
Back to top
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