ankprsn Posted November 26, 2023 Posted November 26, 2023 Hello I'm a new autoit user, I'm not a programmer - I'm just playing out of curiosity. But I have a question/problem: With the help of the Internet, I wrote a simple code that aims to press the "DEL" key when a given color appears on the screen, and then I want the code to wait until the effect of pressing "DEL" disappears, i.e. until the next color disappears. The problem is that the second color does not always disappear after the same time. I tried to write the code to check whether the color is still on the screen, if it is, it will wait longer and if not, it will start the loop from the beginning, but the code continues even if the color is on the screen: While 1 $color = PixelGetColor(3502, 57) If $color <> 0x4D4D4D Then Send("{DEL}") While PixelGetColor(3494, 65) = 0xFF0000 Sleep(100) WEnd MouseMove(100, 100) EndIf The point is that I want the code to check whether the color 0xFF0000 is on the screen, if it is, it will wait 1 second and check again and so on until it is gone and then move on. I don't know what the problem is? Should GetPixelColor be at the very beginning of the code for this to work? or whatever it is Thanks up for answer
Andreik Posted November 26, 2023 Posted November 26, 2023 Print to console the read colors and make sure it's the expected color at the expected coordinates: While True $FirstColor = PixelGetColor(3502, 57) If $FirstColor <> 0x4D4D4D Then ConsoleWrite('First color: 0x' & Hex($FirstColor, 6) & @CRLF) Send("{DEL}") Do $SecondColor = PixelGetColor(3494, 65) ConsoleWrite('Second color: 0x' & Hex($SecondColor, 6) & @CRLF) Sleep(100) Until $SecondColor <> 0xFF0000 MouseMove(100, 100) EndIf WEnd
ankprsn Posted November 26, 2023 Author Posted November 26, 2023 Unfortunately, it's still the same, the code checks the first color and finds differences, but when looking for the second color, it still moves on after the first search instead of waiting for the color to disappear. First color: 0x0A0502 Second color: 0x4A4A4A First color: 0x0A0502 Second color: 0x4A4A4A First color: 0x323C41 Second color: 0x4A4A4A First color: 0x323C41 Second color: 0xFF0000 First color: 0x323C41 Second color: 0x000000 First color: 0x323C41 Second color: 0xFF0000 First color: 0x323C41 Second color: 0x000000 First color: 0x323C41 Second color: 0xFF0000 First color: 0x323C41 Second color: 0x4A4A4A First color: 0x323C41 Second color: 0xFF0000 First color: 0x323C41 Second color: 0xFF0000 First color: 0x0A0502 Second color: 0x4A4A4A First color: 0x0A0502 Second color: 0x4A4A4A First color: 0x0A0502 Second color: 0xFF0000 First color: 0x0A0502 Second color: 0xFF0000 As you can see, the code finds the second color but does not check again whether it is still on the screen, it just moves on
Nine Posted November 26, 2023 Posted November 26, 2023 8 hours ago, ankprsn said: aims to press the "DEL" key when a given color appears So shouldn't it be : If $FirstColor = 0x4D4D4D Then “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
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