Jump to content
Sign in to follow this  
rdb

Moving with keys from cord to cord

Recommended Posts

rdb

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

Share this post


Link to post
Share on other sites
rdb

no i meant ill get 500,500 as end position

then i have to move with my up,downleft keys

from a starting position

Share this post


Link to post
Share on other sites
martin

no i meant ill get 500,500 as end position

then i have to move with my up,downleft keys

from a starting position

You 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.

Share this post


Link to post
Share on other sites
Olsson

You mean to be able to move the mouse with arrowkeys?

Share this post


Link to post
Share on other sites
rdb

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 by rdb

Share this post


Link to post
Share on other sites
rdb

Posted Image

a mini map

btw 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 by rdb

Share this post


Link to post
Share on other sites
rdb

; Find Location at waypoint 1

$Coord = PixelSearch( 1240, 780, 1280, 800, 0x000000, 11)

If Not @error Then

MouseMove($coord[0], $Coord[1])

EndIf

Share this post


Link to post
Share on other sites
rdb

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 by rdb

Share this post


Link to post
Share on other sites
rdb

been editing the code

Share this post


Link to post
Share on other sites
FireFox

@rdb

no luck ...

Only bump your topic after 24 hours of your last reply :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
rdb

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

Share this post


Link to post
Share on other sites
FireFox

@rdb

........ :)

Can you edit your reply instead of replying when you have edited your script

IsPressed_UDF

#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
WEnd

Cheers, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
rdb

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 by rdb

Share this post


Link to post
Share on other sites
FireFox

@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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
andybiochem

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!

Share this post


Link to post
Share on other sites
rdb

thnxs iamma see if i can understand it

Edited by rdb

Share this post


Link to post
Share on other sites
rdb

need to know how to get -12 to result in going left 1200 ms and

12 = 1200 ms right

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×