Need help with priorkey i think?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
isuckatahk
Posts: 36
Joined: 12 Mar 2020, 02:56

Need help with priorkey i think?

12 Jun 2021, 20:19

This script works on it's own but when i press F6 i have to press F7 twice to get it to preform the F7 hotkey functions. is there a way to add multiple Keys to the prior key? F6,F7,F8 and F9, so whenever i press a different key it works without me having to press a key twice. Sorry for the messy code, it's something i found.

Code: Select all

$F6::
  if (!F6) {
   F6:=0
  }
  if (F6State = 0) { 
    SetTimer, F6HoldTimerLabel, -400
    F6State:=1    
  }
  return
~$F6 up::
  SetTimer, F6HoldTimerLabel, Delete
  SetTimer, F6SingleClickTimerLabel, Delete
  If (A_PriorKey <>"F6") { ; combination - do nothing
    F6State:=0
  } else if (F6State = 1) { 
    SetTimer, F6SingleClickTimerLabel, -300
    F6State:=2
  } else if (F6State = 2) { 
    F6State:=0
    Send, !a
	Sleep, 25
	Send, n
  } else { ; hold
    F6State:=0
  }
  Return
F6SingleClickTimerLabel:
  SetTimer, F6HoldTimerLabel, Delete
  F6State:=0
  Send, !a
  return
F6HoldTimerLabel:
  F6State:=3
  If (A_PriorKey = "F6") {
  Send, !b
  }
  return
  
~$F7::
  if (!F7) {
   F7:=0
  }
  if (F7State = 0) { 
    SetTimer, F7HoldTimerLabel, -400
    F7State:=1    
  }
  return
~$F7 up::
  SetTimer, F7HoldTimerLabel, Delete
  SetTimer, F7SingleClickTimerLabel, Delete
  If (A_PriorKey <> "F7")  { ; combination - do nothing
    F7State:=0
  } else if (F7State = 1) { 
    SetTimer, F7SingleClickTimerLabel, -300
    F7State:=2
  } else if (F7State = 2) { 
    F7State:=0
    Send, e
  } else { ; hold
    F7State:=0
  }
  Return
F7SingleClickTimerLabel:
  SetTimer, F7HoldTimerLabel, Delete
  F7State:=0
  Send, d
  Sleep, 25
  Send, !m
  Sleep, 1600
  Send, z
  return
F7HoldTimerLabel:
  F7State:=3
  If (A_PriorKey = "F7") {
Send, j
  }
  return

~$F8::
  if (!F8) {
   F8:=0
  }
  if (F8State = 0) { 
    SetTimer, F8HoldTimerLabel, -500
    F8State:=1    
  }
  return
~$F8 up::
  SetTimer, F8HoldTimerLabel, Delete
  SetTimer, F8SingleClickTimerLabel, Delete
  If (A_PriorKey <> "F8")  { ; combination - do nothing
    F8State:=0
  } else if (F8State = 1) { 
    SetTimer, F8SingleClickTimerLabel, -300
    F8State:=2
  } else if (F8State = 2) { 
    F8State:=0
    MsgBox, DOUBLECLICK
  } else { ; hold
    F8State:=0
  }
  Return
F8SingleClickTimerLabel:
  SetTimer, F8HoldTimerLabel, Delete
  F8State:=0
  Send, b
  return
F8HoldTimerLabel:
  F8State:=3
  If (A_PriorKey = "F8") {
    Send, i
  }
  return

~$F9::
  if (!F9) {
   F9:=0
  }
  if (F9State = 0) { 
    SetTimer, F9HoldTimerLabel, -500
    F9State:=1    
  }
  return
~$F9 up::
  SetTimer, F9HoldTimerLabel, Delete
  SetTimer, F9SingleClickTimerLabel, Delete
  If (A_PriorKey <> "F9") { ; combination - do nothing
    F9State:=0
  } else if (F9State = 1) { 
    SetTimer, F9SingleClickTimerLabel, -400
    F9State:=2
  } else if (F9State = 2) { 
    F9State:=0
    MsgBox, DOUBLECLICK
  } else { ; hold
    F9State:=0
  }
  Return
F9SingleClickTimerLabel:
  SetTimer, F9HoldTimerLabel, Delete
  F9State:=0
  Send, b
  return
F9HoldTimerLabel:
  F9State:=3
  If (A_PriorKey = "F9") {
    MsgBox, HOLD
  }
  return
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 12 Jun 2021, 20:40, edited 1 time in total.
Reason: Please use [code] tags. Thank you!
User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Need help with priorkey i think?

12 Jun 2021, 20:31

You have not said what you want the script to do, but it seems possible that your F7 variable should actually be F7State.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jeves and 155 guests