vivec45 Posted May 26, 2008 Share Posted May 26, 2008 HotKeySet("{f7}", "tp") $left = 1000 $top = 1000 $right = 1000 $bottom = 1000 $color = 0xff0000 $shadevar = 25 $step = 1 Func tp() $pos = PixelSearch($left, $top, $right, $bottom, $color, $shadevar, $step) sleep(2000) MouseMove($pos[0], $pos[1]) sleep(2000) MouseClick("Left") EndFunc while 1 sleep(1) WEnd Whats wrong with this script? Also, when they say sizes, what is this in? Pixels around the mouse? What is a reasnable number for a normal sized window? The script is supposed to search the entire screen for red, move the mouse to it, then left click ;/! Link to comment Share on other sites More sharing options...
martin Posted May 26, 2008 Share Posted May 26, 2008 (edited) HotKeySet("{f7}", "tp") $left = 1000 $top = 1000 $right = 1000 $bottom = 1000 $color = 0xff0000 $shadevar = 25 $step = 1 Func tp() $pos = PixelSearch($left, $top, $right, $bottom, $color, $shadevar, $step) sleep(2000) MouseMove($pos[0], $pos[1]) sleep(2000) MouseClick("Left") EndFunc while 1 sleep(1) WEnd Whats wrong with this script? Also, when they say sizes, what is this in? Pixels around the mouse? What is a reasnable number for a normal sized window? The script is supposed to search the entire screen for red, move the mouse to it, then left click ;/!The rectangle you specified is incorrect, $top,$left should be the x,y coords of the top left and $right,$bottom should be the x,y coords o fthe bottom right. Might be worth adding something to allow ending the script. I tried this, with a colour change to test on my PC. HotKeySet("{f7}", "tp") HotKeySet("{F8}","leave") $left = 900 $top = 0 $right = 1000 $bottom = 10 $color = 0xfcfcfc $shadevar = 25 $step = 1 Func tp() $pos = PixelSearch($left, $top, $right, $bottom, $color, $shadevar, $step) ;sleep(2000) MouseMove($pos[0], $pos[1]) sleep(2000) MouseClick("Left") EndFunc while 1 sleep(1) WEnd Func leave() Exit EndFunc EDIT: to search the entire screen you need $pos = PixelSearch($left, $top, 0,0,@DesktopWidth,@DesktopHeight, $step) Edited May 26, 2008 by martin 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...
vivec45 Posted May 26, 2008 Author Share Posted May 26, 2008 The rectangle you specified is incorrect, $top,$left should be the x,y coords of the top left and $right,$bottom should be the x,y coords o fthe bottom right. Might be worth adding something to allow ending the script. I tried this, with a colour change to test on my PC. HotKeySet("{f7}", "tp") HotKeySet("{F8}","leave") $left = 900 $top = 0 $right = 1000 $bottom = 10 $color = 0xfcfcfc $shadevar = 25 $step = 1 Func tp() $pos = PixelSearch($left, $top, $right, $bottom, $color, $shadevar, $step) ;sleep(2000) MouseMove($pos[0], $pos[1]) sleep(2000) MouseClick("Left") EndFunc while 1 sleep(1) WEnd Func leave() Exit EndFunc EDIT: to search the entire screen you need $pos = PixelSearch($left, $top, 0,0,@DesktopWidth,@DesktopHeight, $step) >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Robin\Desktop\tp.au3" C:\Documents and Settings\Robin\Desktop\tp.au3 (14) : ==> Subscript used with non-Array variable.: MouseMove($pos[0], $pos[1]) MouseMove($pos^ ERROR >Exit code: 0 Time: 2.311 Link to comment Share on other sites More sharing options...
LinuZ Posted May 26, 2008 Share Posted May 26, 2008 >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Robin\Desktop\tp.au3" C:\Documents and Settings\Robin\Desktop\tp.au3 (14) : ==> Subscript used with non-Array variable.: MouseMove($pos[0], $pos[1]) MouseMove($pos^ ERROR >Exit code: 0 Time: 2.311Meaning it didn't find it... So you could add an error check before that like: If @error = 1 then Exit or something... 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