Skip to content

Instantly share code, notes, and snippets.

@daynebatten
Last active August 29, 2015 14:13
Show Gist options
  • Save daynebatten/3040752e36473f28c828 to your computer and use it in GitHub Desktop.
Save daynebatten/3040752e36473f28c828 to your computer and use it in GitHub Desktop.
Tells you how far your mouse moves. I wrote this in high school, so it's pretty terrible. You've been warned.
AppTitle "Mouse Distance"
file=ReadFile("distance.ini")
Global custom=ReadLine(file)
Global width=ReadLine(file)
Global height=ReadLine(file)
Global writedelay=ReadLine(file)
Global inches#=ReadLine(file)
Global feet=ReadLine(file)
Global miles=ReadLine(file)
CloseFile(file)
invisiblewindow=CreateWindow("",-100,-100,0,0,Desktop(),16)
window=CreateWindow("",ClientWidth(Desktop())-100,0,100,15,invisiblewindow,0)
canvas=CreateCanvas(0,0,100,15,window)
xinchesperpixel#=Float(width)/ClientWidth(Desktop())
yinchesperpixel#=Float(height)/ClientHeight(Desktop())
oldmousex=MouseX()
oldmousey=MouseY()
oldmousexinches#=oldmousex*xinchesperpixel
oldmouseyinches#=oldmousey*yinchesperpixel
xinchesperpixel#=Float(width)/ClientWidth(Desktop())
yinchesperpixel#=Float(height)/ClientHeight(Desktop())
timer=CreateTimer(1)
While Not endvar=1
Delay(1)
If (MouseX()<>oldmousex Or MouseY()<>oldmousey) And Abs(MouseX() - oldmousex) < 2000 And Abs(MouseY() - oldmousey) < 2000
mousexinches#=MouseX()*xinchesperpixel
mouseyinches#=MouseY()*yinchesperpixel
inches=inches+Sqr((mousexinches-oldmousexinches)^2+(mouseyinches-oldmouseyinches)^2)
feet=feet+(inches-(inches Mod 12))/12
inches=inches Mod 12
miles=miles+(feet-(feet Mod 5280))/5280
feet=feet Mod 5280
SetBuffer(CanvasBuffer(canvas))
Cls
Text(0,0,miles+":"+feet+":"+Int(inches))
FlipCanvas(canvas)
End If
oldmousex=MouseX()
oldmousey=MouseY()
oldmousexinches=oldmousex*xinchesperpixel
oldmouseyinches=oldmousey*yinchesperpixel
If TimerTicks(timer)>writedelay
file=WriteFile("distance.ini")
WriteLine(file,1+" -Leave this value as is")
WriteLine(file,width+" -Screen Width (inches)")
WriteLine(file,height+" -Screen Height (inches)")
WriteLine(file,writedelay+" -File Update Frequency (seconds)")
WriteLine(file,inches+" -Travelled Inches")
WriteLine(file,feet+" -Travelled Feet")
WriteLine(file,miles+" -Travelled Miles")
CloseFile(file)
ResetTimer(timer)
End If
Wend
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment