I am new to stackoverflow and apologize in advance if what I am trying to explain is unclear.
I have tried multiple ways to make this work but have had no success so far.
I am trying to achieve the following:
When F3 is held and left arrow is pressed, left arrow will be pressed twice with no pause (0sec).
When F3 is held and right arrow is pressed, right arrow will be pressed twice with no pause (0sec).
Here's an alternative to Blauhirn's
F3::
While (GetKeyState("F3", "P")) {
If (GetKeyState("Left", "P"))
SendInput, {Left}
If (GetKeyState("Right", "P"))
SendInput, {Right}
}
Return
Alternatively you don't need to Loop to send multiples of of the same key.
You can simply use SendInput, {Left 4} the number represents the number of times that key will be sent.
Edit:
Oops, I didn't address the issue of delay between key presses. So I changed Send to SendInput as that has no delay between key presses.
~F3 & ~left::
send {left}
return
does this work?
This means, that as soon as f3 and left is pressed together, left will be sent a second time. If you want to repeat the send {left}command, use it like
loop, 4 ; 4 times
{
send {left}
}
Related
Hi im trying to make an AHK Script that sends a button press twice, once when i hold the button down and the second time when i release the button on my keyboard. So far i've only figured out the opposite of making any button a toggle, however that doesn't really help me D: any help appreciated!
The $-prefix prevents the hotkey from triggering itself, because it forces the keyboard hook to be used.
$a::
SendInput, a
KeyWait, a ; wait for the key to be released
SendInput, a
return
For more than one keys, you can use:
#NoEnv
#SingleInstance Force
SendMode Input
#InstallkeybdHook
#UseHook ; prevents the keys from triggering itself
keys := ["a","b","c","d","1","2","3","4"] ; ....
for each, key in keys
hotkey, %key%, send_key_twice, on
return
send_key_twice:
Send, %A_ThisHotkey%
KeyWait, %A_ThisHotkey% ; wait for the key to be released
Send, %A_ThisHotkey%
return
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 want my code to be able to register if the mouse is clicked, and do something when that happens, but also to be able to register if the mouse is held down and not interrupt the mouse being held down if that is the case. For example,
If AutoCAD is open
If mbutton is clicked
click the escape key
If mbutton is held down
be able to use the mbutton held down as usual
End
I've tried a couple of different ways to do this but I don't have the knowledge to do this exactly. I've got the "If AutoCAD is open", and the "click the escape key" parts down, just not the "use the mbutton as normal if held down part"
Thanks for any help you can provide!
This was a bit of a tricky one. Change the #IfWinExist line accordingly. You can adjust the duration to be what you would consider "holding" MButton
SetTitleMatchMode, 2
#IfWinExist AutoCAD
~MButton::
duration := 100
start := A_TickCount
While(GetKeyState("MButton"))
{
if ((A_TickCount - start) > duration)
{
KeyWait, MButton
Send {MButton Up}
Return
}
}
Send, {Escape}
Return
#IfWinExist AutoCAD
If I understand you right, you are searching for the UP keyword:
The word UP may follow the name of a hotkey to cause the hotkey to
fire upon release of the key rather than when the key is pressed down.
(documentation)
#if autocad()
MButton Up::
send {escape}
return
#if
autocad() {
return true
}
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}
I've search AHK forums but couldn't solution.
The script I found on AHK to use LShift as LButton does not work correctly..when press & hold left shift and move the mouse pointer, it can't copy text exactly like as if click and hold left mouse. What I mean by exactly is.. press & hold left shift and move the mouse pointer copies the whole paragraph or section of text..not just the few words I wanted.
My first time here & newbie w/ AHK. Your time is appreciated.
~Lshift::
Send {LButton}
return
F10::exitapp
you could try:
~Lshift::
Send {LButton Down} ; Press the LButton key Down
KeyWait, LShift ; Wait for the LShift key to be lifted
Send {LButton Up} ; Release the LButton key
return
F10::exitapp