Mouse Drag n'Drop script problem

Get help with using AutoHotkey and its commands and hotkeys
Typical-User
Posts: 8
Joined: 15 Jun 2019, 06:38

Mouse Drag n'Drop script problem

15 Jun 2019, 06:56

Hi everyone

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]
Typical-User
Posts: 8
Joined: 15 Jun 2019, 06:38

Re: Mouse Drag n'Drop script problem

16 Jun 2019, 03:55

Problem Solved.
Just increased the #MaxThreadsPerHotkey up to 100.

Return to “Ask For Help”

Who is online

Users browsing this forum: Clemens375, Xeo786 and 35 guests