Sorry if this is easy, but I don't know where I could start consulting the manual.
I would like that Left shift key sends arrow down if no key is pressed after it.
If a key is pressed after Left shift key, it should send the up case letter.
Same with Rigth shift key, but with arrow up.
How should it be done?
Best regards
Double use of shift keys Topic is solved
Re: Double use of shift keys
Using InputHook isn't the easiest feature for beginners.
Therefore, I wanted to solve this problem without InputHook, but I couldn't find a neat way.
Above all, it was just too bothersome(?), so I just went ahead and used InputHook to solve this problem. Umm...
I hope someone else can provide code that's easier to understand than mine. Thank you.
Therefore, I wanted to solve this problem without InputHook, but I couldn't find a neat way.
Above all, it was just too bothersome(?), so I just went ahead and used InputHook to solve this problem. Umm...
I hope someone else can provide code that's easier to understand than mine. Thank you.
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
~LShift:: {
static init := false, ih
if (!init) {
init := true
ih := inputHook("L0")
ih.BackspaceIsUndo := false
ih.MinSendLevel := 101
ih.keyOpt("{All}","VE")
ih.KeyOpt("{LShift}","-E")
}
ih.start()
keyWait("LShift")
ih.stop()
if (ih.EndKey == "")
send("{Down}")
}
~RShift:: {
static init := false, ih
if (!init) {
init := true
ih := inputHook("L0")
ih.BackspaceIsUndo := false
ih.MinSendLevel := 101
ih.keyOpt("{All}","VE")
ih.KeyOpt("{RShift}","-E")
}
ih.start()
keyWait("RShift")
ih.stop()
if (ih.EndKey == "")
send("{Up}")
}
- English is not my native language. Please forgive any awkward expressions.
- 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
Re: Double use of shift keys
An easier way?
or this:
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
~LShift:: {
keyWait("LShift")
if A_PriorKey = "LShift"
send("{Down}")
}
~RShift:: {
keyWait("RShift")
if A_PriorKey = "RShift"
send("{Up}")
}
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
~LShift Up:: {
if A_PriorKey = "LShift"
send("{Down}")
}
~RShift Up:: {
if A_PriorKey = "RShift"
send("{Up}")
}
Last edited by ntepa on 08 May 2024, 20:15, edited 1 time in total.
Re: Double use of shift keys Topic is solved
I originally had something like ntepa's but found that pressing too many shifts in a row caused shift+arrow to be used so I had to send shift up.
Code: Select all
~LShift::SendArrow('down')
~RShift::SendArrow('up')
SendArrow(direction) {
key := SubStr(A_ThisHotkey, 2)
KeyWait(key)
Send('{Shift up}')
if A_PriorKey = key {
Send('{' direction '}')
}
}
Re: Double use of shift keys
First: thanks!
Second: I would like to understand better your code, it is some steps above my level, any tips welcome. @niCode
Third: Could it be possible to use shift with mouse click? Right now I can't select several cells in excel using Shift + Left click (it acts as arrow).
Best regards
Second: I would like to understand better your code, it is some steps above my level, any tips welcome. @niCode
Third: Could it be possible to use shift with mouse click? Right now I can't select several cells in excel using Shift + Left click (it acts as arrow).
Best regards
Re: Double use of shift keys
One idea:
Code: Select all
#HotIf GetKeyState('Shift', 'P') ; if shift is physically being pressed down
~*LButton::SendArrow(false) ; LButton sends a false to SendArrow to interrupt it
#HotIf ; blank #HotIf prevents below hotkeys from being affected by above #HotIf condition
~LShift::SendArrow('down') ; LShift behaves as normal and calls SendArrow function with down as parameter
~RShift::SendArrow('up') ; RShift behaves as normal and calls SendArrow function with up as parameter
SendArrow(direction) {
static key := '' ; initialize variable 'key' : static means the value is remembered between calls
if not direction { ; if direction is false
key := '' ; reset key to interrupt comparison after the KeyWait so it fails and doesn't send directional key
return ; exit early
}
key := SubStr(A_ThisHotkey, 2) ; key is the hotkey called, starting at the second value e.g. ~LShift hotkey is just LShift
KeyWait(key) ; wait for key to be physically released
Send('{Shift up}') ; send shift up
if A_PriorKey = key { ; if a prior key is the same as the key pressed to get here, i.e. no other key was pressed during the hold
Send('{' direction '}') ; send direction sent by shift key
}
}
Who is online
Users browsing this forum: Descolada, william_ahk and 39 guests