Andreik Posted September 28, 2008 Posted September 28, 2008 I want to make a square to move in the direction keystrokes. Maybe it would be more suggestive pictures to explain what I want to do. I think that the best method is GDI+. If someone has an idea how to do this?
junkew Posted September 28, 2008 Posted September 28, 2008 http://www.autoitscript.com/forum/index.ph...mp;#entry559306alternative method could be to use a transparent window without a title bar but with borderline. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
monoceres Posted September 28, 2008 Posted September 28, 2008 GDI+ Is fun >_< expandcollapse popup#include <GDIPlus.au3> #include <misc.au3> Global Const $width=500, $height=400 Global $rw=50,$rh=50; Rect size Global $x=$width/2-$rw/2,$y=$height/2-$rh/2 Global $user32=DllOpen("user32.dll") Opt("GUIOnEventMode",1) $hwnd=GUICreate("GDI+",$width,$height) GUISetState() GUISetOnEvent(-3,"close") _GDIPlus_Startup() $graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd) $bitmap=_GDIPlus_BitmapCreateFromGraphics($width,$height,$graphics) $backbuffer=_GDIPlus_ImageGetGraphicsContext($bitmap) $pen=_GDIPlus_PenCreate(0xFFFF0000,4) Do _GDIPlus_GraphicsCLear($backbuffer) If _IsPressed("25",$user32) Then $x-=3 EndIf If _IsPressed("26",$user32) Then $y-=3 EndIf If _IsPressed("27",$user32) Then $x+=3 EndIf If _IsPressed("28",$user32) Then $y+=3 EndIf _GDIPlus_GraphicsDrawRect($backbuffer,$x,$y,$rw,$rh,$pen) _GDIPlus_GraphicsDrawLine($backbuffer,$x+$rw/2,0,$x+$rw/2,$y,$pen) _GDIPlus_GraphicsDrawLine($backbuffer,0,$y+$rh/2,$x,$y+$rh/2,$pen) _GDIplus_GraphicsDrawLine($backbuffer,$width,$y+$rh/2,$x+$rw,$y+$rh/2,$pen) _GDIPlus_GraphicsDrawLine($backbuffer,$x+$rw/2,$height,$x+$rw/2,$y+$rh,$pen) _GDIPlus_GraphicsDrawImageRect($graphics,$bitmap,0,0,$width,$height) Sleep(10) Until False Func close() _GDIPlus_PenDispose($pen) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_Shutdown() Exit EndFunc Broken link? PM me and I'll send you the file!
Andreik Posted September 28, 2008 Author Posted September 28, 2008 (edited) Yeah. GDI+ is funny with monoceres and Malkey. Thanks, your example work fine. It`s exactly what I want. >_< Edited September 28, 2008 by Andreik
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now