![:graduated:](http://aut1.autoit-cdn.com/forum/public/style_emoticons/autoit/graduated.gif)
[ autoit ]
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> Global $g = 10, $Label2, $CONTROLPOS[2] $CONTROLPOS[0] = 20 $CONTROLPOS[1] = 20 Global $USER32DLL = DllOpen('user32.dll') $DEFAULTVELOCITY = 5 _GDIPlus_StartUp() $Form1 = GUICreate("My Problem", 934, 627, 332, 130) GUISetBkColor(0xffffff) $Label2 = GUICtrlCreateLabel("", 20, 20, 33, 33) $hGraphicLabel = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($Label2)) _GDIPlus_GraphicsDrawEllipse($hGraphicLabel, 0,0, 30, 30) _GDIPlus_GraphicsSetSmoothingMode($hGraphicLabel, 2) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(33, 33, $hGraphicLabel) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) _GDIPlus_GraphicsDrawEllipse($hGraphic, 0,0, 30, 30) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_PAINT, '_ReDraw') While 1 _Projectile() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hGraphicLabel) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_ShutDown() DllClose($USER32DLL) Exit EndSwitch WEnd Func _Projectile() If _IsPressed('27', $USER32DLL) and $CONTROLPOS[0] < 934-33 then GUICtrlSetPos($Label2, $CONTROLPOS[0] + $DEFAULTVELOCITY) $CONTROLPOS[0] = $CONTROLPOS[0] + $DEFAULTVELOCITY _GDIPlus_GraphicsDrawImage($hGraphicLabel, $hBMPBuff, 0, 0) EndIf If _IsPressed('25', $USER32DLL) and $CONTROLPOS[0] >$DEFAULTVELOCITY then GUICtrlSetPos($Label2, $CONTROLPOS[0] - $DEFAULTVELOCITY) $CONTROLPOS[0] = $CONTROLPOS[0] - $DEFAULTVELOCITY _GDIPlus_GraphicsDrawImage($hGraphicLabel, $hBMPBuff, 0, 0) EndIf If _IsPressed('26', $USER32DLL) and $CONTROLPOS[1] >$DEFAULTVELOCITY then GUICtrlSetPos($Label2, $CONTROLPOS[0], $CONTROLPOS[1] - $DEFAULTVELOCITY) $CONTROLPOS[1] = $CONTROLPOS[1] - $DEFAULTVELOCITY _GDIPlus_GraphicsDrawImage($hGraphicLabel, $hBMPBuff, 0, 0) EndIf If _IsPressed('28', $USER32DLL) and $CONTROLPOS[1] < 627-26 then GUICtrlSetPos($Label2, $CONTROLPOS[0], $CONTROLPOS[1] + $DEFAULTVELOCITY) $CONTROLPOS[1] = $CONTROLPOS[1] + $DEFAULTVELOCITY _GDIPlus_GraphicsDrawImage($hGraphicLabel, $hBMPBuff, 0, 0) EndIf EndFunc Func _ReDraw() _GDIPlus_GraphicsDrawImage($hGraphicLabel, $hBMPBuff, 0, 0) EndFunc
Now, as soon as you press an arrow key, the ball moves fine as expected, but if the mouse is moved, the ball moves super-duper fast (something, which is not acceptable in my case)
![>_<](http://aut1.autoit-cdn.com/forum/public/style_emoticons/autoit/pinch.gif)
Thank you for your time...
With regards,
MKISH