Page 2 of 2

Re: Time threshold...

Posted: 11 Jul 2021, 11:19
by akirofe
just me wrote:
10 Jul 2021, 07:19
Maybe:

Code: Select all

HookEnded(InputHook) {
   ...
   If (EndReason = "Max") {
      If (IsDown) && ((A_TickCount - IsDown) >= Treshold) {
         Switch Input {
            Case "s":   ; a & s
               Send ...
            Case "d":   ; a & d
               Send
            Case "f":   ; a & f
               Send ...
            Case " ":   ; a & space
               Send ...
            Case "w":   ; a & w
               Send ...
            Case "e":   ; a & e
               Send ...
            Default:    ; a & anything else
               Send %PriorKey%%Input%
         }
      }
      Else
         Send %PriorKey%%Input%
   }
   ...
}
Hi Justme,

With my very limited knowledge and with a lot of shooting in the dark, I have implemented your code into the below but I must have done something wrong :headwall: Could you please help me to fix? And, could you please help me a bit more: I couldn't find where it specifies "a" in your code ie. if I want to have another codes with, say, "f" instead of "a" for things like: f+a=Tab,... then where should I replace that "a" to an "f" in your code please?

Thank you very much Justme!!

Code: Select all

HookEnded(InputHook) {
   EndReason := InputHook.EndReason
   Input := InputHook.Input
   InputHook.Stop()
   If (EndReason = "Max") {
      If (IsDown) && ((A_TickCount - IsDown) >= Treshold) {
         Switch Input {
            Case "s":   ; a & s
               Send {WheelDown}{WheelDown}{WheelDown}
            Case "d":   ; a & d
               Send WheelUp}{WheelUp}{WheelUp}{WheelUp}
            Case "f":   ; a & f
               Send LButton
            Case " ":   ; a & space
               Send RButton
            Case "w":   ; a & w
               Send Escape
            Case "e":   ; a & e
               Send Delete
            Default:    ; a & anything else
               Send %PriorKey%%Input%
         }
      }
      Else
         Send %PriorKey%%Input%
   }
   IsDown := 0
   PriorKey := "a"
}

Re: Time threshold...

Posted: 12 Jul 2021, 05:16
by just me
You need my whole script to make it work:

Code: Select all

#NoEnv
#InstallKeybdHook
Global Treshold := 400
Global PriorKey := ""
Global IsDown := 0
Global Hook := InputHook("L1")
Hook.OnEnd := Func("HookEnded")
Return
; ------------------------------------------------------------------------------
$a::
$+a::
   IsDown := A_TickCount
   PriorKey := InStr(A_ThisHotkey, "+") ? "A" : "a"
   Hook.Start()
   KeyWait, a
   Hook.Stop()
   IsDown := 0
   If (PriorKey <> "") {
      SendInput, %PriorKey%
      PriorKey := ""
   }
Return
; ------------------------------------------------------------------------------
HookEnded(InputHook) {
   EndReason := InputHook.EndReason
   Input := InputHook.Input
   InputHook.Stop()
   If (EndReason = "Max") {
      If (IsDown) && ((A_TickCount - IsDown) >= Treshold) {
         Switch Input {
            Case "s":   ; a & s
               Send {WheelDown}{WheelDown}{WheelDown}
            Case "d":   ; a & d
               Send {WheelUp}{WheelUp}{WheelUp}{WheelUp}
            Case "f":   ; a & f
               Send {LButton}
            Case " ":   ; a & space
               Send {RButton}
            Case "w":   ; a & w
               Send {Escape}
            Case "e":   ; a & e
               Send {Delete}
            Default:    ; a & anything else
               Send %PriorKey%%Input%
         }
      }
      Else
         Send %PriorKey%%Input%
   }
   IsDown := 0
   PriorKey := ""
}
; ------------------------------------------------------------------------------
Esc::ExitApp
The a is defined as a hotkey. I wouldn't use this concept if you need more prefix keys.

Re: Time threshold...

Posted: 17 Jul 2021, 10:01
by akirofe
just me wrote:
12 Jul 2021, 05:16
You need my whole script to make it work:

Code: Select all

#NoEnv
#InstallKeybdHook
Global Treshold := 400
Global PriorKey := ""
Global IsDown := 0
Global Hook := InputHook("L1")
Hook.OnEnd := Func("HookEnded")
Return
; ------------------------------------------------------------------------------
$a::
$+a::
   IsDown := A_TickCount
   PriorKey := InStr(A_ThisHotkey, "+") ? "A" : "a"
   Hook.Start()
   KeyWait, a
   Hook.Stop()
   IsDown := 0
   If (PriorKey <> "") {
      SendInput, %PriorKey%
      PriorKey := ""
   }
Return
; ------------------------------------------------------------------------------
HookEnded(InputHook) {
   EndReason := InputHook.EndReason
   Input := InputHook.Input
   InputHook.Stop()
   If (EndReason = "Max") {
      If (IsDown) && ((A_TickCount - IsDown) >= Treshold) {
         Switch Input {
            Case "s":   ; a & s
               Send {WheelDown}{WheelDown}{WheelDown}
            Case "d":   ; a & d
               Send {WheelUp}{WheelUp}{WheelUp}{WheelUp}
            Case "f":   ; a & f
               Send {LButton}
            Case " ":   ; a & space
               Send {RButton}
            Case "w":   ; a & w
               Send {Escape}
            Case "e":   ; a & e
               Send {Delete}
            Default:    ; a & anything else
               Send %PriorKey%%Input%
         }
      }
      Else
         Send %PriorKey%%Input%
   }
   IsDown := 0
   PriorKey := ""
}
; ------------------------------------------------------------------------------
Esc::ExitApp
The a is defined as a hotkey. I wouldn't use this concept if you need more prefix keys.
Hi JustMe,

Thank you very much for your help!!

But, your instinct was right... I do need other sets starting with other prefix keys ie. "f" "d" and "s". As this would let my left hand stay on A-S-D-F more hence reduce shoulder and neck rsi pains... Maybe InputLevel or SendLevel could do something... (I tried but failed to how to use them correctly ...sad...) . My attached whole file may explain this better.

Thank you very much again JustMe!!!!
_ALL.ahk
(7.74 KiB) Downloaded 8 times