nathan546 Posted June 14, 2004 Share Posted June 14, 2004 Is it possible to get the Top left, Top right,Bottom Left, and Bottom Right cordinates for Pixel Checksum/Search using a script of some sort. Like you would put your cursor on the left, top, right, bottom coordinates of rectangle, and it would return the cordinates to you so you could use them in a script? If so how would I do this(tell me if you cant do it so im not waiting). Thanks. Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 There is no need to write a script to do this since the AU3_Spy can do it for you. Look in your installation directory for AutoIt, and run the AU3_Spy.exe program. It will give you a window listing both window, and fulscreen cursor coordinates. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 (edited) I know but, im trying to make a bot so a place can set the left,top,right,and bottom coordinates and then it will search for a pixel color inside those coordinates and click it. So is it possible and how would I do it? EDIT: Also i dont need to it to do it to the whole screen, i need it to do a part of the screen in rectangle, or square form because their is more than 1 part of the screen that has the same color and it will start clicking the wrong spot. Edited June 14, 2004 by nathan546 Link to comment Share on other sites More sharing options...
emmanuel Posted June 14, 2004 Share Posted June 14, 2004 define hotkeys that do mousegetpos, then do a splash screen or something that prompts the user to put the mouse in the right place and hit that hotkey to get that pos... something like that? "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 I need the Dimensions of the square/rectangle though not the cursor coordinates, I alrdy have a script made for that. Actually i have the bot completly made its just the screen shifts some then it starts clicking off the area and im going to make sure it clicking the right color and if its not im going to make it shut off or reask for coordinates, or maybe just let it click randomly at that pixel color if it messes up. Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 define hotkeys that do mousegetpos, then do a splash screen or something that prompts the user to put the mouse in the right place and hit that hotkey to get that pos... something like that?I did that just 2 days ago for a "Keep mouse in boundry" script. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 (edited) I did that just 2 days ago for a "Keep mouse in boundry" script. Keep mouse in boundry is basically what I need but more complex to where it has to click a certain color too. Maybe i don't get what he means but how is getting the cursor coordinates going to keep it from clicking outside the boundry? EDIT: Something like this is what i need $XY = PixelSearch(1, 2, 3, 4, Color Here) If Not @ERROR Then Sleep(3500) MouseClick("left",$XY[0],$XY[1], 1, 0) EndIf only i need to be able to set the 1, 2, 3, and 4 to click in a certain area like inside a X on the screen (i can do the color but thats no good right now). Edited June 14, 2004 by nathan546 Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 You can use the coordinates to feed your pixel search program, and only click if the result of the pixelsearch is a positive result (as in it worked.) If it helps, feel free to check out my MouseInBounds script, avaiable from my Public Examples directory.I know that program doesn't do excatally what you want, so read the helpfile on PixelSearch and MouseGetPos. It would do you no good if I took time to write your script [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 It would do you no good if I took time to write your script I disagree with that ive learned everything about guis for autoit by looking after other peoples scripts and using bits and peices till i figure out how to do it . Anyways ill take a look at them and try to figure it out. Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 (edited) ive learned everything about guis for autoit by looking after other peoples scripts and using bits and peices till i figure out how to do itYou learn so much more by doing the research yourself, and writing the code on your own that pasting other people's examples into your program and making small changes. The problem with doing that is that you don't know if there's a better way to do what your goal is. I normally don't write code as complete as the linked example, but I already had it written. It's not excatally what you want, but it should demonstrate how the critical functions work, such as hotkeys, and the MouseGetPos command.Minor edit Edited June 14, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 You learn so much more by doing the research yourself, and writing the code on your own that pasting other people's examples into your program and making small changes. The problem with doing that is that you don't know if there's a better way to do what your goal is. I normally don't write code as complete as the linked example, but I already had it written. It's not excatally what you want, but it should demonstrate how the critical functions work, such as hotkeys, and the MouseGetPos command.Minor edit I dont copy and paste usually, I just look at it till I understand what im doing. Anyways time to go look at your source and help file to see what I can come up with. Link to comment Share on other sites More sharing options...
Guest Guest Posted June 14, 2004 Share Posted June 14, 2004 It didnt help because it still tries to click outside the boundrys anyways. Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 (edited) It didnt help because it still tries to click outside the boundrys anyways.Why should it click outside your boundry if you're only searching for a pixel inside the boundry to begin with??? $result = PixelSearch($left, $top, $right, $bottom, $color) If @error = 1 Then MsgBox(0, "Color Not Found", "Color not found in region, now quitting") Exit EndIf MouseClick("left", $result[0], $result[1]) This code will NEVER click outside the area in which you searched. Corrected MouseClick to include the button paramater Edited June 14, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 (edited) it always logs me out after like a day forgot to log back in, anyways heres a another question.How come when I put this it clicks at the top left hand corner of the screen (where coordinates 1,1 would click) The red part doesn't work and saysMouseClick("Left", $coord[0], $coord[1], 1, 1)MouseClick("Left", $coord^ERRORError: Subscript used with a non-Array variableBut when I take them out it clicks in the top left hand corner of the screen.Func PixelClick()$Mouse = MouseGetPos()$Pixel1 = IniRead("Config.ini", "Pixels", "Pixels1", $Pixel1)$Pixel2 = PixelGetColor($Mouse[0], $Mouse[1])$coord = PixelSearch( 0, 0, 1024, 768, $Pixel1)If $Pixel1 = $Pixel2 ThenMouseClick("Left", $Pixel2, $Pixel2, 1, 1)ElseMouseClick("Left", $coord[0], $coord[1], 1, 1)EndIfEndFuncFunc Pixel()Pixel1()EndFuncFunc Pixel1()MsgBox(4096, "Paused", "1. Put your cursor on a pixel",)Sleep(2000)$Mouse1 = MouseGetPos()$Pixel1 = PixelGetColor($Mouse1[0], $Mouse1[1])IniWrite("Config.ini", "Pixels", "Pixels1", $Pixel1)MsgBox(4096, "Paused", "Pixel Set",)EndFuncThen if I use this outside of my script it works as long as the mouse isnt on the right pixel color given.Pixel1()Sleep(2000)PixelClick1()Func PixelClick1()$Mouse = MouseGetPos()$Pixel1 = IniRead("Config.ini", "Pixels", "Pixels1", $Pixel1)$Pixel2 = PixelGetColor($Mouse[0], $Mouse[1])$coord = PixelSearch( 0, 0, 1024, 768, $Pixel1)If $Pixel1 = $Pixel2 ThenMouseClick("Left", $Pixel2, $Pixel2, 1, 1) Â // add [0] [1]?ElseMouseClick("Left", $coord[0], $coord[1], 1, 1)//has [0] [1]EndIfEndFuncFunc Pixel()Pixel1()EndFuncFunc Pixel1()MsgBox(4096, "Paused", "1. Put your cursor on a pixel",)Sleep(2000)$Mouse1 = MouseGetPos()$Pixel1 = PixelGetColor($Mouse1[0], $Mouse1[1])IniWrite("Config.ini", "Pixels", "Pixels1", $Pixel1)MsgBox(4096, "Paused", "Pixel Color Set",)EndFuncEDIT: I didn't know your post Ill give it a try. Edited June 14, 2004 by nathan546 Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 Regarding your subscript error, you need to check @error right away after using the PixelSearch command to verify that it found a pixel. If it didn't, you won't get an array back, so you can't access it with $return[0].As for your 2nd issue, why are you using a pixel color in a MouseClick function? You should never do that. Only use numbers in the range of 0 to whatever your resolution is for the X or Y paramater (in effect, a mouse coordinate.) [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 Ok i tried remaking it off what you said it gives me the same Subscript Error. Func PixelClick() $left = IniRead("Config.ini", "Pixels", "left", "Not Found") $top = IniRead("Config.ini", "Pixels", "top", "Not Found") $right = IniRead("Config.ini", "Pixels", "right", "Not Found") $bottom = IniRead("Config.ini", "Pixels", "bottom", "Not Found") $Pixels1 = IniRead("Config.ini", "Pixels", "Pixels1", "Not Found") $Pixel1 = PixelSearch($left, $top, $right, $bottom, $Pixels1) If @error = 1 Then MsgBox(4096, "Paused", "Error",) EndIf MouseClick("left", $Pixel1[0], $Pixel1[1]) EndFunc Link to comment Share on other sites More sharing options...
pekster Posted June 14, 2004 Share Posted June 14, 2004 Ok i tried remaking it off what you said it gives me the same Subscript Error.Look at your conditional code. You only display a message box if the pixel wasn't found, and then try to access an invalid array. You can't run that MouseClick unless the command succeeds. Also, be sure those ini keys exist, otherwise it will think of the "Not Found" text as the number 0 when used in Pixel or Mouse functions. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
nathan546 Posted June 14, 2004 Author Share Posted June 14, 2004 (edited) My config file [Pixels] Pixels1=7105751 // part of the Autoit icon color left=0 top=0 right=1024 bottom=768 Pixel1() Start() Func Pixel1() MsgBox(4096, "Paused", "1. Put your cursor on a color of the mine",) Sleep(2000) $Mouse1 = MouseGetPos() $Pixel1 = PixelGetColor($Mouse1[0], $Mouse1[1]) IniWrite("Config.ini", "Pixels", "Pixels1", $Pixel1) MsgBox(4096, "Paused", "Mine Color Set",) EndFunc Func Start() $left = IniRead("Config.ini", "Pixels", "Left", "Not Found") $top = IniRead("Config.ini", "Pixels", "Top", "Not Found") $right = IniRead("Config.ini", "Pixels", "Right", "Not Found") $bottom = IniRead("Config.ini", "Pixels", "Bottom", "Not Found") $Pixel1 = IniRead("Config.ini", "Pixels", "Pixels1", "Not Found") $Pixel2 = PixelSearch($left, $top, $right, $bottom, $Pixel1) If @error = 1 Then MsgBox(4096, "Paused", "Error",) Exit EndIf MouseClick("left", $Pixel1[0], $Pixel1[1]) EndFunc Now it just says Error and exits it never clicks anywhere at all. This 1 clicks on the right spot unless its already on the right spot then it just messes up, so why does this 1 partly work but the other 1 doesn't Pixel1() Sleep(2000) PixelClick1() Func PixelClick1() $Mouse = MouseGetPos() $Pixel1 = IniRead("Config.ini", "Pixels", "Pixels1", $Pixel1) $Pixel2 = PixelGetColor($Mouse[0], $Mouse[1]) $coord = PixelSearch( 0, 0, 1024, 768, $Pixel1) If $Pixel1 = $Pixel2 Then MouseClick("Left", $Pixel2, $Pixel2, 1, 1) Else MouseClick("Left", $coord[0], $coord[1], 1, 1) EndIf EndFunc Func Pixel() Pixel1() EndFunc Func Pixel1() MsgBox(4096, "Paused", "1. Put your cursor on a color",) Sleep(2000) $Mouse1 = MouseGetPos() $Pixel1 = PixelGetColor($Mouse1[0], $Mouse1[1]) IniWrite("Config.ini", "Pixels", "Pixels1", $Pixel1) MsgBox(4096, "Paused", "Color Set",) EndFunc Edited June 14, 2004 by nathan546 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