Page 1 of 1

Run again and again a hotkey with primary key down

Posted: 05 Jul 2019, 06:38
by jorj escu
Hello,
I'm trying to run a hotkey many times with primary key down.
For example the key is Ctrl + U, but I want to keep pressing Ctrl while I press repeatedly the U key.
Is possible to do that?

Re: Run again and again a hotkey with primary key down

Posted: 05 Jul 2019, 09:20
by WalkerOfTheDay
Something like this ?

This will hold the ctrl key when you press it once. After pressing it again it will release it.

Code: Select all

#NoEnv  ; for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2

#IfWinActive, Untitled - Notepad <------- might be a good idea if you only want to use it in certain program (example for notepad)

$LControl:: 
Toggle := !Toggle
If (Toggle)
{
	Send {CtrlDown}
	ToolTip, CTRL = Down
} Else {
	Send {CtrlUp}
	ToolTip, CTRL = Up
}
Return

Re: Run again and again a hotkey with primary key down

Posted: 05 Jul 2019, 10:42
by jorj escu
Thank you WalkerOfTheDay, but actually... no.
I should mention "holding" the Ctrl key, and then pressing repeatedly C, or whatever.
But I figured out how to do it inspired by some posts from here:

^u up::
{
send, part%n%
n++
send ^+{left}
}

Very interesting your code also. I think I know where to use it elsewhere. ;)