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 

Looping a key while...

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





PostPosted: Wed Aug 26, 2009 4:14 pm    Post subject: Looping a key while... Reply with quote

I'm hoping to achieve this:

If Capslock is held and any other key is held ->
Send "other" key repeatedly with a sleep timer.
Otherwise, do nothing.

Something in this sort of format, but with the two key checks, and the second key being sent instead of LButton. Capslock should not be sent at all, and it's native function disabled.

Code:
Capslock::
Loop
{
If not GetKeyState("Capslock","p")
break
SendEvent, {LButton}
Sleep, 10
}
return
Back to top
Justin
Guest





PostPosted: Wed Aug 26, 2009 4:15 pm    Post subject: Reply with quote

That "other" key must be any key, like a wildcard in the script. Including Mouse Clicks, so if Capslock + RButton is being held then RButton is sent. If Capslock + LButton is being held then LButton must be sent.
Back to top
OMG!
Guest





PostPosted: Wed Aug 26, 2009 4:22 pm    Post subject: Reply with quote

A_ThisHotkey + InStr() + StringSplit + If ...
Back to top
HotKeyIt



Joined: 18 Jun 2008
Posts: 1994
Location: GERMANY

PostPosted: Wed Aug 26, 2009 4:37 pm    Post subject: Reply with quote

Try something like this (does not work for mouse buttons)
Code:
Capslock::
Loop
{
If not GetKeyState("Capslock","p")
   break
Input,v,L1
Send % Chr(1+Asc(v))
Sleep, 10
}
return

CapsLock Up::
Input
Return

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
Justin
Guest





PostPosted: Wed Aug 26, 2009 4:58 pm    Post subject: Reply with quote

Is there no way to include mouse buttons in something like this?
Back to top
HotKeyIt



Joined: 18 Jun 2008
Posts: 1994
Location: GERMANY

PostPosted: Wed Aug 26, 2009 5:46 pm    Post subject: Reply with quote

Sure Wink
Try pressing Capslock and RButton + Moving Mouse Very Happy
Code:
Capslock::
Loop
{
   If not GetKeyState("Capslock","p")
      break
   Input,v,L1
   If (ErrorLevel="NewInput"){
      if (break and (!break:=0))
         break
      else {
         Loop {
            If GetKeyState("LButton","P")
               Send {LButton}
            else If GetKeyState("RButton","P")
               Send {RButton}
            else
               break
            Sleep, 10
         }
      }
   }
   Send % Chr(1+Asc(v))
   Sleep, 10
}
return

CapsLock Up::
break=1
Input
Return
~LButton::
~RButton::
Input
Return

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
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