Sorry but do you know what your change actually do?
If this is your whole script(without LButton as a hotkey to start the loop
If you don't have a hotey set,the loop will constantly get the mouse position(I think every 20ms)and do nothing until press LButton and after that since the next condition is "if GetKeyState("LButton", "D")" which means the left mouse button,the script will get the same coordinates as SX and SY even if you move the mouse and since you are getting the same values,the " If((SX != X) or (SY != Y)) " will never be true
AHK does have a click and drag feature but not in a single function(as far as I know)
Open paint and press F1 after you run this script and do a dragging once(click somewhere and move the mouse as many times as you want).
When you release the button,press F1 to stop the recording and the code with your last mouse drag will be in the clipboard,ready to be pasted into a ahk file and run it by pressing Esc when the paint window is active(while the repeating code is running,your mouse movements will be blocked until the script is done dragging)
Code: Select all
F1::
Keywait,F1
If Recording = 1
{
Tooltip,
Recording =
Return
}
Recording += 1
Tooltip,Recording,0,0
Return
#If (Recording = "1")
~LButton::
List =
MM =
WinGet,EXE,Processname,A
MouseGetPos,SX,SY
While GetKeyState("LButton","D")
{
MouseGetPos,X,Y
If ((X != X2) or (Y != Y2))
List .= X "|" Y "`n"
MouseGetPos,X2,Y2
}
Loop,Parse,List,`n
{
If A_LoopField =
Break
StringSplit,PoS,A_LoopField,|
If A_Index = 1
MM .= "#IfWinActive,ahk_exe " EXE "`nEsc::`nKeywait,Esc`nBlockInput,MouseMove`nMouseMove," Pos1 "," PoS2 ",0`nSend,{LButton Down}`n"
Else
MM .= "MouseMove," Pos1 "," PoS2 ",0`n"
}
MM .= "Send,{LButton Up}`nBlockInput,MouseMoveOff`nReturn"
Clipboard := MM
REturn