Can someone help me with my autohotkey script? I tried looking online for loop scripts, however when i activate it, it never stops. Even when i assign an stop command. I would like to assign the stop command to F1. Thank you
^!r::
WinWait, BlueStacks App Player,
IfWinNotActive, BlueStacks App Player, , WinActivate, BlueStacks App Player,
WinWaitActive, BlueStacks App Player,
MouseClick, left, 335, 574
Sleep, 100
MouseClick, left, 191, 134
MouseClick, left, 191, 134
Sleep, 100
MouseClick, left, 191, 134
Sleep, 100
Send, {CTRLDOWN}v{CTRLUP}{ENTER}
MouseClick, left, 29, 47
Sleep, 100
MouseClick, left, 104, 128
MouseClick, left, 104, 128
Sleep, 100
Send, {CTRLDOWN}v{CTRLUP}{ENTER}
MouseClick, left, 24, 58
Sleep, 100
MouseClick, left, 24, 58
Sleep, 100
return
Try:
F1::Reload
and make sure your hotkey doesn't accidentally trigger itself by sending ^!r.
Your looping structure is not allowing the escape hotkey to be called. Additionally try adding a pause:
p::Pause
If you can get your program to pause then add an exit:
Esc::ExitApp
Related
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
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
I'm scripting some pre-determined Clicks and Sends at a specific window.
Sometimes a click will not end up at the desired location, it may click on a different window and now all subsequent inputs from my script will be sent to the wrong window/location.
Here is the executing part of the code which I can't seem to make 100% consistent.
CoordMode, Mouse, Window
SetTitleMatchMode, 2
<!p::
Click, 60, 270
Send, %dp%{Tab}{Tab}{Tab}{Tab}%e1%{Tab}^a ; Plate thickness and layout
Send, %PLh% ; Plate Height
Click, 60, 130
Sleep 100
Click, 263, 45
Sleep 20
Click, 263, 45
Sleep 20
Click, 370, 48
Sleep 100
Click, %Mx%, %My% ; Bolt Diameters (M16: 40, 135) (M20: 40, 150) (M24: 40, 170) (M27: 40, 190) (M30: 40, 210)
Sleep 50
Click, 60, 160
Send, {Tab}{Tab}{Tab}%w1%{Tab}{Tab}^a ; Hor Bolt center distance
Sleep 50
Send, 0{Tab}^a ; Edge distance
Send, 0 ; Edge distance
Sleep 100
Click, 60, 190
Sleep 100
Send, {Tab}{Tab}%e3% ; Vert interm distance
Send, {Tab}{Tab}{Tab}{Tab}{Tab}%e2% ; vert outside bolt dist
Click, 60, 295
Sleep 100
Send, {Tab}%Stiff%{Tab}{Tab}{Tab}%Stiff% ; Stiffener thickness
Sleep 100
Click, 60, 320
Sleep 100
Send, %Weld%{Tab}{Tab}{Tab}%Weld%{Tab}{Tab}%Weld%{Tab}{Tab}%Weld%{Tab}{Tab}%Weld% ; Weld thickness
Return
If any of the clicks in this section of code result in activating an undesired window then I would like my script to stop and give a warning.
I could insert an If Winactive statement for every click, but that feels very inelegant to me, perhaps there is a better solution?
(I could also ask how to make this script more consistent which I've already tried to do by inserting Sleep commands, but that's a different question. The main culprit seems to be clicking drop-down boxes, but it's tough to determine that since I can't debug AHK code by running line-by-line)
Thanks in advance
So kindly enough Yane pointed me in the direction of "Controlsend" and "Controlclick" which covers the problem I was having.
Instead of using, for example:
Click, 60, 300
One can force a click in a specific window like this:
ControlClick, x60 y300, MyDesiredWindow'sTitle
Furthermore, to fix my specific case of a Click on a dropbox throwing off the rest of the script, the following can be used:
ControlClick, ComboBox1, MyDesiredWindow'sTitle
This will Click a specific control in a specific window. (use Window Spy to identify windows and controls)
I guess my question is largely irrelevant when properly making use of ControlSend and other AHK commands and practices.
It seems to me that it's possible to directly answer the question in the title and, although my answer doesn't really do that, I will accept my own answer when it becomes possible for me to do so because it did solve my problem.
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.
I'm trying to make autohotkey click a certain screen region, every 45 minutes. I've come up with this, but it seems not to respond correctly.
Can anyone offer suggestions?
Loop,99
{
MouseClick, left, 392, 735
Sleep 2700000
}
Return
When you say doesn't respond correctly, can you be more specific? Is your loop not working, is the timer giving you issues or is the mouseclick not working. In some browsers, I've noticed that you might need to play around with mouseclicking (there are various ways to simulate a mouseclick [up to sending raw code] and there are timers to set the click time).
If you want the loop to indeed only run 99 times, you might need to add a counter in my example, but your objective cab be done with the settimer command.
SetTimer, MyMouseClick, 2700000 ; Run every 2700 seconds
Return
MyMouseClick:
MouseClick, left, 392, 735
Return
Alternative with 99 limit.
MyCounter := 0
SetTimer, MyMouseClick, 2700000 ; Run every 2700 seconds
Return
MyMouseClick:
MyCounter++
MouseClick, left, 392, 735
If (MyCounter = 100)
SetTimer, MyMouseClick, Off
Return
If you want to click a fixed screen coordiate, than make sure you are using CoordMode, Mouse, Screen. A script starts with a default of Relative.
CoordMode
CoordMode, Mouse, Screen
Loop, 99
{
MouseClick, left, 42, 34
Sleep 2000
}
Return
F12::ExitApp