Auto Hot Key.. Button Holding? - autohotkey

My brain is borderline flat and I'm having no luck understanding what Up and Down mean. I only want the hotkey to hold left click for whatever amount of time. If anyone could provide the code used for that and maybe a short explanation of how Up and Down work (r/explainlikeim5) that would be greatly appreciated. :)

$Lbutton:: ;when you push left mouse button(Can be changed)
Sendinput, {LButton down} ; holds left mouse button down
Sleep, 1000 ; delay in miliseconds(1 second delay)
Sendinput, {LButton up} ; releases left mouse button
Return
There you go sir.

Related

Autohotkey: WinMenuSelectItem not working on Figma

Hope someone can help me with this.
I am trying to use Autohotkey to automate some menu navigation within figma.
Point is that the "WinMenuSelectItem" function somehow doesn't work.
While searching for this, i found a script to detect any clicked menu item, and tell its position.
Turns out that none of the menu items, were detected.
it made me suspect that probably Figma's Windows app is just a disguised web browser, so i have to approach this differently.
A solution could be to create my shortcuts through mouse position, but i once i switch screens, all the positioning will be messed.
Can someone help me?
Thank you!
Edit: As request, im going to paste the code i have right now.
But is almost of no use, as now i am using mouse movement to click on menu items, and this solution is both slow (on performing time) and as soon as i change screen resolution, those coordinates render useless.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
^!+f1:: ; Go to main component
SendEvent {Click 28 63}
sleep, 100 ;
SendEvent {Click 93 228}
sleep, 400 ;
SendEvent {Click 291 464}
sleep, 100 ;
SendEvent {Click 550, 463}
CoordMode, Mouse, Screen
MouseMove, (A_ScreenWidth // 2), (A_ScreenHeight // 2)
return
^!+f2:: ; Plugin Papa component
SendEvent {Click 28 63}
sleep, 100 ;
SendEvent {Click 93 338}
sleep, 400 ;
SendEvent {Click 296 535}
sleep, 100 ;
CoordMode, Mouse, Screen
MouseMove, (A_ScreenWidth // 2), (A_ScreenHeight // 2)
return
^!+f3:: ; Copy Prototype link
SendEvent {Click 2374 69}
sleep, 400 ;
SendEvent {Click 1109 506}
return

How can i MouseClickDrag position while holding Ctrl+Windows key ? Autohotkey

Please, how can i hold Windows+Ctrl key while MouseClickDraging?
Here is the code:
Send, {Win Ctrl Down}
CoordMode, mouse, screen
MouseClickDrag, left, 3181, 326 , 3769, 642
Thanks
You need to ensure that the hotkey you use to trigger the logic does not conflict with the keys you want to send, ie. don't use Win or Ctrl. With that being said, the following example uses F3. For the Win key, you need to specify left or right. Since it doesn't seem to be of importance, the example just assumes LWin.
CoordMode, mouse, screen
F3::
Send, {LWin down}{Ctrl down}
MouseClickDrag, left, 3181, 326 , 3769, 642
Send, {Ctrl up}{LWin up}
return

pressing Q should be Q + MB RightClick

I was wondering if this can be done in AutoHotKey that whenever I press Q the output should be Q and mouse right click. I tried
Q::MouseClick, right but this doesnt do the Q keystroke. Any help is appreciated.
As well as ~ you can send the ASCII character
q::
Send, {Asc 113}
mouseclick, right
return

SetKeyDelay for Mouse Wheel

I want to scroll a page 5 times, with a small delay after each scroll. But instead of this, the page is scrolled without delays. Why?
~+PgDn::
SetKeyDelay, 50
Send, {WheelUp 5}
Return
For mouse clicks, SetMouseDelay should be used, but apparently WheelUp and WheelDown don't count as clicks so it won't work for them.
Use a Sleep command and a Loop instead:
Loop, 5
{
Send, {WheelUp}
Sleep, 50
}
Consider wrapping this into a function for convenience.

Trigger AHK script based on the position of the mouse

Is it possible to trigger an AHK script based on the position of the mouse? Say, if I wanted to press a button or series of buttons on my keyboard if I move my mouse to the corner or edge of the screen. Also, can this be done multiple times per second until the mouse is moved out of the specified area?
All I could find from googling is AHK scripts for moving the mouse using the keyboard, when I want to do the opposite.
I did it, thanks Aaron and ahkcoder.
I got a little better feel with Up and Down instead of PgUp and PgDn, to anyone else, play with the timings until it's sufficient. You'll also need to modify the values for the edges of your screen.
; move up and down when mouse is at edges of screen
#Persistent
SetTimer, foo, 65
return
foo:
MouseGetPos, x, y, id, control
; ToolTip, %x% %y%
; will trigger only at edges of a full screen
if (y = 1087){
; bottom
send {Down}
send {Down}
send {Down}
; sleep, 300
}
else if(y = 8){
; top
send {Up}
send {Up}
send {Up}
}
return
Yes. Easiest way I can think of to do what you are asking is to use SetTimer and MouseGetPos to evaluate the position and if it matches than trigger your script.
The 2nd example code on the MouseGetPos is using SetTimer. This should get you headed in the right direction.