Hello! I would like help in creating an ahk script that simulates two different key press processes whenever I press the alt+a hotkey.
When I press alt+a, I would like the following sequence to process first:
Send +{F3}
Send F4
Move mouse to stored position 1
Send LButton
Send F3
And if I press alt+a again:
Send +{F3}
Send F2
Move mouse to stored position 2
Send Lbutton
Send F3
Pressing alt+a will simply go back and forth between these two processes. The stored positions are mouse cursor positions, exactly where the mouse cursor pointer is located.
To get stored position 1, I would like Send +{F2} to record the mouse cursor position 1 whenever it is pressed. It only has to save the most recently recorded position.
To get stored position 2, I would like Send +{F4} to record the mouse cursor position 2 whenever it is pressed. It only has to save the most recently recorded position.
I made my own version of this ahk but it was terrible. It was not accurate at all. Sometimes the process would click the wrong thing or inputs would not go through. If you could please help, I would greatly appreciate it. Thank you!
Simulate key presses with one hotkey Topic is solved
Re: Simulate key presses with one hotkey
Code: Select all
#Requires AutoHotkey v1.1.33
CoordMode Mouse
!a::
If on := !on {
Send +{F3}{F4}
MouseMove x1, y1
} Else {
Send +{F3}{F2}
MouseMove x2, y2
}
Send {LButton}{F3}
Return
+F2::
MouseGetPos x1, y1
SoundBeep 1500
Return
+F4::
MouseGetPos x2, y2
SoundBeep 1200
Return
Re: Simulate key presses with one hotkey
@mikeyww
Thanks for your help.
For some reason it works when I record the two mouse positions in the same location, but when I split them up into different locations, it doesn't work. I am not sure why this is happening because the code is very straightforward.
Thanks for your help.
For some reason it works when I record the two mouse positions in the same location, but when I split them up into different locations, it doesn't work. I am not sure why this is happening because the code is very straightforward.
Re: Simulate key presses with one hotkey Topic is solved
Test in Notepad. Use only this script with no additional code. Copy and paste all of the code that is posted. Close other scripts.
Testing just the mouse moves is simple, as follows.
I generally find "it doesn't work" to be a non-statement: it says nothing about what happens, or what doesn't happen. What happens? Nothing? Something?
Testing just the mouse moves is simple, as follows.
Code: Select all
#Requires AutoHotkey v1.1.33
CoordMode Mouse
!a::
If on := !on {
; Send +{F3}{F4}
MouseMove x1, y1
} Else {
; Send +{F3}{F2}
MouseMove x2, y2
}
; Send {LButton}{F3}
Return
+F2::
MouseGetPos x1, y1
SoundBeep 1500
Return
+F4::
MouseGetPos x2, y2
SoundBeep 1200
Return
Re: Simulate key presses with one hotkey
This worked perfectly. thank you!