dustinisgod Posted January 11, 2022 Share Posted January 11, 2022 (edited) If GUICtrlRead($checkbox) = $GUI_CHECKED And Not (PixelGetColor(GUICtrlRead($value1x), GUICtrlRead($value1y)) = (GUICtrlRead($testcolor1))) And Not (PixelGetColor(GUICtrlRead($value1x), GUICtrlRead($value1y)) = (GUICtrlRead($testcolor2))) And Not (PixelGetColor(GUICtrlRead($value1x), GUICtrlRead($value1y)) = (GUICtrlRead($testcolor3))) Then dothething() EndIf Trying to make sure a color in the assigned pixel location is not one of the 3 color values. The way I'm doing it works.. but is there a cleaner way? Thanks. Edited January 11, 2022 by dustinisgod Link to comment Share on other sites More sharing options...
Nine Posted January 12, 2022 Share Posted January 12, 2022 Hmm, what game is this for ? Musashi and Bert 1 1 “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
markyrocks Posted January 12, 2022 Share Posted January 12, 2022 Shoving a couple more function calls in there might clean it up a bit. I saw a little bit of white space in there that could use filling. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
ad777 Posted January 12, 2022 Share Posted January 12, 2022 (edited) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 112, 32, 75, 25);button $Button2 = GUICtrlCreateButton("Button1", 112, 32, 75, 25);button $Input1= GUICtrlCreateInput("testcolor1", 56, 64, 121, 21);testcolor1 $Input2 = GUICtrlCreateInput("testcolor2", 56, 64, 121, 21);testcolor2 $Input3 = GUICtrlCreateInput("testcolor3", 56, 64, 121, 21);testcolor3 $value1x = GUICtrlCreateInput("", 56, 64, 121, 21);value1x $value1y = GUICtrlCreateInput("", 56, 64, 121, 21);value1y GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 1 To 3 Step 1;;check every testcolor 1 2 3 If GUICtrlRead($checkbox) = $GUI_CHECKED And Not (PixelGetColor(GUICtrlRead($value1x), GUICtrlRead($value1y)) = (ControlGetText("Form1","","Edit"&$i))) dothething() EndIf Next EndSwitch WEnd Edited January 12, 2022 by ad777 iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
dustinisgod Posted January 13, 2022 Author Share Posted January 13, 2022 On 1/11/2022 at 7:34 PM, Nine said: Hmm, what game is this for ? For the game of making money. I am trying to automate functions for controlling my mining computers. Link to comment Share on other sites More sharing options...
dustinisgod Posted January 13, 2022 Author Share Posted January 13, 2022 9 hours ago, markyrocks said: Shoving a couple more function calls in there might clean it up a bit. I saw a little bit of white space in there that could use filling. I am assuming this is snark? Unfortunately, I have zero programming experience, and am self teaching myself this stuff and my coding skills are below basic at the moment. Hopefully, I will be better with time. Link to comment Share on other sites More sharing options...
dustinisgod Posted January 13, 2022 Author Share Posted January 13, 2022 (edited) 23 hours ago, ad777 said: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 112, 32, 75, 25);button $Button2 = GUICtrlCreateButton("Button1", 112, 32, 75, 25);button $Input1= GUICtrlCreateInput("testcolor1", 56, 64, 121, 21);testcolor1 $Input2 = GUICtrlCreateInput("testcolor2", 56, 64, 121, 21);testcolor2 $Input3 = GUICtrlCreateInput("testcolor3", 56, 64, 121, 21);testcolor3 $value1x = GUICtrlCreateInput("", 56, 64, 121, 21);value1x $value1y = GUICtrlCreateInput("", 56, 64, 121, 21);value1y GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 1 To 3 Step 1;;check every testcolor 1 2 3 If GUICtrlRead($checkbox) = $GUI_CHECKED And Not (PixelGetColor(GUICtrlRead($value1x), GUICtrlRead($value1y)) = (ControlGetText("Form1","","Edit"&$i))) dothething() EndIf Next EndSwitch WEnd For $i = 1 To 3 Step 1 Thanks for the help. I looked up this bit of code on the help section. And I kind of understand it. What I do not understand is how does it know that $Input1,2,3 are the variables that it should be reading? (ControlGetText("Form1","","Edit"&$i))) Update: I think I have figure out what this means.. so where It says Edit.. If this is changed to $Input1.. the code starts at input 1 in the form1.. then steps 1 down to the next line which would be input 2.. then steps again to the 3rd which is input3. Am I understanding this correctly? Edited January 13, 2022 by dustinisgod Link to comment Share on other sites More sharing options...
Nine Posted January 13, 2022 Share Posted January 13, 2022 (edited) Ok then, are you sure you cannot read those numbers directly from the application instead of trying to read the pixels ? Can you tell us a bit more about the application (is it a windows app or web app) ? Have you tried to use au3info tool over the fields ? Overall, using pixel* functions is probably the worst way to automate an application. Make sure you eliminate all robust approach before reverting to pixel ! Edited January 13, 2022 by Nine “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
markyrocks Posted January 13, 2022 Share Posted January 13, 2022 (edited) 14 hours ago, dustinisgod said: I am assuming this is snark? Unfortunately, I have zero programming experience, and am self teaching myself this stuff and my coding skills are below basic at the moment. Hopefully, I will be better with time. You will get better. I was joking. But the truth is if your code looks like that set a variable equal to the function. When started out it took me a minute to get this concept aswell. When a function returns a value regardless doing something like $retVal=func() will set the variable to whatever that value is. Then you don't have to keep calling that function to get the value bc you can just use your variable instead. In your case it will make your code alot more readable. When I look at the first post it makes my eyes water. But keep at it. Good luck. Edit also reducing function calls makes your script faster. Efficiency is king. Edited January 13, 2022 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
SkysLastChance Posted January 13, 2022 Share Posted January 13, 2022 Can I have some of the graphics cards you are hoarding? You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott 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