Hello AHK, I cant understand how to make a script not work instantly when a key is pressed, but when I have the key pressed for 5 seconds.
The other problem is that the original key must work as usual on quick click.
For example, I need Win key to be a CTRL + C, only if I have WIN key pressed for 5 sec
Is it possible?
thanks
AHK script to work when a key is pressed for some time
-
- Posts: 26
- Joined: 25 Jan 2022, 10:24
-
- Posts: 26
- Joined: 25 Jan 2022, 10:24
Re: AHK script to work when a key is pressed for some time
cheers @mikeyww, Thanks for your reply. I've seen this topic from Google Search already. The problem for me is that I need the opposite result, but being newbie to AHK I don't understand what exactly needs to be changed from that proposed script unfortunately
-
- Posts: 26
- Joined: 25 Jan 2022, 10:24
Re: AHK script to work when a key is pressed for some time
UPD
___
from abovementioned topic I composed a script for my needs
the problem is that when I need to enter Win + V menu (clipboard) the script doesn't let me, looks like it recognizes the Win pressed as part of script. I changed the value for 8000 but anyway it works too fast.
what can be the problem ?
___
from abovementioned topic I composed a script for my needs
Code: Select all
LWin::
KeyWait, LWin, T.2
If ErrorLevel { ; Held
Send #{Left}
SoundBeep, 8000
KeyWait, LWin
Send {LWin up}
} Else Send {LWin down}
Send {LWin up}
SoundBeep, 1000
Return
what can be the problem ?
Re: AHK script to work when a key is pressed for some time
Perhaps:
Code: Select all
LWin::
Input, key, L1T5, % "{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}"
. "{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}"
. "{Del}{Ins}{BS}{CapsLock}{NumLock}{PrintScreen}{Pause}"
mods := (GetKeyState("Ctrl" , "P") ? "^" : "")
. (GetKeyState("Alt" , "P") ? "!" : "")
. (GetKeyState("Shift", "P") ? "+" : "")
SoundBeep, 1500
If (ErrorLevel = "Timeout") ; LWin was held
Send ^c
Else Send % "#" mods "{" (key > "" ? key : StrReplace(ErrorLevel, "EndKey:")) "}"
KeyWait, LWin
Return