cppman Posted March 6, 2006 Share Posted March 6, 2006 (edited) Okay, this is for my autoit script, but is hardly relevant to AutoItIm trying to move an image at a diagnal to the position 30, 50 on the screenHow would I do this..likeFor $i = 1 to 100ControlMove($MyImage, $ImagePos[0] + 1, $ImagePos[1] + 1)NextThis will not work, because it will only step 100 times, so if it is something like moving the image to 500, 700 then it will only do a 7th of the movement... How would I go about making it move the full length... Sorry if this is kinda difficult for you to understand, but im trying my best to explain....here is a diagram:Im trying to move X to Y. How would i make X Move in that exact path until it hits Y?I think someone partially answered this question a while ago, but it was'nt really what i was looking for.. Edited March 6, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
greenmachine Posted March 6, 2006 Share Posted March 6, 2006 (edited) Do ControlMove($MyImage, $ImagePos[0] + 1, $ImagePos[1] + 1) $ImagePos[0] += 1 $ImagePos[1] += 1 Until ($ImagePos[0] = $yourX) and ($ImagePos[1] = $yourY) Of course, this only moves in a 45 degree angle (as of now). Edited March 6, 2006 by greenmachine Link to comment Share on other sites More sharing options...
Oxin8 Posted March 6, 2006 Share Posted March 6, 2006 (edited) This is where algebra and geometry help you... Figure out the slope by using the start point and the end point and add appropriately... Post the start point and we'll get you all fixed up. EDIT: On second thought, maybe I have no idea what you're asking for... :-/ Edited March 6, 2006 by Oxin8 ~My Scripts~ *********_XInput UDF for Xbox 360 ControllerSprayPaint_MouseMovePlus Link to comment Share on other sites More sharing options...
Valuater Posted March 6, 2006 Share Posted March 6, 2006 (edited) use @desktopwidth and @desktophieght get your position, subtract to get the difference the idea is $ImagePos[0] + $i .... not $ImagePos[0] + 1 Question is this a control or a Window ?? better read more on ControlMove() you syntax is not right ControlMove ( "title", "text", controlID, x, y [, width [, height]] ) 8) Edited March 6, 2006 by Valuater Link to comment Share on other sites More sharing options...
cppman Posted March 6, 2006 Author Share Posted March 6, 2006 (edited) yeah, i no... i was doin it real quick to hurry and ask my question... thanks GM. and everyone else... Edited March 6, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
cppman Posted March 6, 2006 Author Share Posted March 6, 2006 Its a control.... a Pic inside my gui. Miva OS Project Link to comment Share on other sites More sharing options...
cppman Posted March 6, 2006 Author Share Posted March 6, 2006 (edited) use @desktopwidth and @desktophieght get your position, subtract to get the difference the idea is $ImagePos[0] + $i .... not $ImagePos[0] + 1 Question is this a control or a Window ?? better read more on ControlMove() you syntax is not right ControlMove ( "title", "text", controlID, x, y [, width [, height]] ) 8) but if u do image[0] + $i tput the image at the top of the window, then move... i want it to move from its current position. The code GM Gave me worked perfect. btw, sorry for the triple posts, lol. Oh, also, is their anyway to slow down that movement without using the Sleep() function? Edited March 6, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
greenmachine Posted March 6, 2006 Share Posted March 6, 2006 (edited) By the way, about my code... you might want to change the "and" in the do/until loop to an "or", unless your pic starts out so X and Y are proportionate to the final location... In other words, if you're trying to move it to 500, 700, you need to have the pic start at say (200, 400) - it would then move 300 pixels at a 45 degree angle to meet 500, 700. If you want to use a different angle, sin and cos are going to be your friends. @Larry - gah, so slow. Edited March 6, 2006 by greenmachine Link to comment Share on other sites More sharing options...
cppman Posted March 6, 2006 Author Share Posted March 6, 2006 (edited) okay, im confused on the math... could someone please imlement it into this code... Func SpriteMove($Sprite, $EndX, $EndY) Do $ImagePos = ControlGetPos("", "", $Sprite) ControlMove("", "", $Sprite, $ImagePos[0] + $xadd, $ImagePos[1] + $yadd) $ImagePos[0] += 1 $ImagePos[1] += 1 Until ($ImagePos[0] = $EndX) and ($ImagePos[1] = $EndY) Return 0 EndFunc Edited March 6, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
greenmachine Posted March 6, 2006 Share Posted March 6, 2006 (edited) I used mousemove as my example, I figure you can change it to suit your needs. SpriteMove(0, 500, 500) Func SpriteMove($Sprite, $EndX, $EndY) $CurrentPos = MouseGetPos () $xadd = ($EndX - $CurrentPos[0])/100; 100 movements $yadd = ($EndY - $CurrentPos[1])/100; 100 movements Do ;$ImagePos = ControlGetPos("", "", $Sprite) ;ControlMove("", "", $Sprite, $ImagePos[0] + $xadd, $ImagePos[1] + $yadd) MouseMove ($CurrentPos[0] + $xadd, $CurrentPos[1] + $xadd) $CurrentPos[0] += $xadd $CurrentPos[1] += $yadd TrayTip ("pos", $CurrentPos[0] & @CRLF & $CurrentPos[1], 1) Until (Int ($CurrentPos[0]) = $EndX) And (Int ($CurrentPos[1]) = $EndY) Return 0 EndFunc It's going to look a lot like Larry's in terms of math, but that's because all correct math answers look alike. There are also more efficient methods, but I was just continuing from my initial post. Edited March 6, 2006 by greenmachine Link to comment Share on other sites More sharing options...
cppman Posted March 6, 2006 Author Share Posted March 6, 2006 (edited) I used mousemove as my example, I figure you can change it to suit your needs. SpriteMove(0, 500, 500) Func SpriteMove($Sprite, $EndX, $EndY) $CurrentPos = MouseGetPos () $xadd = ($EndX - $CurrentPos[0])/100; 100 movements $yadd = ($EndY - $CurrentPos[1])/100; 100 movements Do ;$ImagePos = ControlGetPos("", "", $Sprite) ;ControlMove("", "", $Sprite, $ImagePos[0] + $xadd, $ImagePos[1] + $yadd) MouseMove ($CurrentPos[0] + $xadd, $CurrentPos[1] + $xadd) $CurrentPos[0] += $xadd $CurrentPos[1] += $yadd TrayTip ("pos", $CurrentPos[0] & @CRLF & $CurrentPos[1], 1) Until (Int ($CurrentPos[0]) = $EndX) And (Int ($CurrentPos[1]) = $EndY) Return 0 EndFunc It's going to look a lot like Larry's in terms of math, but that's because all correct math answers look alike. There are also more efficient methods, but I was just continuing from my initial post. It does'nt stop at 500, 500. it kept going.... whent passed 1000..... This is weird, for some numbers it works, but for others, it does'nt. Thanks alot though! Edited March 6, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
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