
Atzi
Members-
Posts
10 -
Joined
-
Last visited
Everything posted by Atzi
-
Also will try to combine start function with regular one using variable vor sleep ... should make things more clean i guess... Will have a cloder look on the isarray once i got some time
-
The Mousemove looked like working fine actually but the pixelfind seemed to act strange on different positions of the Screen actually. For now i added a WinGetPos and WinMove If in the first function to call untill i got a better solution for that. Dont understand the DPI Thing after reading a whole bunch... i set my Windows to Standard 100% which should be 96dpi and i am running it on 1920x1080 also the Window i am looking for Pixels is set to 960x540 and according to our IT @ Workspace should be running in Standard Win10dpi - also 96dps. Really dunno if and how this could mess up here. Worked out something that seems to work pretty good for what it yet is tho: Wasnt too sure about removing your error Outputs but seemed to be lots easier for me to work with Little less lines per function for now - might add some error Messages mack in later if you recommend to tho as i am really willing to learn sth from the once who know what they do Opt("CaretCoordMode", 0) HotKeySet("{ESC}", "_Exit") Global $todo = 1 Global $WinTitle = "Main" Global $WinPosSh = [1, 1] Global $NAr = [740, 255, 764, 277] Global $NCol = 0x3AA4C2 Global $SAr = [444, 487, 524, 507] Global $SCol = 0x97FFEE Global $OkAnAr = [469, 412, 503, 430] Global $OkAnCol = 0xEEFFFF Global $OkAdAr = [442, 481, 522, 503] Global $OkAdCol = 0xFFF954 Global $SIRAr = [922, 47, 944, 67] Global $SIRCol = 0xCEFCFC Global $DoneAr = [906, 509, 936, 535] Global $DoneCol = 0xFDF5B3 While $todo = 1 $todo = Search_nClickStart($WinTitle, $NAr, $NCol, $todo) Sleep (50) WEnd While $todo = 2 $todo = Search_nClickStart($WinTitle, $SAR, $SCol, $todo) Sleep (50) WEnd While $todo = 3 $todo = Search_nClick($WinTitle, $OkAnAr, $OkAnCol, $todo) Sleep(50) WEnd While $todo = 4 $todo = Search_nClick($WinTitle, $OkAdAr, $OkAdCol, $todo) Sleep(50) WEnd While $todo = 5 $todo = Search_nClick($WinTitle, $SIRAr, $SIRCol, $todo) Sleep(50) WEnd While $todo = 6 $todo = Search_nClickDone($WinTitle, $DoneAr, $DoneCol, $todo) Sleep(50) WEnd _Exit() Func Search_nClickStart($sMain, ByRef $aSearch, $iColor, $iTodo) Local $MainHWnd = WinActivate($sMain) Local $WinPosIS = WinGetPos($Wintitle) If not $WinPosIs[0] = $WinPosSh[0] And $WinPosIs[1] = $WinPosSh[1] Then WinMove ($WinTitle,"",$WinPosSh[0],$WinPosSh[1]) EndIf Local $GotPos = PixelSearch($aSearch[0], $aSearch[1], $aSearch[2], $aSearch[3], $iColor, 0, 1, $MainHWnd) If IsArray($GotPos) And Not @error Then ConsoleWrite(" Clicked " & $GotPos[0] & " x " & $GotPos[1] & " - move on!" & @CRLF) ControlClick($WinTitle, "", "", "left", 1, $GotPos[0], $GotPos[1]) $iTodo += 1 Sleep(20000) Else ConsoleWrite(" Not found - move on!" & @CRLF) EndIf Return $iTodo EndFunc ;==>Search_nClickStart Func Search_nClick($sMain, ByRef $aSearch, $iColor, $iTodo) Local $MainHWnd = WinActivate($sMain) Local $GotPos = PixelSearch($aSearch[0], $aSearch[1], $aSearch[2], $aSearch[3], $iColor, 0, 1, $MainHWnd) If IsArray($GotPos) And Not @error Then ConsoleWrite(" Clicked " & $GotPos[0] & " x " & $GotPos[1]) ControlClick($WinTitle, "", "", "left", 1, $GotPos[0], $GotPos[1]) Else ConsoleWrite(" - move on!"& @CRLF) $iTodo += 1 EndIf Return $iTodo EndFunc ;==>Search_nClick Func Search_nClickDone($sMain, ByRef $aSearch, $iColor, $iTodo) Local $MainHWnd = WinActivate($sMain) ConsoleWrite(" Clicked " & $DoneAr[0] & " x " & $DoneAr[1]) ControlClick($WinTitle, "", "", "left", 1, $DoneAr[0], $DoneAr[1]) Sleep(1000) Local $GotPos = PixelSearch($aSearch[0], $aSearch[1], $aSearch[2], $aSearch[3], $iColor, 0, 1, $MainHWnd) If IsArray($GotPos) And Not @error Then $itodo += 1 ConsoleWrite(" Finally Done!" & @CRLF) Else ConsoleWrite("Search again!" & @CRLF) EndIf Return $iTodo EndFunc ;==>Search_nClickDone Func _Exit() Exit EndFunc ;==>_Exit Search_nClickStart is for starting up the program (which will be 1 click per button always) Search_nClickDone i added for the last button as it has to check if ist there after clicking another and if yes dont click it anymore (at least for now as Long i dunno what to do next ) here the sleep(1000) seems to be necassary to get a good result but i will test tomorrow if i can get lower on that if i dont have a more clean solution for this
-
Still didnt have the time to test the code but think i found sth that might be not working the way i thought of... the last pixelsearch was actually meant to be the opposite direction... should mean if it doesnt find the pixel click and dont click if found but end function/call new function Just tried your script and all i get is: Failed! Failed! Failed! Failed! EDIT: really trying to fiddle the Problem out and looking closer to it it Looks like an Array Problem with $asearch... and $GotPos not beeing an array If UBound($aSearch) = 4 Then Local $GotPos = PixelSearch($aSearch[0], $aSearch[1], $aSearch[2], $aSearch[3], $iColor, 20, 1, $MainHWnd) ;x and y should be saved to this array ;Sleep(1000) If IsArray($GotPos) And Not @error Then ;<=== doesnt seem to be true as it doesnt return the consolewrite! ConsoleWrite("Click* " & $GotPos[0] & " x " & $GotPos[1]) MouseMove($GotPos[0], $GotPos[1]) ;Just to verify Remove Later ControlClick("Main", "", "", "left", 1, $GotPos[0], $GotPos[1]) Else ConsoleWrite("Failed!" & @CRLF) ;<=== confirms it is an If IsArray($GotPos) problem if i got this right $iTodo += 1 EndIf EDIT2: oddly enough putting the window to another Location on the Screen seems to have done the trick... really dont know why tho. Gotta test again with moving the window to 0,0 added i guess
-
Got what you mean now thx. Gonna check this out on various applications as well then... seems to be lots more comfortable with the control click directly sent to the button as it has a 100÷ success i guess and also should response if the button was actually clicked
-
Thx for the help. I even understand most of ur changes from a logical point of view, which pretty much surprises myself and i do have to do some testing later today to confirm this however what i didnt really get is what you mean with Next ControlClick should do this finding for you if you give it the name of the control and a classname (See helpfile) Could you plz specify this so i know whatelse can be changed
-
Hi there, got a Problem with Arrays it seems, didnt get how it works from my researches it seems. Maybe someone can help me out on this. Want to save coordinates returned from pixelfind to an Array and call that Array again. also want to save predefined Arrays to others so i dont have to set that much variables and simply can copy parts of the codes for other sections. For the Loop... it should do every step of the Code until the conditions are fulfilled (maybe someone got a better solution for that as well - also not sure yet if it resets the $todo to 1 after the script is quit and restarted - but hope so for now). For the "Sleep(1000) after Pixelsearch i am not sure if i really Need that but can test it out after i solved my other Problems. opt("CaretCoordMode",0) Global $MainHWnd Global $GotPos[2] Global $SearAr[4] Global $SearCol Global $todo = 1 ;this should be 1 on each start Global $OkAnAr = [469,412,503,430] Global $OkAnCol = 0xCAFFFF Global $OkAdAr = [459,489,505,507] Global $OkAdCol = 0x800000 Global $SIRAr = [922,47,944,67] Global $SIRCol = 0xCEFCFC Global $DoneAr = [910,511,934,535] Global $DoneCol = 0xFDF5B3 While $todo = 1 OkAn() Sleep(50) WEnd While $todo = 2 OkAd() Sleep(50) WEnd While $todo = 3 SIR() Sleep(50) WEnd While $todo = 4 Done() WEnd Exit Func OkAn() WinActivate ("Main") sleep(100) $MainHWnd = WinGetHandle("Main") $SearAr = $OkAnAr ;Array 0 to 3 should be set according to predefined coords $SearCol = $OkAnCol $GotPos = PixelSearch($SearAr[0],$SearAr[1],$SearAr[2],$SearAr[3],$SearCol,20,1,$MainHwnd) ;x and y should be saved to this array Sleep(1000) If Not @error Then ControlClick("Main","","","left",1,$GotPos[0],$GotPos[1]) ;x and y should be taken from this array ElseIf @error Then $todo = 2 OkAd() EndIf EndFunc Func OkAd() WinActivate ("Main") sleep(100) $MainHWnd = WinGetHandle("Main") $SearAr = $OkAdAr ;Array 0 to 3 should be set according to predefined coords $SearCol = $OkAdAr ;color code should be set according to predefined settings $GotPos = PixelSearch($SearAr[0],$SearAr[1],$SearAr[2],$SearAr[3],$SearCol,20,1,$MainHwnd) ;x and y should be saved to this array Sleep(1000) If Not @error Then ControlClick("Main","","","left",1,$GotPos[0],$GotPos[1]) ;x and y should be taken from this array ElseIf @error Then $todo = 3 SIR() EndIf EndFunc Func SIR() WinActivate ("Main") sleep(100) $MainHWnd = WinGetHandle("Main") $SearAr = $SIRAr ;Array 0 to 3 should be set according to predefined coords $SearCol = $SIRCol ;color code should be set according to predefined settings $GotPos = PixelSearch($SearAr[0],$SearAr[1],$SearAr[2],$SearAr[3],$SearCol,20,1,$MainHwnd) ;x and y should be saved to this array Sleep(1000) If Not @error Then ControlClick("Main","","","left",1,$GotPos[0],$GotPos[1]) ;x and y should be taken from this array ElseIf @error Then $todo = 4 OkAd() EndIf EndFunc Func Done() WinActivate ("Main") sleep(100) $MainHWnd = WinGetHandle("Main") $SearAr = $DoneAr ;Array 0 to 3 should be set according to predefined coords $SearCol = $DoneCol ;color code should be set according to predefined settings $GotPos = PixelSearch($SearAr[0],$SearAr[1],$SearAr[2],$SearAr[3],$SearCol,20,1,$MainHwnd) ;x and y should be saved to this array Sleep(1000) If @error Then ControlClick("Main","","","left",1,$GotPos[0],$GotPos[1]) ;x and y should be taken from this array ElseIf Not @error Then $todo = 5 OkAd() EndIf EndFunc What i get using this Code is: ControlClick("Main","","","left",1,$GotPos[0],$GotPos[1]) ControlClick("Main","","","left",1,$GotPos^ ERROR ->01:37:46 AutoIt3.exe ended.rc:1 Hope you can help me out on this as i am only about to get started using autoit.
-
Pixelgetcolor and infotool seem to get wrong values
Atzi replied to Atzi's topic in AutoIt General Help and Support
Seems to work now. Thx a lot! Also had a glince into the imagefind function. Do you maybe know, if there is a way to use it inside a hwnd (doesnt matter if it has to be active for this)... i know i could just use it on desktop but there are some downsides i guess... would have to set all up with desktop coords but i would prefer to use window coords to set the area to search as it wouldnt be depending on the window location and therefore wouldnt change if window was moved. Could be an alternative for pixelsearch with less chance of false positives i guess... just in case i can hook the func to specific windows as pixelfind tho. -
Pixelgetcolor and infotool seem to get wrong values
Atzi replied to Atzi's topic in AutoIt General Help and Support
Thx for all the thoughts you put into this. I guess i will simply put scaling in win to 100% tho and hope i can work out the func this way... dont need to have it to 150% anyway cant even remember to have it set to this Will tell you if i managed to get this working once i got time to code it (hope this weekend) -
Pixelgetcolor and infotool seem to get wrong values
Atzi replied to Atzi's topic in AutoIt General Help and Support
Hi first i wanna thank you that you are willing to help me here. Didn't have a chance to test your codes yet tho. Do you mind explaining what this exactly does? I am running @full hd if that matters because what i found searching this function it should be more suited to higher resolutions. Also is the dpi scaling your talking off sth in the graphic settings of win10? Could it help to update the graphic drivers or doesnt this impact the get pixel in any way didnt do updates for a while as i didnt use this pc for a while Edit: just had a chance to check for updates... driver is uptodate anyway. Also found out what you meant with dpi scaling and it seems to have done the trick! It now seems to show proper color/coord in windowinfo tool at least. Hope i get time to test this on code tomorrow. Thos really helped me thus far tho - thanx a lot! Scaling was 150÷ in win10 settings -
Start () Func Start () WinActivate ("Neue Bitmap - Paint") sleep(2000) ConsoleWrite(Hex(PixelGetColor(721,313)) & @CR) ConsoleWrite(Hex(PixelGetColor(907,535)) & @CR) EndFunc Hi there. I am new to this forum and to programming, so i could really use some help here. No matter what mode i use in the infotool to get the coords of the pixels (window or desktop) When i check the color valies of my script on the internet they seem to be completely different colors. Also when i use the infotool to mouseover to get value they dont fit the colors. If i hover over various different colors (no matter if frozen or not) the value sometimes simply doesnt change. My OS is win10 home if that matters btw. Really hope s1 can get me started on this.