by davidahlstroem » 19 Aug 2024, 15:07
Mouse drag rotate camera. Test post
Code: Select all
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
; Speed settings in pixels per loop iteration
speeds := {1: 1, 2: 3, 3: 5, 4: 10} ; Very slow, Slow, Normal, Fast
currentSpeed := 3 ; Default to normal speed
dragging := false
autoRotateLeft := false
autoRotateRight := false
; Toggle speed with F1 key
F1::
currentSpeed := (currentSpeed + 1 > 4) ? 1 : currentSpeed + 1
return
; Rotate camera left with Left Arrow key
Left::
dragging := true
While dragging {
MouseMove, -speeds[currentSpeed], 0, 0, R
Sleep, 10 ; Control the smoothness of the rotation
}
return
; Rotate camera right with Right Arrow key
Right::
dragging := true
While dragging {
MouseMove, speeds[currentSpeed], 0, 0, R
Sleep, 10 ; Control the smoothness of the rotation
}
return
; Stop camera rotation when arrow keys are released
Left Up::dragging := false
Right Up::dragging := false
; Auto-rotate camera left with Shift + Left Arrow key
+Left::
autoRotateLeft := !autoRotateLeft
if (autoRotateLeft) {
SetTimer, AutoRotateLeft, 10
} else {
SetTimer, AutoRotateLeft, Off
}
return
; Auto-rotate camera right with Shift + Right Arrow key
+Right::
autoRotateRight := !autoRotateRight
if (autoRotateRight) {
SetTimer, AutoRotateRight, 10
} else {
SetTimer, AutoRotateRight, Off
}
return
; Function for auto-rotating left
AutoRotateLeft:
MouseMove, -speeds[currentSpeed], 0, 0, R
return
; Function for auto-rotating right
AutoRotateRight:
MouseMove, speeds[currentSpeed], 0, 0, R
return
Mouse drag rotate camera. Test post
[code]#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
; Speed settings in pixels per loop iteration
speeds := {1: 1, 2: 3, 3: 5, 4: 10} ; Very slow, Slow, Normal, Fast
currentSpeed := 3 ; Default to normal speed
dragging := false
autoRotateLeft := false
autoRotateRight := false
; Toggle speed with F1 key
F1::
currentSpeed := (currentSpeed + 1 > 4) ? 1 : currentSpeed + 1
return
; Rotate camera left with Left Arrow key
Left::
dragging := true
While dragging {
MouseMove, -speeds[currentSpeed], 0, 0, R
Sleep, 10 ; Control the smoothness of the rotation
}
return
; Rotate camera right with Right Arrow key
Right::
dragging := true
While dragging {
MouseMove, speeds[currentSpeed], 0, 0, R
Sleep, 10 ; Control the smoothness of the rotation
}
return
; Stop camera rotation when arrow keys are released
Left Up::dragging := false
Right Up::dragging := false
; Auto-rotate camera left with Shift + Left Arrow key
+Left::
autoRotateLeft := !autoRotateLeft
if (autoRotateLeft) {
SetTimer, AutoRotateLeft, 10
} else {
SetTimer, AutoRotateLeft, Off
}
return
; Auto-rotate camera right with Shift + Right Arrow key
+Right::
autoRotateRight := !autoRotateRight
if (autoRotateRight) {
SetTimer, AutoRotateRight, 10
} else {
SetTimer, AutoRotateRight, Off
}
return
; Function for auto-rotating left
AutoRotateLeft:
MouseMove, -speeds[currentSpeed], 0, 0, R
return
; Function for auto-rotating right
AutoRotateRight:
MouseMove, speeds[currentSpeed], 0, 0, R
return[/code]