rdb Posted January 10, 2009 Share Posted January 10, 2009 i want to be able to go from one cordinate to a other with keystrokes lets says $Posstart = 0,100 $Posend = 500,500 then i need to get $Posstart to 500,500 from 0,100 and maby not to hard doing it backwards? $Posend = 0,100 $Posstart = 500,500 Link to comment Share on other sites More sharing options...
Achilles Posted January 10, 2009 Share Posted January 10, 2009 $x = 500 $y = 500 MouseMove($x, $y)Is that kind of what you mean? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
rdb Posted January 10, 2009 Author Share Posted January 10, 2009 no i meant ill get 500,500 as end position then i have to move with my up,downleft keys from a starting position Link to comment Share on other sites More sharing options...
martin Posted January 10, 2009 Share Posted January 10, 2009 no i meant ill get 500,500 as end positionthen i have to move with my up,downleft keys from a starting positionYou should give enough information so that we don't have to guess.Does each key press move 1 unit? All you need to do, I expect, is to use Send the correct number of times.What code have you got so far? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Olsson Posted January 11, 2009 Share Posted January 11, 2009 You mean to be able to move the mouse with arrowkeys? Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 (edited) srry for not being to clear... i mean this , i have a start position lets says 100,100, for my robot. now i want to move the robot from 100,100 to 300,350 useing left ,right,up,down . if i press a key to move it wil move me 50 pixels ~ to the direction i want so i figure i need to move - 200 x pixels and - 250 y pixels orsomething and i cant figure out how to get this striaght. - on the x means left - on the y means up . ect... i really chould use some tip , been looking for 5 days and i am stil clueless Edited January 11, 2009 by rdb Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 (edited) a mini mapbtw my own position doesnt changes its a fixed location but the map moves.....so lets say my start aka current location is 200,200 and the end location is 200,500 and i move somewhere , then my new curent location wil be the same but the end location wil be 200,450 orso Edited January 11, 2009 by rdb Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 ; Find Location at waypoint 1 $Coord = PixelSearch( 1240, 780, 1280, 800, 0x000000, 11) If Not @error Then MouseMove($coord[0], $Coord[1]) EndIf Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 (edited) hmm hard:( any1 got a suggestion? i figured this out ;// Declaring constant variables :// start pos LocalConst $X= 200 Local Const $Y= 200 Local Const $Stepin = 100 ;// Get next position by looking for a dot on mini map $Pos1 = PixelSearch( 0, 0, 600, 600, 0x000000, 11) If Not @error Then :/ part that iam stuck with lets say 300,300 ,so a distance of 100 pix x right and down on Y ;// X distance to target is $Distx = $Pos1[0] - $X ;// Y distance to target is $DistY = $Pos1[1] - $Y ;// .. calculate howfar togo.. X as cant seem to know how $Move = $Distx / $Stepin If $Move is positive then send("{right down}") sleep(250) send("{right up}") Else send("{left down}") sleep(250) send("{left up}") Endif (dunno) ;// .. calculate howfar togo.. Y as cant seem to know how $Move = $Disty / $Stepin If $Move is positive then send("{down down}") sleep(250) send("{down up}") Else send("{up down}") sleep(250) send("{up up}") Endif (dunno) ;// when at location use this func to click and check for pixel $Coord = PixelSearch( 0, 0, 600, 600, 0xFFF700, 11) If Not @error Then MouseMove($Coord[0], $Coord[1], 1) Opt("MouseClickDownDelay", 110) MouseClick("left",($Coord[0] + 24), ($Coord[1] + 57), 1) MouseClick("right",($Coord[0] + 24), ($Coord[1] + 57), 1) MouseClick("left",($Coord[0] + 24), ($Coord[1] + 57), 1) Edited January 11, 2009 by rdb Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 been editing the code Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 no luck ... Link to comment Share on other sites More sharing options...
FireFox Posted January 11, 2009 Share Posted January 11, 2009 @rdbno luck ...Only bump your topic after 24 hours of your last reply Cheers, FireFox. Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 srry , this my actual code i use and got sofar ;// Declaring constant variables ;// start pos Local Const $X= 1268 Local Const $Y= 774 Local Const $Stepin = 2 ;// Get next position by looking for a dot on mini map $Pos1 = PixelSearch( 1221, 760, 1260, 800, 0x000000, 11) If Not @error Then MouseMove($Pos1[0], $Pos1[1]) $Distx = $Pos1[0] - $X ;// Y distance to target is $DistY = $Pos1[1] - $Y ;// .. calculate howfar togo.. X as cant seem to know how ;// .. calculate howfar togo.. X as $Move = $Distx / $Stepin EndIf If $Move <=0 Then send ( "{left down}") sleep(12222) Send ( "{left up}" ) EndIf stil wroking to a end result i seemd to figuredout allot sofar any suggestions chould be helpfull to ty Link to comment Share on other sites More sharing options...
FireFox Posted January 11, 2009 Share Posted January 11, 2009 (edited) @rdb........ Can you edit your reply instead of replying when you have edited your scriptIsPressed_UDFexpandcollapse popup#include <IsPressed_UDF.au3> $mgp = MouseGetPos() $x = $mgp[0] $y = $mgp[1] While 1 If _IsAndKeyPressed('25|26') Then $x -= 1 $y -= 1 MouseMove($x, $y) ElseIf _IsAndKeyPressed('26|27') Then $x += 1 $y -= 1 MouseMove($x, $y) ElseIf _IsAndKeyPressed('27|28') Then $x += 1 $y += 1 MouseMove($x, $y) ElseIf _IsAndKeyPressed('25|28') Then $x -= 1 $y += 1 MouseMove($x, $y) ElseIf _IsPressed('25') Then $x -= 1 MouseMove($x, $y) ElseIf _IsPressed('26') Then $y -= 1 MouseMove($x, $y) ElseIf _IsPressed('27') Then $x += 1 MouseMove($x, $y) ElseIf _IsPressed('28') Then $y += 1 MouseMove($x, $y) EndIf WEndCheers, FireFox. Edited January 11, 2009 by FireFox Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 (edited) dunt see how this gonna help me ..... i am getting cords and i have to SEND left.right or uo down keystrokes to get to location from start not anything else. in short.... 1 i need to get a location 2 use that location to calculate howmuch distance to location 1 3 then go to location 1 4 and go to location 2 ect........ useing Arrow keys Edited January 11, 2009 by rdb Link to comment Share on other sites More sharing options...
FireFox Posted January 11, 2009 Share Posted January 11, 2009 @rdb ?? Local $last_pos[3], $lastdistance While 1 $current_pos = MouseGetPos() $distance = Sqrt(($current_pos[0] - $last_pos[0]) ^ 2 + ($current_pos[1] - $last_pos[1]) ^ 2) $mousedist = $distance + $lastdistance $lastdistance = $mousedist $last_pos = $current_pos TrayTip('Mouse dist (pixels)', $mousedist, 0, 1) WEnd Cheers, FireFox. Link to comment Share on other sites More sharing options...
andybiochem Posted January 11, 2009 Share Posted January 11, 2009 This might help, try changing it for you own script: ;----- choose start / end coords ----- $sStartCoord = "100,100" $sEndCoord = "300,350" ;----- unit of movement ----- $iUnit = 50 ;----- split coords to arrays ----- $aStartCoord = StringSplit($sStartCoord,",") $aEndCoord = StringSplit($sEndCoord,",") ;----- calculate how many keystrokes to make ----- $iMoveX = ($aEndCoord[1] - $aStartCoord[1]) / $iUnit $iMoveY = ($aEndCoord[2] - $aStartCoord[2]) / $iUnit ;----- make x keystrokes ----- For $i = 1 To $iMoveX Select Case $iMoveX < 0 Send("{LEFT}") Case $iMoveX > 0 Send("{RIGHT}") EndSelect Next ;----- make y keystrokes ----- For $i = 1 To $iMoveY Select Case $iMoveY < 0 Send("{DOWN}") Case $iMoveY > 0 Send("{UP}") EndSelect Next - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 (edited) thnxs iamma see if i can understand it Edited January 11, 2009 by rdb Link to comment Share on other sites More sharing options...
rdb Posted January 11, 2009 Author Share Posted January 11, 2009 need to know how to get -12 to result in going left 1200 ms and 12 = 1200 ms right 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