Time threshold...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
akirofe
Posts: 161
Joined: 05 Apr 2021, 21:54

Re: Time threshold...

11 Jul 2021, 11:19

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"
}
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
just me
Posts: 9528
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Time threshold...

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.
akirofe
Posts: 161
Joined: 05 Apr 2021, 21:54

Re: Time threshold...

17 Jul 2021, 10:01

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
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kaka2, pgeugene and 166 guests