Hallo Leute,
da ich mich erst seit 2 Wochen mit Autoit beschäftige, verzeiht mir erstmal meinen Programmierstil.
Mein Problem das ich habe das ich den Mausweg wissen will in meinem Script.
Gedacht ist es so:
Linke Maustaste gedrückt -> Anfangsposition speichern -> Linke Maustaste losgelassen -> Endposition speichern
Aber sobald ich drücke spuckt er mir meine Msgbox zum testen aus.
Vielleicht kennt einer von euch eine funktionierende Lösung
Das ganze findet Verwendung in einem Bild-Slider-Script mit der Hilfe von QuickDraw.
Im Anhang ist ein Archiv mit allen Dateien um das Script zum laufen zu bringen.
Code:
Spoiler anzeigen
#AutoIt3Wrapper_usex64=n
#Include <Memory.au3>
#include <Array.au3>
#include <GDIPlus.au3>
#Include <Misc.au3>
#include <QuickDraw.au3>
OnAutoItExitRegister("_Exit")
Opt("GUIOnEventMode", 1)
$dll = DllOpen("user32.dll")
$anzahlbilder = 12;Anzahl der Bilder im Verzeichniss pics
$z = 1;Bild was als erstes angezeigt wird
Global $anfangmaus = 0
Global $endemaus = 0
Global $gedrueckt =0
Global $pos[5][3] ;Bilderpositionen
[/autoit] [autoit][/autoit] [autoit]$pos[0][0] = 150
$pos[0][1] = 250
$pos[0][2] = 150
$pos[1][0] = 225
$pos[1][1] = 200
$pos[1][2] = 225
$pos[2][0] = 450
$pos[2][1] = 150
$pos[2][2] = 300
$pos[3][0] = 750
$pos[3][1] = 200
$pos[3][2] = 225
$pos[4][0] = 900
$pos[4][1] = 250
$pos[4][2] = 150
_QuickDraw_Enable("Quickdraw Slider",1200,500,200,200,False) ; Quickdraw Fenster erstellen
GUISetOnEvent(-1, "_Exit")
GUISetState()
_QuickDraw_ClearBuffer(0xFF000000)
_showpics($z, $anzahlbilder);Die ersten Bilder anzeigen
_QuickDraw_SwapBuffers()
While _QuickDraw_Running()
[/autoit] [autoit][/autoit] [autoit];Problemzone Anfang
$mouse_pos= _QuickDraw_GetMousePos(-1)
$druck=_IsPressed(01,$dll)
;$druck=_QuickDraw_GetMouseLeft()
ToolTip($mouse_pos[0]&","&$mouse_pos[1]&"::"& $druck,0,0)
If $anfangmaus = 0 And $druck = "True" Then
$anfangmaus = $mouse_pos[0]
$gedrueckt = 1
EndIf
If $gedrueckt = 1 And $druck = "False" Then
$endemaus = $mouse_pos[0]
MsgBox (0,"Test",$anfangmaus & " bis " & $endemaus)
$anfangmaus = 0
$gedrueckt = 0
EndIf
;Problemzone Ende
;#cs
;linkes Bild
;Prüfen ob Maus gedrückt im linken Bild von der Mitte
If $mouse_pos[0] >= $pos[1][0] And $mouse_pos[0] <= ($pos[1][0] + $pos[1][2]) And $mouse_pos[1] >= $pos[1][1] And $mouse_pos[1] <= ($pos[1][1] + $pos[1][2]) And $druck = "True" Then
_nachrechts($z, $anzahlbilder, 50) ;Bilder nach rechts bewegen
$z = $z - 1
If $z < 1 then $z = $anzahlbilder
EndIf
;rechtes Bild
;Prüfen ob Maus gedrückt im rechten Bild von der Mitte
If $mouse_pos[0] >= $pos[3][0] And $mouse_pos[0] <= ($pos[3][0] + $pos[3][2]) And $mouse_pos[1] >= $pos[3][1] And $mouse_pos[1] <= ($pos[3][1] + $pos[3][2]) And $druck = "True" Then
_nachlinks($z, $anzahlbilder, 50) ;Bilder nach links bewegen
$z = $z + 1
If $z > $anzahlbilder Then $z = 1
EndIf
;#ce
WEnd
[/autoit] [autoit][/autoit] [autoit]_Exit()
[/autoit] [autoit][/autoit] [autoit]Func _showpics($nummer, $anzahl)
[/autoit] [autoit][/autoit] [autoit]$picl2 = $nummer - 2
If $picl2 < 1 then $picl2 = $anzahl - abs($picl2)
$picl =$nummer - 1
If $picl < 1 then $picl = $anzahl - $picl
$picm = $nummer
[/autoit] [autoit][/autoit] [autoit]$picr = $nummer + 1
If $picr > $anzahl then $picr = $picr - $anzahl
$picr2 = $nummer +2
If $picr2 > $anzahl then $picr2 = $picr2 - $anzahl
$piclinks2 = _QuickDraw_LoadTexture("./pics/" & $picl2 & ".jpg")
$picrechts2 = _QuickDraw_LoadTexture("./pics/" & $picr2 & ".jpg")
$piclinks = _QuickDraw_LoadTexture("./pics/" & $picl & ".jpg")
$picrechts = _QuickDraw_LoadTexture("./pics/" & $picr & ".jpg")
$picmitte = _QuickDraw_LoadTexture("./pics/" & $picm & ".jpg")
_QuickDraw_ClearBuffer(0xFF000000)
_QuickDraw_Rect($pos[0][0],$pos[0][1], $pos[0][2], $pos[0][2], $piclinks2, 0xFFFFFFFF)
_QuickDraw_Rect($pos[4][0],$pos[4][1], $pos[4][2], $pos[4][2], $picrechts2, 0xFFFFFFFF)
_QuickDraw_Rect($pos[1][0],$pos[1][1], $pos[1][2], $pos[1][2], $piclinks, 0xFFFFFFFF)
_QuickDraw_Rect($pos[3][0],$pos[3][1], $pos[3][2], $pos[3][2], $picrechts, 0xFFFFFFFF)
_QuickDraw_Rect($pos[2][0],$pos[2][1], $pos[2][2], $pos[2][2], $picmitte, 0xFFFFFFFF)
_QuickDraw_SwapBuffers()
EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _nachrechts($nummer, $anzahl, $schritte)
[/autoit] [autoit][/autoit] [autoit]If $nummer < 1 then $nummer = $anzahl
If $nummer > $anzahlbilder Then $nummer = 1
$picl3 = $nummer - 3
If $picl3 < 1 then $picl3 = $anzahl - abs($picl3)
$picl2 = $nummer - 2
If $picl2 < 1 then $picl2 = $anzahl - abs($picl2)
$picl =$nummer - 1
If $picl < 1 then $picl = $anzahl - abs($picl)
$picm = $nummer
[/autoit] [autoit][/autoit] [autoit]$picr = $nummer + 1
If $picr > $anzahl then $picr = $picr - $anzahl
$picr2 = $nummer +2
If $picr2 > $anzahl then $picr2 = $picr2 - $anzahl
;MsgBox(0,"" ,$picl3 &","& $picl2 &","& $picl &"," &$picm &","& $picr&","&$picr2)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$piclinks3 = _QuickDraw_LoadTexture("./pics/" & $picl3 & ".jpg")
$piclinks2 = _QuickDraw_LoadTexture("./pics/" & $picl2 & ".jpg")
$picrechts2 = _QuickDraw_LoadTexture("./pics/" & $picr2 & ".jpg")
$piclinks = _QuickDraw_LoadTexture("./pics/" & $picl & ".jpg")
$picrechts = _QuickDraw_LoadTexture("./pics/" & $picr & ".jpg")
$picmitte = _QuickDraw_LoadTexture("./pics/" & $picm & ".jpg")
;schritte berechnen
Dim $schritt[4][3]
;Bild 0 zu 1
$schritt[0][0] = ($pos[1][0] - $pos[0][0]) / $schritte
$schritt[0][1] = ($pos[0][1] - $pos[1][1]) / $schritte
$schritt[0][2] = ($pos[1][2] - $pos[0][2]) / $schritte
;Bild 1 zu 2
$schritt[1][0] = ($pos[2][0] - $pos[1][0]) / $schritte
$schritt[1][1] = ($pos[1][1] - $pos[2][1]) / $schritte
$schritt[1][2] = ($pos[2][2] - $pos[1][2]) / $schritte
;Bild 2 zu 3
$schritt[2][0] = ($pos[3][0] - $pos[2][0]) / $schritte
$schritt[2][1] = ($pos[3][1] - $pos[2][1]) / $schritte
$schritt[2][2] = ($pos[2][2] - $pos[3][2]) / $schritte
;Bild 3 zu 4
$schritt[3][0] = ($pos[4][0] - $pos[3][0]) / $schritte
$schritt[3][1] = ($pos[4][1] - $pos[3][1]) / $schritte
$schritt[3][2] = ($pos[3][2] - $pos[4][2]) / $schritte
$i = 1
for $i = 1 to $schritte
_QuickDraw_ClearBuffer(0xFF000000)
_QuickDraw_Rect($pos[0][0], $pos[0][1], $pos[0][2], $pos[0][2], $piclinks3, 0xFFFFFFFF)
_QuickDraw_Rect($pos[0][0] + $schritt[0][0] * $i ,$pos[0][1] - $schritt[0][1] * $i, $pos[0][2] + $schritt[0][2] * $i, $pos[0][2] + $schritt[0][2] * $i, $piclinks2, 0xFFFFFFFF)
_QuickDraw_Rect($pos[4][0], $pos[4][1], $pos[4][2], $pos[4][2], $picrechts2, 0xFFFFFFFF)
_QuickDraw_Rect($pos[1][0] + $schritt[1][0] * $i, $pos[1][1] - $schritt[1][1] * $i, $pos[1][2] + $schritt[1][2] * $i, $pos[1][2] + $schritt[1][2] * $i, $piclinks, 0xFFFFFFFF)
_QuickDraw_Rect($pos[3][0] + $schritt[3][0] * $i, $pos[3][1] + $schritt[3][1] * $i, $pos[3][2] - $schritt[3][2] * $i, $pos[3][2] - $schritt[3][2] * $i, $picrechts, 0xFFFFFFFF)
_QuickDraw_Rect($pos[2][0] + $schritt[2][0] * $i, $pos[2][1] + $schritt[2][1] * $i, $pos[2][2] - $schritt[2][2] * $i, $pos[2][2] - $schritt[2][2] * $i, $picmitte, 0xFFFFFFFF)
_QuickDraw_SwapBuffers()
sleep(5)
Next
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _nachlinks($nummer, $anzahl, $schritte)
[/autoit] [autoit][/autoit] [autoit]If $nummer < 1 then $z = $anzahl
If $nummer > $anzahl Then $z = 1
$picl2 = $nummer - 2
If $picl2 < 1 then $picl2 = $anzahl - abs($picl2)
$picl =$nummer - 1
If $picl < 1 then $picl = $anzahl - abs($picl)
$picm = $nummer
[/autoit] [autoit][/autoit] [autoit]$picr = $nummer + 1
If $picr > $anzahl then $picr = $picr - $anzahl
$picr2 = $nummer +2
If $picr2 > $anzahl then $picr2 = $picr2 - $anzahl
$picr3 = $nummer +3
If $picr3 > $anzahl then $picr3 = $picr3 - $anzahl
;MsgBox(0,"" ,$picl2 &","& $picl &"," &$picm &","& $picr&","&$picr2&","&$picr3)
[/autoit] [autoit][/autoit] [autoit]$piclinks2 = _QuickDraw_LoadTexture("./pics/" & $picl2 & ".jpg")
$picrechts3 = _QuickDraw_LoadTexture("./pics/" & $picr3 & ".jpg")
$picrechts2 = _QuickDraw_LoadTexture("./pics/" & $picr2 & ".jpg")
$piclinks = _QuickDraw_LoadTexture("./pics/" & $picl & ".jpg")
$picrechts = _QuickDraw_LoadTexture("./pics/" & $picr & ".jpg")
$picmitte = _QuickDraw_LoadTexture("./pics/" & $picm & ".jpg")
;schritte berechnen
Dim $schritt[4][3]
;Bild 1 zu 0
$schritt[0][0] = ($pos[1][0] - $pos[0][0]) / $schritte
$schritt[0][1] = ($pos[0][1] - $pos[1][1]) / $schritte
$schritt[0][2] = ($pos[1][2] - $pos[0][2]) / $schritte
;Bild 2 zu 1
$schritt[1][0] = ($pos[2][0] - $pos[1][0]) / $schritte
$schritt[1][1] = ($pos[1][1] - $pos[2][1]) / $schritte
$schritt[1][2] = ($pos[2][2] - $pos[1][2]) / $schritte
;Bild 3 zu 2
$schritt[2][0] = ($pos[3][0] - $pos[2][0]) / $schritte
$schritt[2][1] = ($pos[3][1] - $pos[2][1]) / $schritte
$schritt[2][2] = ($pos[2][2] - $pos[3][2]) / $schritte
;Bild 4 zu 3
$schritt[3][0] = ($pos[4][0] - $pos[3][0]) / $schritte
$schritt[3][1] = ($pos[4][1] - $pos[3][1]) / $schritte
$schritt[3][2] = ($pos[3][2] - $pos[4][2]) / $schritte
$i = 1
for $i = 1 to $schritte
_QuickDraw_ClearBuffer(0xFF000000)
_QuickDraw_Rect($pos[0][0], $pos[0][1], $pos[0][2], $pos[0][2], $piclinks2, 0xFFFFFFFF)
_QuickDraw_Rect($pos[4][0], $pos[4][1], $pos[4][2], $pos[4][2], $picrechts3, 0xFFFFFFFF)
_QuickDraw_Rect($pos[4][0] - $schritt[3][0] * $i, $pos[4][1] - $schritt[3][1] * $i, $pos[4][2] + $schritt[3][2] * $i, $pos[4][2] + $schritt[3][2] * $i, $picrechts2, 0xFFFFFFFF)
_QuickDraw_Rect($pos[1][0] - $schritt[0][0] * $i, $pos[1][1] + $schritt[0][1] * $i, $pos[1][2] - $schritt[0][2] * $i, $pos[1][2] - $schritt[0][2] * $i, $piclinks, 0xFFFFFFFF)
_QuickDraw_Rect($pos[3][0] - $schritt[2][0] * $i, $pos[3][1] - $schritt[2][1] * $i, $pos[3][2] + $schritt[2][2] * $i, $pos[3][2] + $schritt[2][2] * $i, $picrechts, 0xFFFFFFFF)
_QuickDraw_Rect($pos[2][0] - $schritt[1][0] * $i, $pos[2][1] + $schritt[1][1] * $i, $pos[2][2] - $schritt[1][2] * $i, $pos[2][2] - $schritt[1][2] * $i, $picmitte, 0xFFFFFFFF)
_QuickDraw_SwapBuffers()
sleep(5)
Next
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _Exit()
_QuickDraw_Disable()
Exit
EndFunc ;==>_Exit