SkyDancer Posted January 31, 2019 Posted January 31, 2019 Const $pixel_check_x = 1030 Const $pixel_check_y = 409 Const $pixel_check_color = 13093063 Const $send_delay_ms = 520 Do $pixel = PixelGetColor($pixel_check_x, $pixel_check_y) Until $pixel = $pixel_check_color Sleep($send_delay_ms) Send("{SPACE}") Exit I have this code but delay is always random time after color matched, how to make color waiting with a static time then make some static delay and then pres Space button? Thank you.
Nine Posted January 31, 2019 Posted January 31, 2019 How do you know it is random ? Sleep () works perfectly. It is your loop that takes a random time to find the right color. IMO. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
SkyDancer Posted January 31, 2019 Author Posted January 31, 2019 5 minutes ago, Nine said: It is your loop that takes a random time to find the right color. IMO. Exectly. I need to search color with a static time. Is it posible to do it in AutoIt?
Nine Posted January 31, 2019 Posted January 31, 2019 yes, just remove the loop, it will be static... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
SkyDancer Posted January 31, 2019 Author Posted January 31, 2019 But how to wait for specific lolor then? I need to wait till one pixel on the screen changed the color then I need static delay and then Press Space button. So the basic question is how to wait for the pixel color changet with a static time, the pixel position is always static so it has to be static time for search it.
Nine Posted January 31, 2019 Posted January 31, 2019 4 minutes ago, SkyDancer said: I need to wait till one pixel on the screen changed the color If that change happens randomly, it will be random, you cannot have both. And may I ask what kind of application you are trying to automate ? Could help if we know what you are attempting to do “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
SkyDancer Posted January 31, 2019 Author Posted January 31, 2019 Im trying to make a unit test for my own web application. And I know the pixel color time is random but after pixel changed, from this moment next steps have to be with a static time but seems like the time for pixel search is random, but it has to be static since the pixel coordinates are always the same or I understand pixel search algorithm wrong?
Nine Posted January 31, 2019 Posted January 31, 2019 Try this : Const $pixel_check_x = 1030 Const $pixel_check_y = 409 Const $pixel_check_color = 13093063 Const $send_delay_ms = 520 $timer = TimerInit () Do $pixel = PixelGetColor($pixel_check_x, $pixel_check_y) Until $pixel = $pixel_check_color Sleep($send_delay_ms - TimerDiff($Timer)) Send("{SPACE}") It will be static unless the pixel doesn't show before end of delay. But you can manage that, right ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
badcoder123 Posted January 31, 2019 Posted January 31, 2019 Made this function and modified it Func _ColourReturn($x, $y, $colour) If PixelGetColor($x, $y, $hWnd) = $colour Then Return True If PixelGetColor($x, $y, $hWnd) <> $colour Then Return False EndFunc Try this out. Just set a sleep delay in the do loop Const $pixel_check_x = 1030 Const $pixel_check_y = 409 Const $pixel_check_color = 13093063 Const $send_delay_ms = 520 Const $iStaticSleep = xxxxxxxxxxxxxxxx Do Sleep($iStaticSleep) Until _ColourReturn($pixel_check_x, pixel_check_y, $pixel_check_color) Sleep($send_delay_ms) Send("{SPACE}") Exit Func _ColourReturn($x, $y, $colour) If PixelGetColor($x, $y) = $colour Then Return True If PixelGetColor($x, $y) <> $colour Then Return False EndFunc
careca Posted January 31, 2019 Posted January 31, 2019 It'll just loop until the color is found, just like the code in the first post, they seem the same to me. Quote from this moment next steps have to be with a static time but seems like the time for pixel search is random, but it has to be static since the pixel coordinates are always the same Well, in theory yes, since you give the coordinates, it should take the same time, every time, but probably because of the cpu load or other factors, there may be a small random delay each time, you have to code counting with it. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
SkyDancer Posted February 1, 2019 Author Posted February 1, 2019 18 hours ago, careca said: but probably because of the cpu load or other factors, there may be a small random delay each time, you have to code counting with it. That is not a small rng time, its around 50-200ms, can it be cuz I run script from IDE? Cuz tbh I didn't try to compile and use it as exe script file...
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