When I hold down left mouse button I would like for the right mouse button be held down also.
The right mouse would then release when the left mouse is no longer being held. So both buttons can be controlled simultaneously with the left click.
LButton::RButton means Left Button acts like your Right Button. The ~ modifier means "Fire the hotkey as well as whatever it's remapped to".
~LButton::RButton
Quick edit: If you need it to activate after Left Button has been held for a certain amount of time, use this:
; Time for LButton to be held down before RButton is sent (in milliseconds)
waitTime := 500
return
~*LButton::
while GetKeyState("LButton", "P")
if (A_TimeSinceThisHotkey > waitTime){
Send, {RButton Down}
KeyWait, LButton
Send, {RButton Up}
}
return
Related
I'm trying to make a macro that clicks and holds "W" key and "RMB" when "RMB" is being held.
So far I've came up with something like this:
RButton::
if( not GetKeyState("RButton" , "P") )
Click, down, right
Send {w down}
return
RButton Up::
Click, up, right
Send {w up}
This only holds "W" key, but not "RMB".
I would appreciate some help.
RMB - Right mouse button
When using three different methods of holding down the left mouse button:
Mouseclick, left, 0, 0, 1, , D, R
or
Send {LButton down}
or
Click down
the game I'm making a macro for logs me out complaining that I'm sending too many actions. I tested this by itself as a script, like:
F3::
Click down
return
So there's no chance other code is causing it.
I was wondering if there are any settings I can use (by settings I mean like CoordMode, Mouse, Screen) or any other solution to perhaps prevent whatever rapid event sending AHK is using to simulate a mouse button being held down. Is there any possible fix I can try? I'm open to testing any ideas.
Well, you could introduce a Sleep like so:
LButton::
while (GetKeyState("LButton", "P"))
{
MouseClick, left
Sleep, 100
}
return
Though I personally dislike binding the mouse click to behaviours via the same mouse click, as it can lead to results that are difficult to get out of.
Here's an example with a toggleable hotkey.
Insert::
SendInput, {LButton Down}
loop
{
Sleep, 100
if getkeystate("Insert", "p") ; Hold for a second as the Sleep will delay recognition.
{
SendInput, {LButton Up}
break
}
}
return
Edited per the comments:
Insert::
SendInput, {LButton Down}
KeyWait, Insert, D
SendInput, {LButton Up}
return
I'm looking to make the right mouse button send a single keystroke on DOWN, and another separate, single keystroke on UP.
"Pseudo-code" example, where pressing down right mouse button toggles an eyedropper tool by sending its hotkey (i), and releasing right mouse button sends the hotkey for brush (b):
RButton down::
Send i ; Send eyedropper hotkey
RButton up::
Send b ; Send brush hotkey
I understand from other questions asked that a while loop using GetKeyState could get part way there, but the while loop causes the key to fire rapidly, which is not desired.
How do I make the right mouse button send its corresponding up/down hotkey only once on up/down?
; RIGHT BUTTON HOTKEY
RButton::
GetKeyState, state, RButton, P ;GET RIGHT MOUSE BUTTON STATE
if state = D ;IF BUTTON STATE = DOWN
{
SetTimer, CheckRButtonState, 10 ;SET TIMER TO MONITOR WHEN IT WAS RELEASED
Goto, RButtonDown ;JUMP TO SUBROUTINE FOR BUTTON STATE = DOWN
}
return
; TIMER
CheckRButtonState: ;TRIGGERED BY TIMER IN EVERY 10 MILLISECONDS
GetKeyState, state, RButton, P ;GET RIGHT MOUSE BUTTON STATE
if state = U ;IF BUTTON STATE = UP
{
SetTimer, CheckRButtonState, Off ;STOP TIMER
Goto, RButtonUp ;JUMP TO SUBROUTINE FOR BUTTON STATE = UP
}
return
; SUBROUTINE FOR RIGHT BUTTON PRESSED
RButtonDown:
TrayTip,Down, %state% ;PUT HERE THE TASKS YOU WANT IT TO PERFORM WHEN BUTTON IS DOWN
return
; SUBROUTINE FOR RIGHT BUTTON RELEASED
RButtonUp:
TrayTip,Up, %state% ;PUT HERE THE TASKS YOU WANT IT TO PERFORM WHEN BUTTON IS UP
return
I want to have a script which will intercept a mouse click and send a key press instead, but only when the capslock key is toggled on. I want the mouse click to be sent normally if the capslock key is toggled off.
Currently I have made this:
$LButton::
if GetKeyState("CapsLock", "T") = 1
send, {a}
else
send, {LButton}
return
The problem with this is that when the capslock key is off, the left button can click perfectly normally but it cannot drag.
If I change $ to ~, it is able to drag but it also performs a click when the capslock key is toggled on.
Is there any way to make the script ignore the click completely if the capslock key is toggled off?
AHK_L's #If will give you what you want:
#If GetKeyState("CapsLock", "T")
LButton::Send, a
With this code, you won't have to bother what happens when capslock is off. AHK will intercept the click on a lower level and let it trickle through.
How to use the symbol UP.
SetBatchLines, -1 ; you pretty much have to include this to speed up the execution
LButton::
if( GetKeyState("CapsLock", "T") )
tooltip, ignore left click
else
send, {LButton Down}
return
LButton UP::
send, {LButton Up}
return
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