hi ich hab ein problem bzw eine frage ... ich hab diese funktion geschrieben , sie soll eine control zur maus bewegen... das macht sie auch aber jetzt meine frage : wieso macht es das nich diagonal müsste es ja nach dem quelltext ?oder ?
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", @DesktopWidth, @DesktopHeight)
$Label1 = GUICtrlCreateLabel("Label1", 130, 130, 30, 30)
GUICtrlSetBkColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{1}","__CtrlToMouse")
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func __CtrlToMouse()
$MousePos2 = MouseGetPos()
$MousePos2[0] = $MousePos2[0] -15
$MousePos2[1] = $MousePos2[1] -15
While 1
$PlayerPos = ControlGetPos("","",$Label1)
If $MousePos2[0] <> $PlayerPos[0] Then
If $MousePos2[0] < $PlayerPos[0] Then
GUICtrlSetPos($Label1,$PlayerPos[0]-1,$PlayerPos[1])
EndIf
If $MousePos2[0] > $PlayerPos[0] Then
GUICtrlSetPos($Label1,$PlayerPos[0]+1,$PlayerPos[1])
EndIf
EndIf
If $MousePos2[1] <> $PlayerPos[1] Then
If $MousePos2[1] < $PlayerPos[1] Then
GUICtrlSetPos($Label1,$PlayerPos[0],$PlayerPos[1]-1)
EndIf
If $MousePos2[1] > $PlayerPos[1] Then
GUICtrlSetPos($Label1,$PlayerPos[0],$PlayerPos[1]+1)
EndIf
EndIf
If ($MousePos2[0] = $PlayerPos[0]) And ($MousePos2[1] = $PlayerPos[1]) Then
ExitLoop
EndIf
Sleep(10)
WEnd
EndFunc