I want my autohotkey script to have mouse clicks once i press shift+3 keys on my keyboard, ignoring the shift key being held down.
For example I have attempted it in this way:
+3::
SetMouseDelay, 0
MouseGetPos, xpos, ypos
Send {Shift Up}
BlockInput, on
Send {Shift Up}
MouseClick, right, uhxpos, uhypos
Sleep, 41
MouseClick, left, yourxpos, yourypos
MouseMove, xpos, ypos
BlockInput, off
return
And even tried to wait once the shift is physically released, still no success;
+3::
SetMouseDelay, 0
MouseGetPos, xpos, ypos
KeyWait, +
MouseClick, right, uhxpos, uhypos
Sleep, 41
MouseClick, left, yourxpos, yourypos
MouseMove, xpos, ypos
return
Would appreciate any help, thanks.
Try to send {Shift Down} before {Shift Up} and maybe you should replace Send with SendInput:
+3::
MouseGetPos, xpos, ypos
SetMouseDelay, 0
Sleep, 100
SendInput, {Shift Down}
SendInput, {Shift Up}
MouseClick, right, uhxpos, uhypos
Sleep, 41
MouseClick, left, yourxpos, yourypos
MouseMove, xpos, ypos
Return
use KeyWait, Shift instead of KeyWait, +
Related
I'm trying to create an AutoHotKey script to run some Premiere Pro shortcuts when I press Ctrl+Alt+d but for some reason it opens the Ctrl+Alt+Del windows menu instead. Hoping someone can debug because I can't figure it out.
Here's the script:
^!d::
Send, {Shift down}NumpadDiv{Shift up}
Send, {Shift down}1{Shift up}
Send, {NumpadDiv}
Send, {Shift down}3{Shift up}
Send, {Ctrl down}a{Ctrl up}
Send, {Delete}
Send, {Shift down}1{Shift up}
Send, {Up}
Send, {Enter}
Send, {Down}
Send, {Backspace 3}
Send, SEL
Send, {Enter}
Send, {Down}
Send, {Backspace 11}
Send, STR
Send, {Tab}
Send, {Shift down}o{Shift up}
Send, {Shift down}2{Shift up}
Send, {Shift down}n{Shift up}
return
Thanks in advance!
Fixed this problem by adding
KeyWait Control
KeyWait Alt
To the beginning of my script
I am using the LButton (mouse left) in a keybind as a prefix key. I got it to work, problem is I now need to redefine the LButton as whatever it was in it's natural state...in Autohotkey's terms.
I read this: https://www.autohotkey.com/docs/commands/GetKeyState.htm.
And cameup with the following code, but it's not working at all the way I thought it would. Simply put, you can use $LButton::Send {Click Left} to emulate the basic mouse click. The problem is when you hold the button/key down, nothing happens. I thought the code to emulate, or define the 'pressed down' behaviour would be readily available, but what I've found isn't working.
$LButton::
if (GetKeyState("LButton", "P"))
Send, {Click Left Down} ;tried variants with {Click Left} etc alrdy
else
Send, {Click Left Up}
return
For person in comments:
LButton & ~RButton::
Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return
$LButton:: ;no idea what this shud be
SendInput {Click Left}
;Send, {Click Left Down}
;KeyWait, LButton
;Send, {Click Left Up}
return
RButton::
Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return
Not sure if I understood this correctly, but you want holding LButton, then clicking the RButton to run this code:
Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
And just clicking RButton should run that code as well?
And if LButton is just pressed normally (not in combination with RButton) it should function as normal?
Well this would be it:
~LButton & RButton::
RButton::
Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep, 130
Send, 1
return
Basically just making use of the ~ modifier.
Although I can't speak for Send, 1{Click Right}{Click Left}{Click Right}{MButton}.
I don't know what it's supposed to do, but maybe/hopefully it's doing the right thing.
Pressing w or something that you define should do the job
w::
Send, {Click down}
Send, {Blind}1{Click Right}{Click}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return
Anyone looking for something similar could try in this direction
#SingleInstance force
#warn
r::Reload
x::ExitApp
w::
Send, {Click down}
Send, {Blind}1{Click Right}{Click}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return
just Pressing w should do the job
Alternately
, the below one will do the same
LButton::Send, {Click down}
RButton::
if GetKeyState("LButton", "P")
{
Send, {Blind}1{Click Right}{Click}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
}
else
Send, {Click Right}
return
Hello I am fairly new to coding and I’m making a programme for a game I play on AHK, I’m trying to code a script so that when a pixel changes colour on my screen the script will completely stop whilst remaining part of the loop. The main code works but I've tried to add a system where the script will stop running if a pixel changes colour. Thanks for the help in advance.
Esc::ExitApp
+r::
sleep, 1000
Send, {e down}
Send, {e up}
sleep, 10750
loop {
PixelGetColor, color1, 949, 269
if(color1 = “0xA6A6A6”)
sleep, 500
SendInput {Esc}
IfWinActive ahk_exe FiveM_GTAProcess.exe
sleep, 5550
Send, {e down}
Send, {e up}
sleep, 500
MouseClick Left, 649, 390
sleep, 500
MouseClick Left, 964, 484
sleep, 500
MouseClick Left, 1311, 415
sleep, 500
loop, 4
{
MouseClick Left, 964, 484
sleep, 500
}
sleep, 500
MouseClick Left, 720, 415
sleep, 500
}
Add Break after your if:
if(color1 = “0xA6A6A6”)
Break
if(color1 = “0xA6A6A6”)
{
sleep, 500
SendInput {Esc}
}
I just want this loop to work when LButton is down and stop when LButton is up.I
The code works when LButton is down but it continues working when i lift my finger off the left click button.
mem:=0
~*LButton::
Sleep, 100
KeyWait, LButton, T0.10
If ErrorLevel = 1
{
While GetKeyState("LButton","P")
Loop {
GetKeyState, state, LButton, P
If state = U
Break
MouseGetPos, xpos, ypos
if (xpos > mem) ;moved right
{
send, {a down} ;send key
mem:=xpos
}
else
send, {a up}
if (xpos < mem) ;moved left
{
send, {d down}
mem:=xpos
}
else
send, {d up}
Sleep, 100
}
}
return
You case is very similar to the example of the usage of the while loop.
If you look at that you can see, you don't need the Loop inside the while. Just have
while GetKeyState("LButton")
{
; Your code here:
MouseGetPos, xpos, ypos
if (xpos > mem) ;moved right
{
send, {a down} ;send key
mem:=xpos
}
else{
send, {a up}
}
if (xpos < mem) ;moved left
{
send, {d down}
mem:=xpos
}
else{
send, {d up}
}
Sleep, 100
}
I want to create a set of mouse movements assigned to the four arrow keys where a keystroke will click and drag one pixel left, right, up, or down. The starting point will be variable. I have no idea how to accomplish this. I gave it a sort of good faith try before asking, but I really need to ask somebody to show me how to do it.
Thanks,
Ellen
Ellen, here we go:
#Persistent
^NumPadUp::
Send, {LButton Down}
MouseMove, 0, -1, 1, R ;Move the mouse one pixel Up
Send, {LButton Up}
Return
^NumPadDown::
Send, {LButton Down}
MouseMove, 0, 1, 1, R ;Move the mouse one pixel Down
Send, {LButton Up}
Return
^NumPadRight::
Send, {LButton Down}
MouseMove, 1, 0, 1, R ;Move the mouse one pixel to the right
Send, {LButton Up}
Return
^NumPadLeft::
Send, {LButton Down}
MouseMove, -1, 0, 1, R ;Move the mouse one pixel to the left
Send, {LButton Up}
Return