Foro | | | | - Página 1 - |
|  funkheld | ¡Hola, guten Tag. Yo habe una kombinationsproblem con ratón.
Yo habe encima el Schwungrad de mi Trimmrad una optische Mausplatine befestigt(5 Euro-Ratón). El Befestigung es así, el, si yo trete, el Mausposition de y-0 después de y-Max va.
¿Cómo se puede uno lo hacer, el el Ratón zb en y=0 gesetzt se y en y>500 una Zähler gezählt se y el Ratón entonces otra vez en y=0 gesetzt se. Dies entonces en uno Bucle abläuft.
Diese kombination bekomme Yo no hin, porque el Ratón en una cierta Geschwindigkeit überfordert es, ellos zählt entonces no mehr más. Mit "sleep 1" es auch no.
Woran liegt el. Yo compiliere con XPSE. KompilierenMarcaSeparación {$cleq}
Def @Getcursorpos(1) !"user32","GetCursorPos"
Def @Setcursorpos(2) !"USER32","SetCursorPos"
Struct Mauskoordinaten = X&,Y&
Declare Xpos&,Ypos&,Curpos#,zaehler&
Windowstyle 31
Windowtitle "Cursorposition ermitteln"
Window 200,0 - 440,440
@Setcursorpos (100,0)
While 0 = 0
Sleep 5
Dim Curpos#,Mauskoordinaten
@Getcursorpos(Curpos#)
Xpos& = Curpos#.X&
Ypos& = Curpos#.Y&
if Ypos& > 500
@Setcursorpos (100,0)
zaehler&=zaehler&+1
endif
Dispose Curpos#
Drawtext 0,0,"Zähler: " + zaehler& + @Space$(30)
Endwhile
Gracias.
Gruss |
| | | | |
| | | | - Página 2 - |
|  | « Dieser Contribución wurde como Solución gekennzeichnet. » | | - Página 1 - |
|  | @Funkheld: Hab Usted hier algo el Strecke misst... algo como?
Descargar KompilierenMarcaSeparación {$cleq}
Windowstyle 31
Windowtitle "Cursorposition ermitteln"
Window 500,500
setcursorpos((winRight-winLeft)\2+winLeft,(winBottom-winTop)\2+winTop)
var modified&=0
var strecke&=0
var my2MousePositions&=globalAlloc(gPTR,16)
getCursorPos(my2MousePositions&)
rtlMoveMemory(my2MousePositions&+8,my2MousePositions&,8)
while 1
waitinput 10
getCursorPos(my2MousePositions&)
settext hWnd,"X:"+str$(long(my2MousePositions&,0))+" Y:"+str$(long(my2MousePositions&,4))+" Strecke:"+str$(strecke&)
add strecke&,abs(long(my2MousePositions&,0)-long(my2MousePositions&,8))+abs(long(my2MousePositions&,4)-long(my2MousePositions&,12))
if long(my2MousePositions&,0) > winRight
long my2MousePositions&,0=winLeft
inc modified&
endif
if long(my2MousePositions&,0) < winLeft
long my2MousePositions&,0=winRight
inc modified&
endif
if long(my2MousePositions&,4) < winTop
long my2MousePositions&,4=winBottom
inc modified&
endif
if long(my2MousePositions&,4) > winBottom
long my2MousePositions&,4=winTop
inc modified&
endif
if modified&
modified&=0
setCursorPos(long(my2MousePositions&,0),long(my2MousePositions&,4))
endif
rtlMoveMemory(my2MousePositions&+8,my2MousePositions&,8)
wend
globalFree(my2MousePositions&)
f='./../../funktionsreferenzen/XProfan/end/'>end
Si usted el add strecke Línea dahin änderst: KompilierenMarcaSeparaciónadd strecke&,(long(my2MousePositions&,0)-long(my2MousePositions&,8))+(long(my2MousePositions&,4)-long(my2MousePositions&,12))
(also sin abs), Luego se el rückwärtsgefahrene Strecke auch de el Streckenlänge subtrahiert en lugar de a Streckenlänge addiert.
PS: En XPSE necesidad el ganzen Standard-APIs no deklarieren y es incluso sinnvoller lo entonces auch no a tun como el Aufrufe en deutlich schnellere Calls umgewandelt voluntad. |
 | | | | |  |
| |  | Schau veces tal vez así:
Descargar
 KompilierenMarcaSeparación {$cleq}
decimals 2
Windowstyle 31
Windowtitle "Cursorposition ermitteln"
window (maxx-500),(maxy-100)
setcursorpos((winRight-winLeft)\2+winLeft,(winBottom-winTop)\2+winTop)
var speed.realPixelSpeed!=0
var speed.forShow!=0
var tmp&=0
var tmp2&=479
var tme&=getTickCount
var tme.start&=getTickCount
var modified&=0
var strecke&=0
var my2MousePositions&=globalAlloc(gPTR,16)
getCursorPos(my2MousePositions&)
rtlMoveMemory(my2MousePositions&+8,my2MousePositions&,8)
mcls 640,480,0
while 1
if tme&<getTickCount
add tme&,100// nur alle 100ms etwas tun
speed.realPixelSpeed!=(strecke&-tmp&)*0.5+speed.realPixelSpeed!*0.5
speed.forShow!=speed.realPixelSpeed!*0.001
tmp&=strecke&
startpaint -1
usefont "Arial",50,0,0,0,0
textcolor $FFFF,0
drawtext 10,10,"Race: "+str$((getTickCount-tme.start&)\1000)+" Sekunden"
drawtext 10,60,"Strecke: "+str$(strecke&*0.0001)+" Meter"
drawtext 10,110,"Geschw.: "+str$(speed.forShow!)+" km/h"
drawtext 10,160,"ø Geschw.: "+str$((strecke&*0.0001)/(1+(getTickCount-tme.start&)\1000))+" Meter/s "
textcolor $00FF00,-1
drawtext 10,10,"Race:"
drawtext 10,60,"Strecke:"
drawtext 10,110,"Geschw.:"
drawtext 10,160,"ø Geschw.:"
copybmp 1,240 - 640,240 > 0,240;0
usepen 0,0,$00FF00
line 637,tmp2& - 638,(479-speed.realPixelSpeed!*0.02)
tmp2&=479-speed.realPixelSpeed!*0.02
endpaint
mcopysizedbmp 0,0 - 640,480 > 0,0 - width(hWnd),height(hWnd);0
endif
getCursorPos(my2MousePositions&)
settext hWnd,"X:"+str$(long(my2MousePositions&,0))+" Y:"+str$(long(my2MousePositions&,4))+" Strecke:"+str$(strecke&)
add strecke&,abs(long(my2MousePositions&,0)-long(my2MousePositions&,8))+abs(long(my2MousePositions&,4)-long(my2MousePositions&,12))
if long(my2MousePositions&,0) > winRight
long my2MousePositions&,0=winLeft
inc modified&
endif
if long(my2MousePositions&,0) < winLeft
long my2MousePositions&,0=winRight
inc modified&
endif
if long(my2MousePositions&,4) < winTop
long my2MousePositions&,4=winBottom
inc modified&
endif
if long(my2MousePositions&,4) > winBottom
long my2MousePositions&,4=winTop
inc modified&
endif
if modified&
modified&=0
setCursorPos(long(my2MousePositions&,0),long(my2MousePositions&,4))
endif
rtlMoveMemory(my2MousePositions&+8,my2MousePositions&,8)
wend
globalFree(my2MousePositions class=s2>)
end
Den Faktor en: KompilierenMarcaSeparaciónspeed.forShow!=speed.realPixelSpeed!*0.001
o. el *0.001 musst sólo adaptar así dass lo passend wirkt. |
 | | | | |
| |  funkheld | Jup, danke. Usted bist sí una Mathefreak.
Funktioniert wunderbar.
Gracias.
Gruss |
| | | | |
| |  | Hier gibts Mathefreaks pero yo bin kein Mathefreak.  |
| | | | |
| |  funkheld | Tal vez puede ser de esta Daten el Geschwindigkeit y el Wegstrecke ausrechnen: Un Pedalumdrehung ha 41000 Mauspunkte, esta dreht se el Schwungrad 5x. Das Schwungrad ha una Umfang de 75 cm.
Gruss peter |
| | | | |
| |  | 5 Schwungraddrehungen metern also 5*75=375cm y dies entspricht entonces wohl uno
Pedalumdrehung -
demnach müsstest valor en strecke& vlt. sólo 375/41000/100=0,0091463
multiplizieren y luego hast Usted imho el número el zurückgelegten Meter en lugar de
Pixel. Probiere veces si dies hier con usted passende Werte zurückliefert: KompilierenMarcaSeparación {$cleq}
decimals 2
Windowstyle 31
Windowtitle "Cursorposition ermitteln"
window (maxx-500),(maxy-100)
setcursorpos((winRight-winLeft)\2+winLeft,(winBottom-winTop)\2+winTop)
var speed.realPixelSpeed!=0
var speed.forShow!=0
var tmp&=0
var tmp2&=479
var tme&=getTickCount
var tme.start&=getTickCount
var modified&=0
var strecke&=0
var my2MousePositions&=globalAlloc(gPTR,16)
getCursorPos(my2MousePositions&)
rtlMoveMemory(my2MousePositions&+8,my2MousePositions&,8)
mcls 640,480,0
while 1
if tme&<getTickCount
add tme&,100// nur alle 100ms etwas tun
speed.realPixelSpeed!=(strecke&-tmp&)*0.5+speed.realPixelSpeed!*0.5
speed.forShow!=speed.realPixelSpeed!*0.000091463*36
tmp&=strecke&
startpaint -1
usefont "Arial",50,0,0,0,0
textcolor $FFFF,0
drawtext 10,10,"Race: "+str$((getTickCount-tme.start&)\1000)+" Sekunden"
drawtext 10,60,"Strecke: "+str$(strecke&*0.000091463)+" Meter"
drawtext 10,110,"Geschw.: "+str$(speed.forShow!)+" km/h "
drawtext 10,160,"ø Geschw.: "+str$((strecke&*0.000091463)/(1+(getTickCount-tme.start&)\1000))+" Meter/s "
textcolor $00FF00,-1
drawtext 10,10,"Race:"
drawtext 10,60,"Strecke:"
drawtext 10,110,"Geschw.:"
drawtext 10,160,"ø Geschw.:"
copybmp 1,240 - 640,240 > 0,240;0
usepen 0,0,$00FF00
line 637,tmp2& - 638,(479-speed.realPixelSpeed!*0.02)
tmp2&=479-speed.realPixelSpeed!*0.02
endpaint
mcopysizedbmp 0,0 - 640,480 > 0,0 - width(hWnd),height(hWnd);0
endif
getCursorPos(my2MousePositions&)
settext hWnd,"X:"+str$(long(my2MousePositions&,0))+" Y:"+str$(long(my2MousePositions&,4))+" Strecke:"+str$(strecke&)
add strecke&,abs(long(my2MousePositions&,0)-long(my2MousePositions&,8))+abs(long(my2MousePositions&,4)-long(my2MousePositions&,12))
if long(my2MousePositions&,0) > winRight
long my2MousePositions&,0=winLeft
inc modified&
endif
if long(my2MousePositions&,0) < winLeft
long my2MousePositions&,0=winRight
inc modified&
endif
if long(my2MousePositions&,4) < winTop
long my2MousePositions&,4=winBottom
inc modified&
endif
if long(my2MousePositions&,4) > winBottom
long my2MousePositions&,4=winTop
inc modified&
endif
if modified&
modified&=0
setCursorPos(long(my2MousePositions&,0),long(my2MousePositions&,4))
endif
rtlMoveMemory(my2MousePositions&+8,my2MousePositions&,8)
wend
globalFree(my2MousePositions class=s2>)
end
|
| | | | |
| |  funkheld | ¡Hola, danke. Jetzt kommt en uno Pedalumdrehung 3,77Meter fuera. Es Super.
Aber por qué va el Geschwindigkeitsanzeige no höher como ca 15Km/h ? Ist me ahora sólo aufgefallen. Wenn Yo más rápido Trete, se auch el zurückgelegte Strecke länger en uno Zeiteinheit, also el km-Zähler funktioniert con steigender Geschwindigkeit.
Gracias.
Gruss |
| | | | |
| |  | ¿Te ha con Geschwindigkeitsanzeige el Graphen? |
| | | | |
| |  funkheld | Yo mi el Zahlenwert y el Grafik.
Gruss peter |
| | | | |
| |  | Auf mi Computer kann Yo el Ratón así rápidamente bewegen dass incluso 20 km/h
adecuado voluntad. Como groß es Su hWnd? Kann lo ser el el de Usted genutzte
Simple ratón no más rápido erfassen kann? |
| | | | |
| |  funkheld | Yo habe ahora veces : add tme&,200 eingestellt. Jetzt funktioniert lo encima 15Km/h.
Welchen Einfluss ha el eigentlich?
Gruss |
| | | | |
| |  | Nach wievielen Millisekunden el Grafikprozedur ablaufen se -
en 100 also 10 veces pro Sekunde y en 200 5 veces pro Sekunde. |
| | | | |
| |  funkheld | ¿Por qué aumenta se entonces el Geschwindigkeit? Ist como irgendein Einfluss drin, si yo 200 eingebe?
Como errechnest du el Geshwindigkeit?
Gruss |
| | | | |
|
RespuestaTema opciones | 25.174 Views |
ThemeninformationenDieses Thema ha 3 subscriber: |