I needed to make a script to do some drag n drop. The requirement is One key (the end key in my case) to start the script when pressed first time,
when pressed 2nd time to stop the script. And when pressed again, it must start from the begining.
While i did some search on internet, ive found this post (https://autohotkey.com/board/topic/83563-solved-start-stop-and-restart-a-loop-from-the-beginning/)
Which at the begining seems to work ok. But, problem starts when i press the hotkey more than 3 times. Ath the 4th time, it stops working and needs to reload it again.
I tried to replace the Reload command within the IF, but seems to loosing the drag n drop coords.
The whole script is:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force
#MaxThreadsPerHotkey 2
Return ;<-- forced end of autoexecute section
;------------------------------------------------
; when you press f3 the first time the loop runs.
; when you press it the 2nd time it flips the f3Run flag and stops the loop
; if you press it a 3d time it restarts the loop from the beginning.
;------------------------------------------------
END::
ENDRun := !ENDRun
If (!ENDRun)
Return
While (ENDRun)
{
WinActivate, ahk_class tooltips_class32
Sleep, 333
SetDefaultMouseSpeed, 8
WinActivate, program-name ahk_class triuiScreen
SendEvent {Click 1252, 891, down}{click 1146, 698, up}
Sleep, 72000
}
Return
Any advice please?
Thanks in Advance
[Mod edit: Moved to 'Ask for Help' and [code][/code] tags added]