AutoHotkey Community

It is currently May 26th, 2012, 8:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Looping a key while...
PostPosted: August 26th, 2009, 5:14 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 5:15 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 5:22 pm 
A_ThisHotkey + InStr() + StringSplit + If ...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 5:37 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 5:58 pm 
Is there no way to include mouse buttons in something like this?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 6:46 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Sure ;)
Try pressing Capslock and RButton + Moving Mouse :D
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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, joetazz, Leef_me, Mickers, tidbit, tomoe_uehara and 63 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