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 

Hotkeys without any keys inbetween

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



Joined: 15 Jun 2008
Posts: 10

PostPosted: Thu Jun 26, 2008 10:12 pm    Post subject: Hotkeys without any keys inbetween Reply with quote

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
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 458

PostPosted: Fri Jun 27, 2008 5:09 pm    Post subject: Reply with quote

Code:
LShift & RShift up::
RShift & LShift up::
Send, {Blind}{Capslock}
Return
Back to top
View user's profile Send private message
xmav000



Joined: 15 Jun 2008
Posts: 10

PostPosted: Fri Jun 27, 2008 9:06 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
k3ph



Joined: 21 Jul 2006
Posts: 123

PostPosted: Fri Jun 27, 2008 10:20 pm    Post subject: Reply with quote

"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 ]
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 903
Location: The Interwebs

PostPosted: Fri Jun 27, 2008 11:31 pm    Post subject: Reply with quote

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
}


Very Happy
Back to top
View user's profile Send private message AIM Address
sar
Guest





PostPosted: Sat Jun 28, 2008 8:15 pm    Post subject: Reply with quote

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]
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