Jump to content
Sign in to follow this  
Ethereal401

Save a mouse location and click on that location latter

Recommended Posts

Ethereal401

What I'm trying to do is move my mouse to 1 location, clicking at that location, then moving the mouse to another location and clicking on that location when a certain pixel I determine changes.

I'm getting nothing bug problems so far. Anyhelp would be nice...

Here's what I got so far...

#Include <Misc.au3>

$dll = DllOpen("user32.dll")


$x = 15000 ;countdown in milliseconds
$y = 15000 ;countdown in milliseconds
$z = 15000 ;countdown in milliseconds
Do
    TrayTip("", "Will record pixel under mouse in: "&$x/1000&" seconds", 0)
    Sleep(1000)
    $x = $x - 1000
Until $x <= 0

TrayTip("", "", 0)

$pos = MouseGetPos();obtain mouse coords

$colorundermouse = PixelGetColor($pos[0], $pos[1]) ;obtains color under mouse position in decimal value

sleep(1000)

Do
    TrayTip("", "Will record mouse position for teleport in: "&$y/1000&" seconds", 0)
    Sleep(1000)
    $y = $y - 1000
Until $y <= 0

$pos2 = MouseGetPos();obtain mouse coords

sleep(1000)



Do
    TrayTip("", "Will record mouseposition for closing window in: "&$z/1000&" seconds", 0)
    Sleep(1000)
    $z = $z - 1000
Until $z <= 0

$pos3 = MouseGetPos();obtain mouse coords






Sleep(1000)


    
Sleep(1000)


While PixelGetColor($pos[0], $pos[1]) = $colorundermouse


Mouseclick("left")
sleep("3000")
Wend



While PixelGetColor($pos[0], $pos[1]) <> $colorundermouse 
    MouseMove($pos2)
    sleep(1000)
    MouseClick("left")
    Sleep(10)
    MouseClick("left")
    Sleep(5000)
    MouseMove($pos3)
    Mouseclick("left")
    Sleep(10)
    Mouseclick("left")
    sleep(3000)
    WEnd

I keep getting these errors.....

C:\macro.au3(66,17) : ERROR: MouseMove() [built-in] called with wrong number of args.

MouseMove($pos2)

~~~~~~~~~~~~~~~^

C:\macro.au3(72,17) : ERROR: MouseMove() [built-in] called with wrong number of args.

MouseMove($pos3)

~~~~~~~~~~~~~~~^

Share this post


Link to post
Share on other sites
smashly

Hi,

MouseMove() is expacting at least 2 parameters of X and Y position

eg:

MouseMove($pos2[0], $pos2[1])

MouseMove($pos3[0], $pos3[1])

Cheers

Share this post


Link to post
Share on other sites
Ethereal401

Hi,

MouseMove() is expacting at least 2 parameters of X and Y position

eg:

MouseMove($pos2[0], $pos2[1])

MouseMove($pos3[0], $pos3[1])

Cheers

Thanks now the program is moving the mouse around properly. For some reason when I left click on a program outside the main program I'm running on the desktop it won't make that new program the active window. Also do does having a projection tv as a monitor effect pixel detection at all? For some reason pixel detection was working on my last monitor but not on my 60" projection television...

Share this post


Link to post
Share on other sites
JSThePatriot

Mouse*() Functions don't care which window is active. I would recommend activating your window if not active already before any mouse function so you know you're on top.

I don't really know about the 60" projection. :-P Let us know what you find out on that though. Maybe someone else will have some insight there.

Regards,

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites
Ethereal401

Mouse*() Functions don't care which window is active. I would recommend activating your window if not active already before any mouse function so you know you're on top.

I don't really know about the 60" projection. :-P Let us know what you find out on that though. Maybe someone else will have some insight there.

Regards,

Jarvis

It wasn't the 60" projection tv it was the code.

Autoit pixel detection works fine as far as I can tell with projection screens.

My goal is to make a macro that will detect if one pixel changes than to stop what it's doing and start another command process..

Whats happening in my current code is that the macro will sleep when I tell it to sleep but will only check that pixel once through it's process.

I want this macro to continously check this pixel and stop its current process and start another set of commands when that pixel changes. How would I go about doing that?

Here's the code I got now.

#Include <Misc.au3>

$dll = DllOpen("user32.dll")

$i = 1
$a = 10000 ;countdown in millisecond
$x = 15000 ;countdown in milliseconds
$y = 5000 ;countdown in milliseconds
$z = 5000 ;countdown in milliseconds
Do
    TrayTip("", "Will record pixel under mouse: "&$x/1000&" seconds", 0)
    Sleep(1000)
    $x = $x - 1000
Until $x <= 0

TrayTip("", "", 0)

$pos = MouseGetPos();obtain mouse coords

$colorundermouse = PixelGetColor($pos[0], $pos[1]) ;obtains color under mouse position in decimal value



Do
    TrayTip("", "Will record mouse position for action: "&$y/1000&" seconds", 0)
    Sleep(1000)
    $y = $y - 1000
Until $y <= 0

$pos2 = MouseGetPos();obtain mouse coords

$colorundermouse2 = PixelGetColor($pos2[0], $pos2[1]) ;obtains color under mouse position in decimal value



Do
    TrayTip("", "Will record mouseposition for closing window in: "&$z/1000&" seconds", 0)
    Sleep(1000)
    $z = $z - 1000
Until $z <= 0

$pos3 = MouseGetPos();obtain mouse coords

Do
    TrayTip("", "Will record mouseposition for closing window yes in: "&$a/1000&" seconds", 0)
    Sleep(1000)
    $a = $a - 1000
Until $a <= 0

$pos4 = MouseGetPos();obtain mouse coord








    



MouseMove($pos[0], $pos[1])
sleep(1000)
MouseClick("middle")
sleep(1000)






Do



    If PixelGetColor($pos2[0], $pos2[1]) <> $colorundermouse2 Then 
        Sleep(180000)
        MouseClick("left")
    EndIf


    If PixelGetColor($pos[0], $pos[1]) = $colorundermouse Then 
        Send("{NUMPAD3}}") 
        Send("{NUMPAD3}}") 
        Send("{NUMPAD3}}") 
        Send("{NUMPAD3}}") 
        sleep(1000) 
        MouseClick("middle")
        sleep(1000)
        Send("{NUMPAD3}}") 
        MouseMove($pos3[0], $pos3[1])
        Sleep(500)
        Mouseclick("left")
        Sleep(500)
        MouseMove($pos4[0], $pos4[1])
        Sleep(500)
        Mouseclick("left")
        Sleep(9999999999)
    Else
        Mouseclick("left")
        sleep(180000)
        
    Endif
        



$i = $i + 1

Until $i = 999

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.