I have a script I'm having trouble combining the logic. What I have is a basically a ruler that measures pixels and converts it to mm using a scale factor. This works great until you zoom. Then I have to convert scale factor with a zoom factor. My problem is I measure using LBUTTON, drag and RELEASE LBUTTON to get a measurement. I also zoom with LBUTTON and RBUTTON and moving the mouse up or down and release. Since I cannot have two Hotkeys of same syntax I need to combine?
Code: Select all
Global ScaleFactor := .4379
Global ZoomFactor := 1
~LButton:: ;hold down Lbutton mouse button to start measuring
mouseGetPos,sx,sy ;start position to measure from
setTimer updatePos,50
return
~LButton Up:: ;release to capture measurement
setTimer updatePos,off
tooltip distance measured is : %distCalibrated% units
clipboard := distCalibrated
return
updatePos:
mouseGetPos,x,y
dx := x-sx
dy := sy-y
dist := round( ((dx)**2 + (dy)**2) **.5 ,2)
distCalibrated := round(dist * scaleFactor,3)
tooltip [%dx%:%dy%]`n%dist% px`n%distCalibrated% units
return
;////////////////FOR Z SCALE FACTOR IN MEASURING
~LButton::
mouseGetPos,,zy
setTimer updatePos,50
While GetKeyState("RButton", "D") {
Gosub, updatePosZ
SetTimer, RemoveToolTip, -1000
}
Return
updatePosZ:
mouseGetPos,,zz
distz := zy-zz
zoomfactor := round(distz,3) / 100
tooltip, % distz
return
Code: Select all
~LButton:: ;hold down middle mouse button to start measuring
mouseGetPos,sx,sy ;start position to measure from
While GetKeyState("RButton", "D") {
mouseGetPos,,zy
setTimer updatePosZ,50
}
setTimer updatePos,50
return
~LButton Up:: ;release to capture measurement
setTimer updatePos,off
tooltip distance measured is : %distCalibrated% units
clipboard := distCalibrated
return
updatePos:
mouseGetPos,x,y
dx := x-sx
dy := sy-y
dist := round( ((dx)**2 + (dy)**2) **.5 ,2)
distCalibrated := round(dist * scaleFactor,3)
tooltip [%dx%:%dy%]`n%dist% px`n%distCalibrated% units
return
updatePosZ:
mouseGetPos,,zz
distz := zy-zz
return
~RButton Up:: ;release to capture measurement
setTimer updatePosZ,off
zoomfactor := round(distz,3) / 100
tooltip, % zoomfactor
SetTimer, RemoveToolTip, -1000
return