Mandi Posted September 18, 2018 Posted September 18, 2018 Hello! Im quite new to Autoit and would love some help. My question is about the pixelsearch function. I So I've two problems. 1. I've selected a Area to pixelsearch in. There is 3 diffrent spots of the the same pixel within the pixelsearch area, but the script tend to just stay in 1 spot. 2. Insted of using Sleep() delay to move from pixels within the area , I would like to automate it in a way where if the current pixel you on dispear it moves to another in the area. (I hope it makes sense) Here is the short code While $pixels = PixelSearch(808, 503, 1064, 685 , 0x484537, 1) if Not(@error) then LC($pixels[0], $pixels[1]) sleep(15000) WEnd Func LC($x, $y) mouseclick( "left", $x, $y, 1, 1) EndFunc
badcoder123 Posted September 19, 2018 Posted September 19, 2018 (edited) While $pixels = PixelSearch(808, 503, 1064, 685 , 0x484537, 1) If Not(@error) then LC($pixels[0], $pixels[1]) Do Sleep(50) Until PixelGetColor($pixels[0], $pixels[1]) <> 0x484537 EndIf WEnd Func LC($x, $y) mouseclick( "left", $x, $y, 1, 1) EndFunc something like this? Edited September 21, 2018 by badcoder123 forgot endif
Mandi Posted September 21, 2018 Author Posted September 21, 2018 On 2018-09-19 at 5:11 AM, badcoder123 said: While $pixels = PixelSearch(808, 503, 1064, 685 , 0x484537, 1) if Not(@error) then LC($pixels[0], $pixels[1]) Do Sleep(50) Until PixelGetColor($pixels[0], $pixels[1]) <> 0x484537 WEnd Func LC($x, $y) mouseclick( "left", $x, $y, 1, 1) EndFunc something like this? Dont work So there is 2 buttons of the same colour. I want the script to press one and wait until the colour change, and then press on the other button. But it dont work...
jdelaney Posted September 21, 2018 Posted September 21, 2018 Use the AutoIt spy tool, and hover over your control. Then post us back the text in the summary tab. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Mandi Posted September 21, 2018 Author Posted September 21, 2018 It does the action 1 time, but i have problem looping it. while (1) $pixel = pixelsearch( 764, 185, 815, 232, $color ,1) If Not(@error) Then LC ($pixel[0], $pixel[1]) EndIf Do sleep(500) Until pixelgetcolor($pixel[0], $pixel[1]) <> $color $pixel = pixelsearch( 804, 146, 856, 186, $color ,1) If Not(@error) Then LC ($pixel[0], $pixel[1]) EndIf Do sleep(500) Until pixelgetcolor($pixel[0], $pixel[1]) <> $color WEnd Func LC($x, $y) mouseclick( "left", $x, $y, 1, 1) EndFunc
badcoder123 Posted September 21, 2018 Posted September 21, 2018 (edited) 1 hour ago, k0ownzz said: It does the action 1 time, but i have problem looping it. while (1) $pixel = pixelsearch( 764, 185, 815, 232, $color ,1) If Not(@error) Then LC ($pixel[0], $pixel[1]) EndIf Do sleep(500) Until pixelgetcolor($pixel[0], $pixel[1]) <> $color $pixel = pixelsearch( 804, 146, 856, 186, $color ,1) If Not(@error) Then LC ($pixel[0], $pixel[1]) EndIf Do sleep(500) Until pixelgetcolor($pixel[0], $pixel[1]) <> $color WEnd Func LC($x, $y) mouseclick( "left", $x, $y, 1, 1) EndFunc made an edit to first comment - retry Edited September 21, 2018 by badcoder123
IAMK Posted September 21, 2018 Posted September 21, 2018 Does "Until" work? Try: While (pixelgetcolor($pixel[0], $pixel[1]) <> $colour) LC($x, $y) WEnd
Bert Posted September 21, 2018 Posted September 21, 2018 Lets start out with the application you wish to automate. I ask this for in many cases we have already coded what you have tried to do and it is a simple matter of finding the code you need. Also using pixel searching is the worst way to automate for if there is any changes in color your script breaks. Thanks in advance. The Vollatran project My blog: http://www.vollysinterestingshit.com/
Mandi Posted September 24, 2018 Author Posted September 24, 2018 For me Pixelgetcolor and until worked. Thanks a lot for the help everyone. Really appricated!
Mandi Posted September 24, 2018 Author Posted September 24, 2018 Hello. I wanted to do pixelsearch and left mouseclick in my script, but it clicked the wrong location. I did search for answers and minimized screen is my problem. Is there any way to bypass this??? would love to know Kind regards
Moderators JLogan3o13 Posted September 24, 2018 Moderators Posted September 24, 2018 Why did you start a new thread? And yes, there is a way to bypass it - stop using pixelsearch which is unreliable and start using Control* commands. But as has been pointed out, so long as you are not providing info on what you are trying to accomplish it is a bit difficult to assist. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Mandi Posted September 24, 2018 Author Posted September 24, 2018 14 minutes ago, JLogan3o13 said: Why did you start a new thread? And yes, there is a way to bypass it - stop using pixelsearch which is unreliable and start using Control* commands. But as has been pointed out, so long as you are not providing info on what you are trying to accomplish it is a bit difficult to assist. I started a thread since I could not find a solution for the problem. I want the script to scan a area for a specific colour. If the color is found then i want to click it. I had no problem with it in the past on fullscreen windows, but When i've the window minimized/smaller it dosent work.(I dont have it tabbed down, the window im using is just no fullscreen). It simply will just click on wrong spot insted of clicking the color and i dont have this problem with fullscreen windows... Would love help with it AutoItSetOption ("MouseCoordMode", 0) winactive ("X.X.X") $pixel = PixelSearch(7, 9, 508, 329, 0x64483F, 1) If Not (@error) Then sleep(300) LC ($pixel[0], $Pixel[1]) EndIf Func LC ($x, $y) mouseclick ("left", $x, $y, 1, 15) EndFunc
Moderators JLogan3o13 Posted September 24, 2018 Moderators Posted September 24, 2018 Stick to one thread in the future. And you still haven't explained why you can't use Control* commands. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Mandi Posted September 24, 2018 Author Posted September 24, 2018 (edited) 4 minutes ago, JLogan3o13 said: Stick to one thread in the future. And you still haven't explained why you can't use Control* commands. If i understand right controlclick is = click that dosen't involve your mouse having to click? Does that mean i can do other things on computer while running script? How can i make controlclick insted of LC/ Left mouseclick like the example above? I made this thread since i could not find answer. Could you link me to a thread with same problem and solution? Edited September 24, 2018 by Mandi Adding information
Moderators JLogan3o13 Posted September 24, 2018 Moderators Posted September 24, 2018 Yes, it clicks on the control without you having to move the mouse, the window doesn't even have to be active. You can view the example in the help file and try to match to your needs, or you can use the AutoIt Window Info Tool (in the same directory where you installed AutoIt) on the window and control you're trying to click on and post here so we have some actual information to help you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
IAMK Posted September 25, 2018 Posted September 25, 2018 https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm You need to figure out the handle to use it.
Mandi Posted September 25, 2018 Author Posted September 25, 2018 I still need to find a way to pixelsearch in minimized window.
Moderators JLogan3o13 Posted September 25, 2018 Moderators Posted September 25, 2018 (edited) The entire point is you cannot. If you want a resolution to your problem you need to provide an example of the window you're trying to search on, and why it must stay minimized. We cannot both guess at what you're trying to do and try and fix it for you. Help us help you. Edited September 25, 2018 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Danp2 Posted September 25, 2018 Posted September 25, 2018 @k0ownzz You never provided the application name as previously requested. Without that, you probably won't get much additional input. Latest Webdriver UDF Release Webdriver Wiki FAQs
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