autohotkey: bind <Enter> to <Control> while retaining certain behaviors - autohotkey

Is there a way to bind the <ENTER> key to <CONTROL> key, while retaining certain behavior of <ENTER> key?
The behavior I'm trying to achieve is as follows:
Pressing <ENTER> and "a" results in <CONTROL> + "a"
Pressing <ENTER> and "1" results in <CONTROL> + "1"
Pressing <ENTER> alone results in <ENTER>
Pressing <ENTER> and <ALT> results in <ENTER> + <ALT>

Shouldn't be too tough, I've not had time to test it but at least it's a starting point.
!enter:: send {alt down} {enter} {alt up}
enter down::
settimer, timer, on
hotkey, enter down, off
return
enter up::
settimer, timer, off
send, {ctrl up}
if a_timesincelasthotkey >= 750
send, {enter}
return
timer:
settimer, timer, off
send {ctrl down}
while getkeystate( "enter", "p" )
sleep, 1
send, {ctrl up}
return

Related

Auto hot key mapping to switch Control and Alt ^<+Tab::ShiftAltTab does not work

I'd like to use the following Auto Hot Key shortcuts to switch CTRL and ALT:
LCtrl & Tab::AltTab
return
^<+Tab::ShiftAltTab
return
But I've got an error The AltTab hotkey "^<+Tab" must specify which key (L or R).
Changed then I get another error: ... must have exactly one modifier/prefix.
<^<+Tab::ShiftAltTab
return
I found my question asked on Reddit too but no answer there:
https://www.reddit.com/r/AutoHotkey/comments/bb5xlv/tab_for_alttab_tab_for_shiftalttab_how
Try this
; LCtrl + Tab
<^Tab::
Send, {Alt Down}{Tab}
KeyWait, LCtrl ; waits for LCtrl to be relesead
Send, {Alt Up}
return
; LCtrl + LShift + Tab
<^<+Tab::
Send, {Alt Down}{Shift Down}{Tab}
KeyWait, LCtrl
KeyWait, LShift
Send, {Alt Up}
return

Hold modifier keys

1. Briefly
I don't understand, how I can make these actions:
hold modifier keys,
print some symbols, when modifier keys hold,
drop modifier keys.
I need it, because I use Clipjump.
2. Expected behavior
Simply example:
Ctrl Down → V → V → Ctrl Up.
3. Actual behavior
Part of my script:
#t::
Send, {LCtrl Down}
Sleep, 1000
Send, {V}
Sleep, 1000
Send, {V}
Sleep, 1000
Send, {LCtrl Up}
return
Ctrl Down → V → Ctrl Up, Ctrl Down → V → Ctrl Up.
4. Did not help
In Google, I write queries, for example, autohotkey hold modifier keys, autohotkey hold ctrl, but I can get no answer to my question.
You might try the different send modes. SendInput for example. You might use a plain "v" (instead of a shifted - capital - "V"). You might add a key multiplier {key #} instead of repeating.
#t::
SendInput, {LCtrl Down}
Sleep, 1000
SendInput, v
Sleep, 1000
SendInput, v
Sleep, 1000
SendInput, {LCtrl Up}
return
Or Better yet:
#t::
SendInput, {LCtrl Down}
Sleep, 1000
SendInput, {v 2}
Sleep, 1000
SendInput, {LCtrl Up}
return
or even:
#t::
SendInput, {LCtrl Down}{v 2}{LCtrl Up}
return
EDITed per comment: You might also try just using the ordinary ahk facility with modifiers, and try it under the different send modes, too:
#t::
Send, ^{v 2}
return
Hth,

Toggle Shift for Single Keypress

I am trying to turn my shift key into a CapsLock of sorts. The goal being that, when Shift is pressed, it shifts the next key to be pressed (eliminating the need to hold down the shift key), similar to the function of StickyKeys but only for the Shift key. I am able to toggle the Shift key using:
LShift:: Send % "{Blind}{LShift " . ((lshift:=!lshift) ? "Down}" : "Up}")
But that requires me to press Shift again, basically turning it into a CapsLock. How can I have this action only last for one keypress?
This should do:
$LShift::
SendInput, {LShift Down}
KeyWait, LShift
SendInput, {LShift Down}
Input, Key, L1 V
SendInput, {LShift Up}
Return
edit:
$*LShift::
SendInput, {LShift Down}
Input, Key, L1 M V
If GetKeyState("LShift", "P")
KeyWait, LShift
SendInput, {LShift Up}
Return

AHK - How to hold a macro while Physical Key depressed

What I want to do is this:
Numpad3::
if(not GetKeyState("Shift" , "P") and not GetKeyState("RButton" , "P"))
{
SendInput {Shift down}
Sleep, 33
Click down right
}
Return
Numpad3 Up::
Sleep, 100
Click up right
Sleep, 33
SendInput {Shift up}
Return
But for some reason it isn't canceling when I let the button up. :(
I would suggest to use Send {RButton Down} (or Up) to send the right mouse click, instead of Click up right.
Also, you don't want to be sending random Sleep's if they are not really necessary, as it creates lag and makes the script inelegant and potentially unreadable.
Here is code which sends Control instead of RButton but it's only so I can test it within Notepad++.
Just replace Control with RButton and have a go:
*NumpadPgDn::
*Numpad3::
Send {Shift Down}{Control Down}
return
*NumpadPgDn Up::
*Numpad3 Up::
Send {Shift Up}{Control Up}
return

Autohotkey, Step by Step Execution

This may be a very simple code but I am not able to find how to do it.
I have this
Send, Hi
Send, How Are you
Send, I am Fine
I want to do it like this
Hi How Are you
....
Right now with the below code
KeyWait, Capslock
Send, Hi
KeyWait, Capslock
Send, How Are you
KeyWait, Capslock
Send, I am Fine
I get
HiHow Are YOuI Am Fine as soon as I press Capslock.
I want it to wait to execute the next command. THanks for your help.
KeyWait, Capslock
Send {Capslock} ; Tap it again to reset it and force it to be released
; or Send {Capslock Up} to force it to be released
; or SetCapslockState Off to disable it completley
Send, Hi KeyWait, Capslock{Enter}
Send, How Are you KeyWait, Capslock{Enter}
Send, I am Fine{Enter}
If you want it in a hotkey, you could do something like this.
~$CapsLock::
Send {CapsLock Up}
Send, Hi {Enter}
KeyWait, Capslock, D
Send {CapsLock Up}
Send, How Are you{Enter}
KeyWait, Capslock
Send {CapsLock Up}
Send, I am Fine{Enter}
return
(It's glitching on my computer, but it may be because I'm on a virtual machine.)
SetCapslockState
Sorry if it is too late,but i did it anyways for everyone searching the solution for it,i assume you want to change it every time u press capslock to be different text:
CapsLock::
CapsLock0:
{
SendRaw Hi
Sleep 500
KeyWait, CapsLock, D
{
Goto CapsLock1
}
}
Return
CapsLock1:
{
SendRaw How Are you
Sleep 500
KeyWait, CapsLock, D
{
Goto CapsLock2
}
}
Return
CapsLock2:
{
SendRaw I am Fine
Sleep 500
KeyWait, CapsLock, D
{
Goto CapsLock0
}
}
Return
Explaination for Sleep,it is used because if you would press CapsLock without it then 2 of the command blocks would be executed,it is especially needed.
How about this...
Capslock::
Send, Hi{Enter}
Sleep, 400 ; sleep briefly to allow the CapsLock key to be released
KeyWait, Capslock, D
Send, How Are you?{Enter}
Sleep, 400
KeyWait, Capslock, D
Send, I am fine Thank you.{Enter}
Return
How about this...
Capslock::
Send, Hi{Enter}
KeyWait, Capslock, U
KeyWait, Capslock, D
Send, How Are you?{Enter}
KeyWait, Capslock, U
KeyWait, Capslock, D
Send, I am fine Thank you.{Enter}
Return