AutoHotkey Community

It is currently May 26th, 2012, 8:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: June 26th, 2008, 10:12 pm 
Offline

Joined: June 15th, 2008, 3:46 am
Posts: 10
Hi,
I would like to turn Capslock on/off iff both Shift keys are pressed and no other key is pressed inbetween.

{RShift down} {LShift down} {RShift up} {LShift up} -> Capslock
{RShift down} {LShift down} {LShift up} {RShift up} -> Capslock
Of course the mirrored versions too.

But I dont want Capslock here:
{RShift down} {a} {LShift down} {RShift up} {LShift up} -> no Lock
{RShift down} {LShift down} {a} {RShift up} {LShift up} -> no Lock
{RShift down} {LShift down} {RShift up} {a} {LShift up} -> no Lock
({a} is the a-key but stands here for just any other key)

With the following code I get the Capslock but the cases I don't want it still give Capslock.

Code:
LShift & RShift up::   
      if GetKeyState("CapsLock","T")
      {
         setcapslockstate, off
      }
      else
      {
         setcapslockstate, on
      }
return

RShift & LShift up::
      if GetKeyState("CapsLock","T")
      {
         setcapslockstate, off
      }
      else
      {
         setcapslockstate, on
      }
return


seems to me like a tough question, but maybe you have some easy way for this.
ciao
xmav000


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2008, 5:09 pm 
Offline

Joined: February 18th, 2008, 8:26 pm
Posts: 442
Code:
LShift & RShift up::
RShift & LShift up::
Send, {Blind}{Capslock}
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2008, 9:06 pm 
Offline

Joined: June 15th, 2008, 3:46 am
Posts: 10
Code:
/*
*  This only works with the two characters j and f "in between" but i want a solution for *anything*
*/

keypressed := 0
RShiftPressed :=0
LShiftPressed :=0


*RShift up::
   if (LShiftPressed) {
    if (GetKeyState("LShift","P")) {
        ; ignore
    } else {
       ; now the other Shift was released earlier
       if (keyPressed) {
        keyPressed := 0
      } else {
           ; nothing inbetween
           send {blind} {capslock}
         RShiftPressed := 0
         LShiftPressed := 0 
      }
    }   
  } else {
    RShiftPressed = 0
    keypressed := 0   
  }
return

*~RShift::
   if (LShiftPressed) {
    ; ignore
  } else {
    keypressed := 0   
  }
  RShiftPressed := 1
return


*LShift up::
   if (RShiftPressed) {
    if (GetKeyState("RShift","P")) {
        ; ignore
    } else {
       ; now the other Shift was released earlier
       if (keyPressed) {
        keyPressed := 0
      } else {
           ; nothing inbetween
        send {blind} {capslock}
        RShiftPressed := 0
        LShiftPressed := 0 
      }
    }   
  } else {
    LShiftPressed = 0
    keypressed := 0   
  }
return

*~LShift::
   if (RShiftPressed) {
       ; ignore
  } else {
    keypressed := 0   
  }
  LShiftPressed := 1
return


*f::
  keypressed := 1
  send {blind}f
return

*j::
  keypressed := 1
  send {blind}j
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2008, 10:20 pm 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
"J and F" -> all keys:

Code:
keylist := "abcdefghijklmnopqrstuvwxyz1234567890-=´[]~;/`,`.'"
StringReplace, keylist, keylist, `n, , All
StringSplit, keylist, keylist
Loop, %keylist0%
{
   key := keylist%a_index%
   hotkey, %key%, pressedkey, on
}

pressedkey:
   keypressed := 1
   key := % SubStr(A_ThisHotkey, 0)
   send {blind}%key%
   /* for testing purposes
   if (key != "") {
      msgbox %key%
   }
   */
return

_________________
                                  [ profile | ahk.net | ahk.talk ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2008, 11:31 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Code:
Loop, Parse, %keylist%
Hotkey, %A_LoopField%, pressedkey, on


is shorter than

Code:
StringSplit, keylist, keylist
Loop, %keylist0%
{
   key := keylist%a_index%
   hotkey, %key%, pressedkey, on
}


:D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2008, 8:15 pm 
The following should also work: make all keys regular hotkeys resembling themselves
Code:
~a::
~b::
~LShift::
~RShift::
   return

then in the double shift routine check for previous hotkey
Code:
LShift & RShift Down::
RShift & LShift Down::
    if( %A_PriorHotkey contains Shift )
        send {capslock}
    return

[/code]


Report this post
Top
  
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: poserpro, RaptorX, sjc1000 and 58 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