SC039::Send {LShift down}
SC039 Up::
Send, {LShift up}
Send, {Space}
Return
I expect this to do the following: when pressing the spacebar, it acts like the shift key. When I release it, I get one space bar press. Unfortunately, when I stay on the space bar, I get a bunch of spaces even though the key is never released. How can this expected behavior be implemented?
You need the * modifier(docs) so the hotkey is recongnized even if extra modifiers are held down (Shift)
Also, why are you using using the scancode?
*Space::SendInput, {LShift Down}
*Space Up::SendInput, {LShift Up}{Space}
Check dual-key "SpaceFN" keyboard layout https://github.com/lydell/spacefn-win
Probably this is what you are looking for or even more.
Related
I wrote this script to make my space-bar button act as a space-bar when tapped and a shift button when held. However, it affects mappings such as
::btw::by the way
Scenario:
when I tapped space-bar after typing "btw" to convert "btw" into "by the way ", the conversion did not take place.
Is there anyway that I can change my script below to ensure that conversion in the above scenario happens?
$Space::
now := A_TickCount
while GetKeyState("Space", "P") ; to find out whether space-bar is held
if (A_TickCount-now > 180) ; this time is tested on asker's computer
{
SendInput {Shift Down}
KeyWait, Space
SendInput {Shift Up}
return
}
SendInput {Space} ; if key detected to be tapped, send space as per normal
return
Thanks :)
Hotstrings ignore events generate by Autothotkey if their send level is equal or lower than the send level of the event.
This means that the send level of Space, must be set to a higher level than the level of hostrings you wish to trigger with it:
#InputLevel, 10 ;set send level for the following code to 10
$Space::
#InputLevel ;set it back to default value of 0 for any remaining code
now := A_TickCount
while GetKeyState("Space", "P") ; to find out whether space-bar is held
if (A_TickCount-now > 180) ; this time is tested on asker's computer
{
SendInput {Shift Down}
KeyWait, Space
SendInput {Shift Up}
return
}
SendInput {Space} ; if key detected to be tapped, send space as per normal
return
you have to change the auto-replace code for btw to
:*:btw::by the way
instead of
::btw::by the way
this will auto-replace btw to by the way even if you have the mentioned hotkey for space
#Neo Ding Yue Is it working? Initially I did it like you, but it had many flaws. Finally I found a solution which I am using since two years: 1. registry remap space to behave like LShift and use this code:
~*LShift:: ;tilde so it gets triggered already on down, in combination with any key, hence can be used as modifier key
Keywait,LShift, L ; just to deactivate autofire
return
~LShift up::
IF(A_TimeSincePriorHotkey < 150 && A_PriorKey = "LShift") {
SendInput {Space}
}
return
If you have question, just ask (I have other versions).
I have a very simple script to try and remap my AppsKey (the one on the right hand side of the keyboard, between WinKey and Ctrl) to Shift + F2 for the Uplay overlay.
AppsKey::
Send, +{F2}
Return
As you can see, it's very basic, however, when I try to use it in-game (Far Cry 3 in this instance), it works erratically. Like sometimes when I press the AppsKey, the overlay opens. Sometimes it doesn't and I have to repeatedly tap the AppsKey for it to finally show up or close.
No, my AppsKey isn't broken. I tried mapping it to something else and it works without problems. I just want some lead as to why it's acting erratically in this case.
Per the comments, the solution should be akin to this:
AppsKey::
SendInput, {Shift down}{F2 down}
Sleep, 50
SendInput, {Shift up}{F2 up}
return
i wannna be able to press Alt+Middle Button for simulating Shift+Ctrl+Right Button with AutoHotkey. I did it for simulating two keys. And it worked but it is not working for three keys.
so i wrote that:
LAlt & MButton::Send {Ctrl Down}{Shift Down}{RButton Down}
keywait, LAlt
keywait, MButton
LAlt & MButton Up::Send {Ctrl Up}{Shift Up}{RButton Up}
return
where is the problem?
First thing is that the two keywait lines are never executed as you have your send action on the some line as the hotkey, this will make a one-line hotkey or remap
If you wish to execute multiple lines of code in one hotkey routine you will need to start the routine on the line below the hotkey definition label.
Also try taking a simpler approach be using Autohotkeys remapping capabilities
Can't say this will work for you but give it a shot
!MButton::^+RButton
Hope it helps
I'm kinda new at this. I have a mouse with only 3 keys that I'd like to write a script for to allow me to use the right mouse button like a "browser back" key if clicked, while still retaining the original function if held for a longer period of time.
RButton::
sleep 400
GetKeyState, state, RButton
if state = U
send {Browser_Back}
else
send {RButton}
keywait, RButton
return
Currently, all my script above does now is activates the "browser back" function, regardless of time held down. I think there's a problem with the key being repeated at the send {RButton} line, but adding a $ to RButton:: didn't seem to help (if it was supposed to, idk.) If I replace the 3 "RButton" instances (not including the one on the send line) with a key on the keyboard, it works perfectly though. Help would be appreciated. Thanks.
Adjusted the code from BlackHolyMan's response to fix it. In case anybody was curious or wanted it, here it is:
RButton::
KeyWait, RButton, U T0.5
If !ErrorLevel
{
send {Browser_Back}
return
}
else
{
send {RButton Down}
KeyWait, RButton
send {RButton up}
}
return
Hi this may be just about what you need
RButton::
KeyWait, RButton, U T0.5
If !ErrorLevel
send {Browser_Back}
else
{
send {RButton Down}
KeyWait, RButton
send {RButton up}
}
return
Still some things you may need to fix as i did not test it for long...
I'm attempting to send three keys (Alt, Shift, Q) at same time using this script:
:*:pk:: ;
Send, {AltDown}{ShiftDown}{qDown}
return
When I run this is it does not release the keys, it seems like the Alt button remains pressed. After the above keys are pressed I then want to press the "q" character again (separately, not at same time).
How can I amend my script above to achieve this?
When using Down, you must also send an Up to the same key or else it will remain pressed. This can be achieved like this:
:*:pk::
Send, {Alt Down}{Shift Down}{q Down}{Alt Up}{Shift Up}{q Up}
Send, {q}