I have the following map:
>!+a::SendInput,+{Delete}
It's supposed to send Ctrl+Delete (delete word after cursor) when I press RightAlt+Ctrl+a but instead it's sending a Ctrl+Alt+Delete signal so it's bringing up the Windows 7 menu of shutdown, start task manager etc.
How can I send the right signal?
Appreciate any help!
The problem you are facing is that Ctrl + Alt + Delete is hard coded and is uninterruptible. There's simply no way around it, if you press that sequence, even with the Command BlockInput enabled, Windows will re-enable input and execute the command...
Try:
>!^a:: ; + symbol is Shift ^ represents Ctrl key
KeyWait, RAlt ; Waits for Right Alt to be released before Ctrl Delete is sent
SendInput,{Ctrl Down}{Delete}{Ctrl Up}
Return
An alternative although it works the exact same way:
>!^a::
While (GetKeyState("RAlt", "P"))
Continue
SendInput,{Ctrl Down}{Delete}{Ctrl Up}
Return
I'll continue to pursue other options.. at the moment I can I think of no better way to do this.
Related
I am trying to make my MacBook in Windows behave similar to macOS: so I can switch between apps using Win+Tab (i.e., replicate the Alt+Tab action), but have all the Ctrl+... actions (like, Ctrl+C, Ctrl+V, Ctrl+Z, etc) be accessible using the Win key (Win+C, Win+V, Win+Z).
In other words, I am trying to :
Remap Win key to Ctrl in all key combinations, but also
Have the Win+Tab act exactly as Alt+Tab (and I don't care if Ctrl+Tab stops
working as Ctrl+Tab, because I am not using that key combination at
all).
I am able to separately individually achieve 1. using LWin::Ctrl, and 2. using LWin & Tab::AltTab, but I cannot make them work together. Whenever I have something like
LWin::Ctrl
LWin & Tab::AltTab
or
LWin::Ctrl
Ctrl & Tab::AltTab
it just stops working, I am using Windows 10.
Did you try to use the symbols like documented here?
For your snippet that would mean:
LWin::Ctrl
LWin & Tab::Send, !{Tab}
There is a problem with this, as it simulates closed keystokes (regard !{Tab} as {Alt Down}{Tab}{Alt Up}. If you want to press and hold Win and then use Tab (or eventually tab multiple times), this doesn't work. To adress this issue, I found three main workarounds:
)
Let Alt stick to being pressed down:
LWin::Ctrl
LWin & Tab::Send, {Alt Down}{Tab}
LWin & Capslock::Send, {Alt Up} ;Suppose you won't use that hotkey elsewhere
)
Use something this solution by 2501:
h::AltTabMenu ; Opens the menu. Press second time to close.
n::AltTab ; Alt-Tabs through forwards
m::ShiftAltTab ; Alt-Tabs through backwards
The underlying principles/functionalities are documented here.
) Dig into AHK really deep: here (which is referenced in 1)
Annotation: Be aware that
<#::Ctrl
<#Tab::!Tab
does not work as Windows then handles the win key on its own first. You can verify This by testing:
<#::
MsgBox test
return
<#Tab::
MsgBox test
return
I'm trying to bind "Esc" key to lock my computer with AutoHotkey.
Manually pressing Winkey + l will lock my computer, but it doesn't work in my AutoHotkey script.
esc::
MsgBox Going to lock
Send, #l
Return
I have tried multiple other AutoHotkey syntax (without the modifier for example) without success.
Per the recommendation in the comments by wOxxOm:
Esc::
{
DllCall("LockWorkStation")
}
return
What you are doing in that code, is pressing the windows key first and then the 'l' key. Not both at the same time. To make key combinations, you need to press the combination key down and then the key you want to combine it with. Remember to release the key afterwards. Your code would then look like:
Send {LWin down}
Send l
Send {LWin up}
or
Send {LWin down}l{LWin up}
Just improving the code of my fellow camarades, you can block AND turn off the screen if you want to:
#J::
KeyWait LWin
KeyWait J
DllCall("LockWorkStation")
SendMessage,0x112,0xF170,2,,Program Manager
Return
Windows 10 has finally multi desktops, you can switch desktops with ctrl+win+right (or left) keys. It's a nice feature, but you have two use two hands to switch desktops.
I'm trying to map the keys like this with autohotkey so I can use just one hand and keep the other one in the mouse..
ctrl + mouse wheel up --> ctrl + win + right
ctrl + mouse wheel down --> ctrl + win + left
the message box comes up so the ctrl + wheel up is working, but it doesn't switches desktops.
~LControl & WheelUp::
MsgBox, Go to desktop right.
Send, {ctrl up}{lwin ctrl righ}
return
~LControl & WheelDown::
MsgBox, Go to desktop left.
Send, {ctrl up}{lwin ctrl left}
return
Any idea why is this not working?.
You can easily switch between two virtual desktops in Windows 10 by using Ctrl+Win+→ or Ctrl+Win+← shortcuts.
But to make this even simpler and easy to use I’ve made this Autohotkey script to toggle betweeen two virtual desktops by just using the (`) key which is the least used key in keyboard.
`::
if (Toggle := !Toggle)
Send #^{right}
else
Send #^{left}
return
Note:- This script works for switching between two desktops only. For creating another virtual desktop you can use the shortcut Ctrl+Win+D.
Inside {} only one key should be specified and I think there's no need for passthrough modifier ~:
LCtrl & WheelUp::Send, {LCtrl up}{LWin down}{LCtrl down}{Right}{LWin up}{LCtrl up}
LCtrl & WheelDown::Send, {LCtrl up}{LWin down}{LCtrl down}{Left}{LWin up}{LCtrl up}
Maybe the standard syntax for modifier keys will also work without sending up-event for LCtrl key:
LCtrl & WheelUp::Send, #{Right}
LCtrl & WheelDown::Send, #{Left}
I know this is an old question but there is now a much better solution that has official support from Microsoft and is really easy to use. Microsoft has recently released an open source tool called Powertoys https://github.com/microsoft/PowerToys . It includes a keyboard manager with a tool for remapping keyboard shortcuts. Its really simple.
I've made simple remapping of CapsLock to Control with autohotkey:
Capslock::Control ; make Caps Lock the control button
This works OK, but in Emacs if I need to do a key sequence like Ctrl-x Ctrl-f while holding the CapsLock key continuously the whole time what gets registered is Ctrl-x f. In order to get the correct sequence I now have to release CapsLock between the keystrokes like Ctrl-x <release> Ctrl-f which is very inconvenient.
Is there a way to do the rebinding so that holding CapsLock down will work exactly as holding down the Control button?
I've also tried the following snippet without success:
#IfWinActive ahk_class Emacs
{
CapsLock::
Sendinput {Ctrl Down}
KeyWait, CapsLock
Sendinput {Ctrl Up}
return
}
Using Send or Sendplay in the above instead of Sendinput also doesn't solve my problem.
My system:
Windows 7 32bit
AHK v1.1.13.01
Emacs 24.3
Thank you!
I'm not sure why it's not working correctly for you. I added your remapping into my existing script and it seems to work fine. Can you post more of what you have? I have the following commands at the top of mine but I wouldn't think they should affect your problem.
#Persistent
#SingleInstance, Force
The commands GetKeystate
and SetKeyDelay might be helpful.
This is what I use and it works:
*Capslock::LCtrl
The asterisk is documented in the help under Keyboard Control > Hotkeys and Hotstrings:
Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons. For example:
*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey.
*ScrollLock::Run Notepad ; Pressing Scrolllock will trigger this hotkey even when modifer key(s) are down.
This symbol is ignored on Windows 95/98/ME.
I actually have this one too, +Caps Lock, if I really want caps lock:
<#Capslock::Capslock
Try this;
SetCapsLockState, AlwaysOff
CapsLock:: SendInput, {LCtrl Down}
Capslock Up:: SendInput, {LCtrl Up}
I want to use AutoHotKey to bind a command to Ctrl+Shift, in the same way that Windows detects it in order to change text direction from right-to-left to left-to-right. That is: I want it to be invoked when Ctrl+Shift is let go, and only if no keys were pressed between pressing Ctrl+Shift and letting them go.
I bound a hotkey on ^~ Shift Up and I expected it to behave the same way as when Windows binds to it for changing the text direction. But, I found that it gets invoked even in cases where I don't want it to be invoked.
For example, I could be selecting a few words by pressing Ctrl and Shift, and then using the arrow keys. Then I let go of Ctrl and Shift and the hotkey gets invoked. I don't want this. I want a hotkey that gets invoked only if I held nothing else then Ctrl and Shift. If I use any other keys, I want the hotkey not to be invoked.
Is there a way to do this with AHK?
#InstallKeybdHook
Hotkey, ^LShift Up, ControlShiftUp
Return
ControlShiftUp:
if (A_PriorKey != "LShift") ; [v1.1.01+]
return
; do something
msgbox hi
Return