Pressing and releasing LShift or RShift does not do anything.
Is it possible to map them without affecting their normal functions?
Similarly, is it possible to map LShift + LShift (pressing LShift twice)
Appreciate education!
Is it possible to map SHIFT?
-
- Posts: 58
- Joined: 15 Jan 2014, 19:09
Re: Is it possible to map SHIFT?
I have used "~LShift Up::RunSomeFunction()" successfully; I don't know if I've tried plain "~LShift::RunSomeFunction()". The ~ says to pass the keystroke along normally. This is in a very large complex script with many layers of hotkeys, so it sometimes has taken trial and error to get a key like this positioned well with respect to other keys which might use shift. As for pressing the key twice. I think you require internal timing logic to detect this for yourself (at least that's what I have to do). In any case, I do use AHK to trap shift keypresses. The ones I really like are "+RShift::RunThis()" and "+LShift::RunThat()", which fire when both shift keys are pressed (one firing when the left is pressed first and the other firing when the right is pressed first).
Re: Is it possible to map SHIFT?
Code: Select all
; LShift + RShift
<+RShift:: MsgBox, LShift + RShift
; RShift + LShift
>+LShift:: MsgBox, RShift + LShift
; 2xLShift
~LShift::
If (A_PriorHotKey = "~LShift Up" AND A_TimeSincePriorHotkey < 300)
MsgBox, 2xLShift
return
~LShift Up:: Send, ^c{Shift Up} ; copy
; 2xRShift
~RShift::
If (A_PriorHotKey = "~RShift Up" AND A_TimeSincePriorHotkey < 300)
MsgBox, 2xRShift
return
~RShift Up:: Send,{Shift Up}
Re: Is it possible to map SHIFT?
Thanks to both.
2xLShift, 2xRShift, and LShift + RShift are working beautifully.
So are LShift and RShift, but WITHOUT the tilde.
With the tilde, Shift + A etc will also fire the macro. Not desirable.
Thank again for the great help.
2xLShift, 2xRShift, and LShift + RShift are working beautifully.
So are LShift and RShift, but WITHOUT the tilde.
With the tilde, Shift + A etc will also fire the macro. Not desirable.
Thank again for the great help.
Re: Is it possible to map SHIFT?
yes, I've done this. I mapped LShift and RShift to send left and right parenthesis respectively (as suggested here), while still maintaining their shifting behavior to capitalize characters.bruin1953 wrote:Pressing and releasing LShift or RShift does not do anything.
Is it possible to map them without affecting their normal functions?
The solution was from this link:
http://www.autohotkey.com/board/topic/1 ... ntrol-key/
Code: Select all
$~*LShift::
;msgbox, %A_ThisHotkey% is down
;// when you hold down the key, this hotkey fires constnatly due to the normal OS-level repeat
;// so we only want to store the time from the initial downpress, not each OS-repeat)
;// and then during the 'up' hotkey, we reset this timestamp back to 0
if (!LShift_down_timestamp)
LShift_down_timestamp := A_TickCount
;// if any other modifiers are down along with this key, then we will not send the replacement key (left parens)
if (!LShift_modifiers_are_pressed)
LShift_modifiers_are_pressed := (GetKeyState("Control", "P") || GetKeyState("Alt", "P") || GetKeyState("LWin", "P") || GetKeyState("RWin", "P"))
return
$~LShift up::
;msgbox, %A_PriorKey%
;msgbox, %A_ThisHotkey%
;// check if EITHER shift key was the last key pressed
;// this allows accidental 'rolling': presing Lshift then Rshift very fast, where you hadn't fully released the LShift before RShift went down
;// also, you must press and release LShift within 300ms, otherwise this doesn't trigger.
;// i found myself sometimes holding LShift for a while, planning on capitalizing a letter
;// but then releasing the key, causing this hotkey to trigger erroneously
if (A_PriorKey ~= "LShift|RShift") && (!LShift_modifiers_are_pressed) && (A_TickCount - LShift_down_timestamp < 300)
Send, {Shift Down}9{Shift Up} ;// send left parenthesis
LShift_modifiers_are_pressed := false
LShift_down_timestamp := 0
return
Re: Is it possible to map SHIFT?
Here is a script that uses left shift to turn off caps lock (regardless of current state) and right shift to turn on caps lock (regardless of current state) while retaining their normal functions if held while pressing another key.
; Capitalist
;
; LShift CapsLock Off
; RShift CapsLock On
; {CapsLock}&{letter} {CAPITAL_LETTER}
#SingleInstance force
#Persistent
Menu, Tray, Add ;divider line
Menu, Tray, Add, CapsLock, ToggleCapsLock
Menu, Tray, Default, CapsLock
IconFile0 := "small_a.ico"
IconFile1 := "BIG_A.ico"
State0 := "Off"
State1 := "On"
Goto, UpdateIcon
RShift & LButton::SendInput +{Click}
~RShift::
{
SetCapsLockState, on
Goto, UpdateIcon
}
LShift & LButton::SendInput +{Click}
~LShift::
{
SetCapsLockState, off
Goto, UpdateIcon
}
CapsLock::
{
NextState := 1 - GetKeyState("Capslock", "T")
SetCapsLockState, on
Gosub, UpdateIcon
Input, Keys, V L1, {CapsLock}
If ErrorLevel = Max
{
NextState := 1 - NextState
}
Return
}
CapsLock Up::
{
SendInput {CapsLock}
if !NextState
{
SetCapsLockState, off
}
Goto, UpdateIcon
}
ToggleCapsLock:
Sleep,40 ;because double click can temporarily turn off CapsLock
if GetKeyState("Capslock", "T")
{
SetCapsLockState, Off
}
else
{
SetCapsLockState, On
}
Goto, UpdateIcon
UpdateIcon:
IconNumber := GetKeyState("Capslock", "T")
IconFile = IconFile%IconNumber%
IconFile := %IconFile%
Menu, Tray, Icon, %IconFile%, 1
State = State%IconNumber%
State := %State%
Menu, Tray, Tip,CapsLock %State%
if IconNumber
{
Menu, Tray, Check, CapsLock
}
else
{
Menu, Tray, Uncheck, CapsLock
}
Return
; Capitalist
;
; LShift CapsLock Off
; RShift CapsLock On
; {CapsLock}&{letter} {CAPITAL_LETTER}
#SingleInstance force
#Persistent
Menu, Tray, Add ;divider line
Menu, Tray, Add, CapsLock, ToggleCapsLock
Menu, Tray, Default, CapsLock
IconFile0 := "small_a.ico"
IconFile1 := "BIG_A.ico"
State0 := "Off"
State1 := "On"
Goto, UpdateIcon
RShift & LButton::SendInput +{Click}
~RShift::
{
SetCapsLockState, on
Goto, UpdateIcon
}
LShift & LButton::SendInput +{Click}
~LShift::
{
SetCapsLockState, off
Goto, UpdateIcon
}
CapsLock::
{
NextState := 1 - GetKeyState("Capslock", "T")
SetCapsLockState, on
Gosub, UpdateIcon
Input, Keys, V L1, {CapsLock}
If ErrorLevel = Max
{
NextState := 1 - NextState
}
Return
}
CapsLock Up::
{
SendInput {CapsLock}
if !NextState
{
SetCapsLockState, off
}
Goto, UpdateIcon
}
ToggleCapsLock:
Sleep,40 ;because double click can temporarily turn off CapsLock
if GetKeyState("Capslock", "T")
{
SetCapsLockState, Off
}
else
{
SetCapsLockState, On
}
Goto, UpdateIcon
UpdateIcon:
IconNumber := GetKeyState("Capslock", "T")
IconFile = IconFile%IconNumber%
IconFile := %IconFile%
Menu, Tray, Icon, %IconFile%, 1
State = State%IconNumber%
State := %State%
Menu, Tray, Tip,CapsLock %State%
if IconNumber
{
Menu, Tray, Check, CapsLock
}
else
{
Menu, Tray, Uncheck, CapsLock
}
Return
-
- Posts: 204
- Joined: 24 Jun 2015, 23:38
Re: Is it possible to map SHIFT?
@bobsundquist, Please use code boxes when posting scripts or script excerpts... they format the code nicely, link keywords automatically to the help pages and keep the script from taking up too much vertical space in the post.
Re: Is it possible to map SHIFT?
This post looks simple and working!
http://superuser.com/questions/579442/u ... t-to-but-i
http://superuser.com/questions/579442/u ... t-to-but-i
Who is online
Users browsing this forum: Descolada and 182 guests